Gnus hooks for the mark get/set operations.
authorTed Zlatanov <tzz@lifelogs.com>
Thu, 7 Oct 2010 03:20:36 +0000 (22:20 -0500)
committerTed Zlatanov <tzz@lifelogs.com>
Thu, 7 Oct 2010 03:25:42 +0000 (22:25 -0500)
* gnus-util.el (gnus-run-hooks-with-args): Convenience function to run
hooks with arguments, which is needed for mark update hooks.

* gnus-int.el (gnus-after-set-mark-hook, gnus-before-update-mark-hook):
Hooks for mark updates.
(gnus-request-set-mark, gnus-request-update-mark): Use them.

lisp/ChangeLog
lisp/gnus-int.el
lisp/gnus-util.el

index 7605a87..903b80c 100644 (file)
@@ -1,3 +1,12 @@
+2010-10-07  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * gnus-int.el (gnus-after-set-mark-hook, gnus-before-update-mark-hook):
+       Hooks for mark updates.
+       (gnus-request-set-mark, gnus-request-update-mark): Use them.
+
+       * gnus-util.el (gnus-run-hooks-with-args): Convenience function to run
+       hooks with arguments, which is needed for mark update hooks.
+
 2010-10-06  Julien Danjou  <julien@danjou.info>
 
        * sieve-manage.el: Update example in `Commentary'.
index 33d020f..9ed52d8 100644 (file)
   :group 'gnus-start
   :type 'hook)
 
+(defcustom gnus-after-set-mark-hook nil
+  "Hook called just after marks are set in a group."
+  :group 'gnus-start
+  :type 'hook)
+
+(defcustom gnus-before-update-mark-hook nil
+  "Hook called just before marks are updated in a group."
+  :group 'gnus-start
+  :type 'hook)
+
 (defcustom gnus-server-unopen-status nil
   "The default status if the server is not able to open.
 If the server is covered by Gnus agent, the possible values are
@@ -471,7 +481,8 @@ If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
        action
       (funcall (gnus-get-function gnus-command-method 'request-set-mark)
               (gnus-group-real-name group) action
-              (nth 1 gnus-command-method)))))
+              (nth 1 gnus-command-method))
+      (gnus-run-hook-with-args gnus-after-set-mark-hook group action))))
 
 (defun gnus-request-update-mark (group article mark)
   "Allow the back end to change the mark the user tries to put on an article."
@@ -479,6 +490,7 @@ If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
     (if (not (gnus-check-backend-function
              'request-update-mark (car gnus-command-method)))
        mark
+      (gnus-run-hook-with-args gnus-before-update-mark-hook group article mark)
       (funcall (gnus-get-function gnus-command-method 'request-update-mark)
               (gnus-group-real-name group) article mark))))
 
index b3f73d7..30bc72b 100644 (file)
@@ -1290,6 +1290,11 @@ ARG is passed to the first function."
   (save-current-buffer
     (apply 'run-hooks funcs)))
 
+(defun gnus-run-hook-with-args (hook &rest args)
+  "Does the same as `run-hook-with-args', but saves the current buffer."
+  (save-current-buffer
+    (apply 'run-hook-with-args hook args)))
+
 (defun gnus-run-mode-hooks (&rest funcs)
   "Run `run-mode-hooks' if it is available, otherwise `run-hooks'.
 This function saves the current buffer."