Fixed.
[riece] / lisp / riece-yank.el
1 ;;; riece-kill.el --- enter the element in kill-ring
2 ;; Copyright (C) 2004 Masatake YAMATO
3
4 ;; Author: Masatake YAMATO <jet@gyve.org>
5 ;; Keywords: IRC, riece
6
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
21
22 ;;; Commentary:
23 ;;
24 ;; In riece's command buffer, you can send the top element of kill-ring
25 ;; by C-c y. 
26 ;; Don't forget do (riece-command-enable-addon 'riece-yank).
27 ;;
28 ;;; Code:
29 (require 'riece-commands)
30
31 (defgroup riece-yank nil
32   "Enter the element of `kill-ring'"
33   :tag "Yank"
34   :prefix "riece-"
35   :group 'riece)
36
37 (defcustom riece-yank-tick 1
38   "Time span in second to send multiple lines."
39   :type 'number
40   :group 'riece-yank)
41
42 (defvar riece-yank-enabled nil)
43
44 (defun riece-yank-insinuate ()
45   )
46
47 (defun riece-yank-enable ()
48   (define-key riece-command-mode-map "\C-cy" 'riece-command-yank)
49   (setq riece-yank-enabled t))
50 (defun riece-yank-disable ()
51   (define-key riece-command-mode-map "\C-cy" 'undefined)
52   (setq riece-yank-enabled nil))
53
54 (defun riece-command-yank (prefix)
55   (interactive "sPrefix: ")
56   (when (or (not prefix)
57             (string= prefix ""))
58     (setq prefix " "))
59   (let* ((kill (current-kill 0))
60          msg)
61     (unless kill
62       (error "Nothing to send in kill-ring"))
63     (setq msg (split-string kill "\n"))
64     (when (y-or-n-p (format "Send \"%s\"\n? " kill))
65       (mapcar
66        (lambda (x) 
67          (riece-command-send-message (concat prefix x) nil)
68          ;; Without next line, you will be kicked out from ircd.
69          ;; It may means "Don't send much data at once."
70          (sit-for riece-yank-tick))
71        msg))))
72
73 (provide 'riece-yank)
74 ;;; riece-yank.el ends here