changeset 82839:af7dc7457402

add mh-annotate-msg-hook
author Stephen Gildea <gildea@stop.mail-abuse.org>
date Sat, 25 Aug 2007 14:12:58 +0000
parents fccd8136f3d6
children b68e2945d3d0
files lisp/mh-e/ChangeLog lisp/mh-e/mh-comp.el lisp/mh-e/mh-e.el
diffstat 3 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mh-e/ChangeLog	Sat Aug 25 14:09:24 2007 +0000
+++ b/lisp/mh-e/ChangeLog	Sat Aug 25 14:12:58 2007 +0000
@@ -1,3 +1,10 @@
+2007-08-25  Stephen Gildea  <gildea@stop.mail-abuse.org>
+
+	* mh-e.el (mh-annotate-msg-hook): New variable.
+
+	* mh-comp.el (mh-annotate-msg): Call new mh-annotate-msg-hook.
+	(mh-annotate-list): New variable, for mh-annotate-msg-hook.
+
 2007-08-21  Jeffrey C Honig  <jch@honig.net>
 
 	* mh-folder.el (mh-folder-message-menu, mh-folder-mode-map): Add
--- a/lisp/mh-e/mh-comp.el	Sat Aug 25 14:09:24 2007 +0000
+++ b/lisp/mh-e/mh-comp.el	Sat Aug 25 14:12:58 2007 +0000
@@ -136,6 +136,10 @@
 (defvar mh-annotate-field nil
   "Field name for message annotation.")
 
+(defvar mh-annotate-list nil
+  "Messages annotated, either a sequence name or a list of message numbers.
+This variable can be used by `mh-annotate-msg-hook'.")
+
 (defvar mh-insert-auto-fields-done-local nil
   "Buffer-local variable set when `mh-insert-auto-fields' called successfully.")
 (make-variable-buffer-local 'mh-insert-auto-fields-done-local)
@@ -975,18 +979,23 @@
     (goto-char (point-max))
     (mh-letter-next-header-field)))
 
-(defun mh-annotate-msg (msg buffer note &rest args)
-  "Mark MSG in BUFFER with character NOTE and annotate message with ARGS.
-MSG can be a message number, a list of message numbers, or a
-sequence."
-  (apply 'mh-exec-cmd "anno" buffer
+(defun mh-annotate-msg (msg folder note &rest args)
+  "Mark MSG in FOLDER with character NOTE and annotate message with ARGS.
+MSG can be a message number, a list of message numbers, or a sequence.  
+The hook `mh-annotate-msg-hook' is run after annotating; see its
+documentation for variables it can use."
+  (apply 'mh-exec-cmd "anno" folder
          (if (listp msg) (append msg args) (cons msg args)))
   (save-excursion
-    (cond ((get-buffer buffer)          ; Buffer may be deleted
-           (set-buffer buffer)
+    (cond ((get-buffer folder)          ; Buffer may be deleted
+           (set-buffer folder)
            (mh-iterate-on-range nil msg
              (mh-notate nil note
-                        (+ mh-cmd-note mh-scan-field-destination-offset)))))))
+                        (+ mh-cmd-note mh-scan-field-destination-offset))))))
+  (let ((mh-current-folder folder)
+        ;; mh-annotate-list is a sequence name or a list of message numbers
+        (mh-annotate-list (if (numberp msg) (list msg) msg)))
+    (run-hooks 'mh-annotate-msg-hook)))
 
 (defun mh-insert-header-separator ()
   "Insert `mh-mail-header-separator', if absent."
--- a/lisp/mh-e/mh-e.el	Sat Aug 25 14:09:24 2007 +0000
+++ b/lisp/mh-e/mh-e.el	Sat Aug 25 14:12:58 2007 +0000
@@ -3032,6 +3032,15 @@
   :group 'mh-alias
   :package-version '(MH-E . "8.0"))
 
+(defcustom-mh mh-annotate-msg-hook nil
+  "Hook run by `mh-annotate-msg' after annotation.
+Variables that are useful in this hook include `mh-current-folder',
+the current folder, and `mh-annotate-list', the messages annotated."
+  :type 'hook
+  :group 'mh-hooks
+  :group 'mh-sending-mail
+  :package-version '(MH-E . "8.1"))
+
 (defcustom-mh mh-before-commands-processed-hook nil
   "Hook run by \\<mh-folder-mode-map>\\[mh-execute-commands] before performing outstanding refile and delete requests.