[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-editor d79c324 118/140: Add an advice for `make-proce
From: |
Jonas Bernoulli |
Subject: |
[nongnu] elpa/with-editor d79c324 118/140: Add an advice for `make-process' |
Date: |
Fri, 6 Aug 2021 12:51:32 -0400 (EDT) |
branch: elpa/with-editor
commit d79c3249707155a403029f1d7fb5efa379c2cdf1
Author: Philipp Stephani <phst@google.com>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Add an advice for `make-process'
This is necessary because in Emacs 27, `make-process' can also start
remote processes.
Fixes #75.
---
with-editor.el | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/with-editor.el b/with-editor.el
index 061156d..aec1e71 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -580,6 +580,47 @@ the appropriate editor environment variable."
(advice-add 'start-file-process :around
'start-file-process--with-editor-process-filter)
+(cl-defun make-process--with-editor-process-filter
+ (fn &rest keys &key name buffer command coding noquery stop
+ connection-type filter sentinel stderr file-handler)
+ "When called inside a `with-editor' form and the Emacsclient
+cannot be used, then give the process the filter function
+`with-editor-process-filter'. To avoid overriding the filter
+being added here you should use `with-editor-set-process-filter'
+instead of `set-process-filter' inside `with-editor' forms.
+
+When the `default-directory' is located on a remote machine and
+FILE-HANDLER is non-nil, then also manipulate COMMAND in order
+to set the appropriate editor environment variable."
+ (if (or (not file-handler) (not with-editor--envvar))
+ (apply fn keys)
+ (when (file-remote-p default-directory)
+ (unless (equal (car command) "env")
+ (push "env" command))
+ (push (concat with-editor--envvar "=" with-editor-sleeping-editor)
+ (cdr command)))
+ (let* ((filter (if filter
+ (lambda (process output)
+ (funcall filter process output)
+ (with-editor-process-filter process output t))
+ #'with-editor-process-filter))
+ (process (funcall fn
+ :name name
+ :buffer buffer
+ :command command
+ :coding coding
+ :noquery noquery
+ :stop stop
+ :connection-type connection-type
+ :filter filter
+ :sentinel sentinel
+ :stderr stderr
+ :file-handler file-handler)))
+ (process-put process 'default-dir default-directory)
+ process)))
+
+(advice-add #'make-process :around #'make-process--with-editor-process-filter)
+
(defun with-editor-set-process-filter (process filter)
"Like `set-process-filter' but keep `with-editor-process-filter'.
Give PROCESS the new FILTER but keep `with-editor-process-filter'
- [nongnu] elpa/with-editor 4f06aba 102/140: with-editor-usage-message: Cosmetics, (continued)
- [nongnu] elpa/with-editor 4f06aba 102/140: with-editor-usage-message: Cosmetics, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 19ebf53 104/140: Handle async-bytecomp-allowed-packages properly, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d5c7772 105/140: with-editor-kill-buffer-noop: Revert previous kludge, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 814777c 107/140: Revert "Add .github/FUNDING.yml", Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d3150a5 110/140: make: Copy indices for htmlified info manuals, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 7e0bf75 111/140: Release version 2.9.1, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 4fe66d4 114/140: Silence byte-compiler, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor f25a707 115/140: make: No longer add dash to ORG_LOAD_PATH, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor e804473 113/140: with-editor-export-editor: Use printf instead of echo, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 7ec873b 117/140: Release version 2.9.2, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d79c324 118/140: Add an advice for `make-process',
Jonas Bernoulli <=
- [nongnu] elpa/with-editor 48ca9bb 119/140: Release version 2.9.3, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor c5e2141 120/140: manual: Fix location of LocalWords, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor efafd48 123/140: Release version 2.9.4, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor c4768f5 125/140: server-switch-buffer: Adjust advice for emacs 28, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 6735180 128/140: Suppress error if vterm module cannot be build, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor b439749 130/140: Remove async-bytecomp kludge, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 2848a90 131/140: license: Update URLs and cleanup whitespace, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 139ef39 129/140: Fix previous commit, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 89280a6 133/140: with-editor-export-editor: Check whether there is a buffer process, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 0708d14 135/140: Add SPDX-License-Identifier library header, Jonas Bernoulli, 2021/08/06