From: kaoru Date: Sat, 12 Jun 2004 04:05:37 +0000 (+0000) Subject: * riece-commands.el (riece-command-send-message): Run X-Git-Tag: riece-1_0_1~15 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ff9e99b1cad0ae9f114d7474f07eabe042caec0e;p=elisp%2Friece.git * riece-commands.el (riece-command-send-message): Run riece-command-send-message-hook. * riece-foolproof.el (riece-foolproof-dmacro-override): Removed. (riece-foolproof-command-send-message-function): New function. (riece-foolproof-insinuate): Use hook instead of advice. (riece-foolproof-enable, riece-foolproof-disable): Simplified. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f54030..34740a1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2004-06-12 TAKAHASHI Kaoru + + * riece-commands.el (riece-command-send-message): Run + riece-command-send-message-hook. + + * riece-foolproof.el (riece-foolproof-dmacro-override): Removed. + (riece-foolproof-command-send-message-function): New function. + (riece-foolproof-insinuate): Use hook instead of advice. + (riece-foolproof-enable, riece-foolproof-disable): Simplified. + 2004-06-11 TAKAHASHI Kaoru * riece-foolproof.el (riece-foolproof-dmacro-override): New diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 3436926..0e31a64 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -354,6 +354,7 @@ the layout to the selected layout-name." (defun riece-command-send-message (message notice) "Send MESSAGE to the current channel." + (run-hooks 'riece-command-send-message-hook) (if (equal message "") (error "No text to send")) (riece-check-channel-commands-are-usable) diff --git a/lisp/riece-foolproof.el b/lisp/riece-foolproof.el index 5e06b34..f691a0a 100644 --- a/lisp/riece-foolproof.el +++ b/lisp/riece-foolproof.el @@ -44,38 +44,24 @@ (cdr (riece-identity-assoc identity riece-channel-buffer-alist)))) -(eval-when-compile - (defvar *dmacro-key* nil)) - -(defun riece-foolproof-dmacro-override (&optional arg) - (when (and (fboundp 'dmacro-exec) (boundp '*dmacro-key*)) - (with-current-buffer riece-command-buffer - (if arg - (when (eq (key-binding *dmacro-key*) 'dmacro-exec) - (local-set-key *dmacro-key* #'ignore)) - (when (eq (key-binding *dmacro-key*) 'ignore) - (local-unset-key *dmacro-key*)))))) - -(defun riece-foolproof-insinuate () - (defadvice riece-command-send-message (before riece-foolproof) +(defun riece-foolproof-command-send-message-function () + (when riece-foolproof-enabled (unless (or (not riece-channel-buffer-mode) (riece-foolproof-get-channel-window riece-current-channel)) - (error "%s is not displayed. (maybe channel miss)" + (error "Channel %s is not displayed" (riece-identity-prefix riece-current-channel))) - (unless (null executing-macro) - (error "Don't use `riece-command-send-message' in keyboard macro")))) + (when executing-kbd-macro + (error "%s" "Forbidden to run keyboard macro")))) + +(defun riece-foolproof-insinuate () + (add-hook 'riece-command-send-message-hook + 'riece-foolproof-command-send-message-function)) (defun riece-foolproof-enable () - (riece-foolproof-dmacro-override t) - (ad-enable-advice 'riece-command-send-message 'before 'riece-foolproof) - (ad-activate 'riece-command-send-message) (setq riece-foolproof-enabled t)) (defun riece-foolproof-disable () - (riece-foolproof-dmacro-override nil) - (ad-disable-advice 'riece-command-send-message 'before 'riece-foolproof) - (ad-activate 'riece-command-send-message) (setq riece-foolproof-enabled nil)) (provide 'riece-foolproof)