diff options
author | Jonas Bernoulli <jonas@bernoul.li> | 2018-10-09 20:13:37 +0200 |
---|---|---|
committer | Jonas Bernoulli <jonas@bernoul.li> | 2018-10-09 20:13:37 +0200 |
commit | f69daaf0acd9096bd3758fdc73a34b1a48d9c4f1 (patch) | |
tree | f9256f844164f81ed7a8b0faa5cec5496a1e90c2 | |
parent | d3b0bc766371fa6dc2f413a619f2e9717f3d1f24 (diff) |
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.
-rw-r--r-- | with-editor.el | 12 |
1 files 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) |