branch: externals/easy-kill
commit 3401ab7427e34f8913374311bf75d342462fc9b0
Author: Akinori Musha <[email protected]>
Commit: Leo Liu <[email protected]>

    Add exit hooks to `easy-kill` and `easy-mark`
    
    At the moment these hooks are run, the current candidate is still
    accessible and `this-command` has the command that is to put an end to
    easy-kill/easy-mark mode.
---
 easy-kill.el | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index f11de711a1..230b61ccb5 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -74,11 +74,29 @@ string) for appending current selection to previous kill."
   :type '(repeat symbol)
   :group 'killing)
 
+(defcustom easy-kill-exit-hook nil
+  "A list of functions to be called when `easy-kill' exits.
+
+At the moment they are run, the current candidate is still accessible
+and `this-command' has the command that is to put an end to the
+easy-kill mode."
+  :type '(repeat function)
+  :group 'killing)
+
 (defcustom easy-mark-try-things '(url email uuid sexp)
   "A list of things for `easy-mark' to try."
   :type '(repeat symbol)
   :group 'killing)
 
+(defcustom easy-mark-exit-hook nil
+  "A list of functions to be called when `easy-mark' exits.
+
+At the moment they are run, the current candidate is still accessible
+and `this-command' has the command that is to put an end to the
+easy-mark mode."
+  :type '(repeat function)
+  :group 'killing)
+
 (defcustom easy-dup-try-things '(line)
   "A list of things for `easy-dup-before' and `easy-dup-after' to try."
   :type '(repeat symbol)
@@ -572,8 +590,11 @@ checked."
                           (command-remapping cmd nil (list map)))))
                (ignore
                 (easy-kill-destroy-candidate)
-                (unless (or (easy-kill-get mark) (easy-kill-exit-p 
this-command))
-                  (easy-kill-save-candidate))))
+                (if (easy-kill-get mark)
+                    (run-hooks 'easy-mark-exit-hook)
+                  (or (easy-kill-exit-p this-command)
+                      (easy-kill-save-candidate))
+                  (run-hooks 'easy-kill-exit-hook))))
          (error (message "%s:%s" this-command (error-message-string err))
                 nil))))))
 

Reply via email to