From: <dm...@dm...> - 2002-05-01 13:42:01
|
This patch includes the previous one (configurable /quit messages) and adds the ability to disable the message and (ding) if you type a blank line. --- erc.el.~1.249.~ Fri Apr 26 03:46:35 2002 +++ erc.el Wed May 1 14:38:18 2002 @@ -130,6 +130,10 @@ :group 'erc :type 'boolean) +(defcustom erc-warn-about-blank-lines t + "Warn the user if they attempt to send a blank line." + :group 'erc + :type 'boolean) ;; tunable GUI stuff @@ -448,6 +452,29 @@ :group 'erc :type 'boolean) +(defcustom erc-quit-reason-various-alist nil + "Alist of possible arguments to the /quit command and what should happen +as a result. For example: + (setq erc-quit-reason-various-alist + '((\"zippy\" erc-quit-reason-zippy) + (\"xmms\" dme:now-playing) + (\"version\" erc-quit-reason-normal) + (\"home\" \"Gone home !\"))) +If the user types \"/quit zippy\", then a Zippy the Pinhead quotation +will be used as the quit message. The car of each element should be +a regexp. If none match, the string is inserted directly." + :group 'erc + :type '(repeat (list regexp (choice (string) (function))))) + +(defcustom erc-quit-reason 'erc-quit-reason-normal + "A function which returns the reason for quitting. Passed a single +argument, which is the string typed by the user after \"/quit\"." + :group 'erc + :type '(choice (const erc-quit-reason-normal) + (const erc-quit-reason-zippy) + (const erc-quit-reason-various) + (symbol))) + (defvar erc-grab-buffer-name "*erc-grab*" "The name of the buffer created by `erc-grab-region'.") @@ -2341,6 +2368,28 @@ (erc-update-mode-line)) t) (t nil))) + +(defun erc-quit-reason-normal (&optional s) + "Normal quit message." + (or s + (format "\C-bERC\C-b v%s (IRC client for Emacs)"; - \C-b%s\C-b" + erc-version-string) ; erc-official-location) + )) + +(defun erc-quit-reason-zippy (&optional s) + "Zippy quit message." + (or s + (replace-regexp-in-string "\n" "" (yow)))) + +(defun erc-quit-reason-various (s) + "Choose a quit reason based on the string \"s\"." + (let ((res (car (assoc-default + s erc-quit-reason-various-alist 'string-match)))) + (cond + ((functionp res) (funcall res)) + ((stringp res) res) + (s)))) + (defalias 'erc-cmd-Q 'erc-cmd-QUERY) (defun erc-cmd-QUIT (line &optional force) @@ -2351,16 +2400,12 @@ ((string-match "^\\s-*\\(.*\\)$" line) (let* ((s (match-string 1 line)) (ob (current-buffer)) - (buffer (erc-server-buffer))) + (buffer (erc-server-buffer)) + (reason (funcall erc-quit-reason (if s s "")))) (if (and buffer (bufferp buffer)) (set-buffer buffer)) - (erc-log (format "cmd: QUIT: %s" s)) + (erc-log (format "cmd: QUIT: %s" reason)) (setq quitting t) - (erc-send-command - (if (or (not s) (string= s "")) - (format - "QUIT :\C-bERC\C-b v%s (IRC client for Emacs)"; - \C-b%s\C-b" - erc-version-string) ; erc-official-location) - (format "QUIT :%s" s)) force) + (erc-send-command (format "QUIT :%s" reason) force) (set-buffer ob) (when erc-save-queries-on-quit (erc-save-query-buffers erc-process)) @@ -5028,8 +5073,10 @@ (old-buf (current-buffer))) (cond ((string-match "^\\s-*\n*$" str) - (message "Blank line - ignoring...") - (ding)) + (if erc-warn-about-blank-lines + (progn + (message "Blank line - ignoring...") + (ding)))) ((<= (point) erc-insert-marker) (message "Point is not in the input area") (ding)) |