branch: elpa/with-editor
commit f69daaf0acd9096bd3758fdc73a34b1a48d9c4f1
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
with-editor-{finish,cancel}: Run post hooks in correct directory
Run `with-editor-post-{finish,cancel}-hook' in the same directory as
was current in the buffer from which `with-editor-{finish,cancel}'
was invoked. This is necessary because running `with-editor-return'
likely changes the value of `default-directory', since it changes
the current directory.
---
with-editor.el | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/with-editor.el b/with-editor.el
index ba01946..88c55ba 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -332,11 +332,13 @@ And some tools that do not handle $EDITOR properly also
break."
(when (run-hook-with-args-until-failure
'with-editor-finish-query-functions force)
(let ((with-editor-post-finish-hook-1
- (ignore-errors (delq t with-editor-post-finish-hook))))
+ (ignore-errors (delq t with-editor-post-finish-hook)))
+ (dir default-directory))
(run-hooks 'with-editor-pre-finish-hook)
(with-editor-return nil)
(accept-process-output nil 0.1)
- (run-hooks 'with-editor-post-finish-hook-1))))
+ (let ((default-directory dir))
+ (run-hooks 'with-editor-post-finish-hook-1)))))
(defun with-editor-cancel (force)
"Cancel the current edit session."
@@ -348,11 +350,13 @@ And some tools that do not handle $EDITOR properly also
break."
(setq message (funcall message)))
(let ((with-editor-post-cancel-hook-1
(ignore-errors (delq t with-editor-post-cancel-hook)))
- (with-editor-cancel-alist nil))
+ (with-editor-cancel-alist nil)
+ (dir default-directory))
(run-hooks 'with-editor-pre-cancel-hook)
(with-editor-return t)
(accept-process-output nil 0.1)
- (run-hooks 'with-editor-post-cancel-hook-1))
+ (let ((default-directory dir))
+ (run-hooks 'with-editor-post-cancel-hook-1)))
(message (or message "Canceled by user")))))
(defun with-editor-return (cancel)