[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-editor 71e61b9 081/140: with-editor-sleeping-editor:
From: |
Jonas Bernoulli |
Subject: |
[nongnu] elpa/with-editor 71e61b9 081/140: with-editor-sleeping-editor: Also print the working directory |
Date: |
Fri, 6 Aug 2021 12:51:24 -0400 (EDT) |
branch: elpa/with-editor
commit 71e61b960adf908309232e374c0878e62e09d9a3
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
with-editor-sleeping-editor: Also print the working directory
When `git-commit' is invoked from a sub-directory, then it changes the
working directory to the root of the working tree before invoking the
editor. Additionally it ask the editor to edit a relative path in
most cases. That path is relative to the top-level, so we need the
sleeping editor to also print the name of that directory; or we would
end up trying to edit e.g. "/path/to/repo/subdir/.git/COMMIT_EDITMSG"
instead of "/path/to/repo/.git/COMMIT_EDITMSG".
Actually, as of 2.19.0, `git-commit' no longer does this, it uses an
absolute file-name now. But programs might still do it and that is
legitimate. `$EDITOR' inherits the working directory from its parent
process, so it normally isn't a problem if the file-name is relative.
It only a problem here because `$EDITOR' in hour case forwards the
edit request to a running `emacs' instance, which is not a child
process and therefore does not inherit the working directory.
Fixes #55.
---
with-editor.el | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/with-editor.el b/with-editor.el
index b61104a..8afa487 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -173,7 +173,7 @@ please see
https://github.com/magit/magit/wiki/Emacsclient."))))
(defcustom with-editor-sleeping-editor "\
sh -c '\
-echo \"WITH-EDITOR: $$ OPEN $0\"; \
+echo \"WITH-EDITOR: $$ OPEN $0 IN $(pwd)\"; \
sleep 604800 & sleep=$!; \
trap \"kill $sleep; exit 0\" USR1; \
trap \"kill $sleep; exit 1\" USR2; \
@@ -202,7 +202,7 @@ with \"bash\" (and install that), or you can use the older,
less
performant implementation:
\"sh -c '\\
- echo \\\"WITH-EDITOR: $$ OPEN $0\\\"; \\
+ echo \\\"WITH-EDITOR: $$ OPEN $0 in $(pwd)\\\"; \\
trap \\\"exit 0\\\" USR1; \\
trap \\\"exit 1\" USR2; \\
while true; do sleep 1; done'\"
@@ -211,6 +211,7 @@ Note that this leads to a delay of up to a second. The
delay can
be shortened by replacing \"sleep 1\" with \"sleep 0.01\", or if your
implementation does not support floats, then by using `nanosleep'
instead."
+ :package-version '(with-editor . "2.8.0")
:group 'with-editor
:type 'string)
@@ -552,14 +553,17 @@ which may or may not insert the text into the PROCESS'
buffer."
(defun with-editor-output-filter (string)
(save-match-data
- (if (string-match "^WITH-EDITOR: \\([0-9]+\\) OPEN \\(.+?\\)\r?$" string)
+ (if (string-match "^WITH-EDITOR: \
+\\([0-9]+\\) OPEN \\([^]+?\\)\
+\\(?: IN \\([^\r]+?\\)\\)?\r?$" string)
(let ((pid (match-string 1 string))
- (file (match-string 2 string)))
- (with-current-buffer
- (find-file-noselect
- (if (and (file-name-absolute-p file) default-directory)
- (concat (file-remote-p default-directory) file)
- (expand-file-name file)))
+ (file (match-string 2 string))
+ (dir (match-string 3 string)))
+ (unless (file-name-absolute-p file)
+ (setq file (expand-file-name file dir)))
+ (when default-directory
+ (setq file (concat (file-remote-p default-directory) file)))
+ (with-current-buffer (find-file-noselect file)
(with-editor-mode 1)
(setq with-editor--pid pid)
(run-hooks 'with-editor-filter-visit-hook)
- [nongnu] elpa/with-editor cacb41d 062/140: make: use same export settings as for manual Org exports, (continued)
- [nongnu] elpa/with-editor cacb41d 062/140: make: use same export settings as for manual Org exports, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ee39f23 065/140: make: generate CDN invalidation after upload, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 73d3d1a 066/140: Use the emacsclient again when running shell commands, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ff3e969 077/140: make: Refactor manual publishing, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 3ad940c 086/140: Update documentation, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor db11c10 089/140: Release version 2.8.0, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 46a7b51 090/140: with-editor-{finish, cancel}-hook: No longer ignore global value, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 66bec91 098/140: Release version 2.8.3, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor bc184cf 075/140: Changing heading of library footer section, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 22a581d 076/140: make: Remove deleted pages when publishing manual, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 71e61b9 081/140: with-editor-sleeping-editor: Also print the working directory,
Jonas Bernoulli <=
- [nongnu] elpa/with-editor d3b0bc7 083/140: Update documentation, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 87c96b3 091/140: with-editor-finish: Preserve local git-commit-post-finish-hook, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ef0ef43 093/140: manual: Call ox-texinfo+-update-copyright-years while exporting, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 513e13f 097/140: Fix previous commit, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ff23166 099/140: Add .github/FUNDING.yml, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor f5a8d96 100/140: with-editor-usage-message: Delay message a little longer, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ba4ca8a 108/140: with-editor-finish: Fix bug concerning git-commit-post-finish-hook, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 324285f 109/140: Add htmlxref.cnf, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 9097321 112/140: with-editor-export-editor: Fix for term-mode, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d8f2e99 116/140: Fix typo, Jonas Bernoulli, 2021/08/06