emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/edit-indirect 2fc8f382ee 19/28: Add before-commit-hook


From: ELPA Syncer
Subject: [nongnu] elpa/edit-indirect 2fc8f382ee 19/28: Add before-commit-hook
Date: Thu, 7 Jul 2022 11:59:14 -0400 (EDT)

branch: elpa/edit-indirect
commit 2fc8f382ee12fc8f7202288534258186bdf6068a
Author: Joost Diepenmaat <joost@zeekat.nl>
Commit: Fanael Linithien <fanael4@gmail.com>

    Add before-commit-hook
    
    Provide a hook to be called before committing changes with the
    edit-indirect buffer as the current buffer. Will be called before the
    edit-indirect-before-commit-functions hook.
    
    This provides the necessary symmetry for doing per-edit custom hooks;
    in an edit-indirect-after-create-hook you can add a buffer-local
    edit-indirect-before-commit-hook, which will then be called only when
    the then-active edit is comitted. You cannot use
    edit-indirect-before-commit-functions for that since that hook is
    called from the parent buffer (so it will apply to any edit committed
    to the parent buffer).
---
 edit-indirect.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/edit-indirect.el b/edit-indirect.el
index 28b4a2e275..569e2adcd6 100644
--- a/edit-indirect.el
+++ b/edit-indirect.el
@@ -63,6 +63,16 @@ Note that the buffer-local value from the parent buffer is 
used."
   :type 'hook
   :group 'edit-indirect)
 
+(defcustom edit-indirect-before-commit-hook nil
+  "Functions called before the edit-indirect buffer is committed.
+The functions are called with the edit-indirect buffer as the
+current buffer.
+
+Note that the buffer-local value from the edit-indirect buffer is
+used."
+  :type 'hook
+  :group 'edit-indirect)
+
 (defcustom edit-indirect-before-commit-functions nil
   "Functions called before an edit-indirect buffer is committed.
 The functions are called with the parent buffer as the current
@@ -296,6 +306,7 @@ No error is signaled if `inhibit-read-only' or
 
 (defun edit-indirect--commit ()
   "Commit the modifications done in an edit-indirect buffer."
+  (run-hooks 'edit-indirect-before-commit-hook)
   (let ((beg (overlay-start edit-indirect--overlay))
         (end (overlay-end edit-indirect--overlay))
         (buffer (current-buffer))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]