branch: elpa/with-editor
commit ac6b2e3aa219a6e0073341665bee859f19627519
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
with-editor*: New macro
---
with-editor.el | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/with-editor.el b/with-editor.el
index 88c55ba..2f6fcca 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -448,7 +448,8 @@ or \\[with-editor-cancel] to cancel"))))))
"Use the Emacsclient as $EDITOR while evaluating BODY.
Modify the `process-environment' for processes started in BODY,
instructing them to use the Emacsclient as $EDITOR. If optional
-ENVVAR is provided then bind that environment variable instead.
+ENVVAR is a literal string then bind that environment variable
+instead.
\n(fn [ENVVAR] BODY...)"
(declare (indent defun) (debug (body)))
`(let ((with-editor--envvar ,(if (stringp (car body))
@@ -458,6 +459,19 @@ ENVVAR is provided then bind that environment variable
instead.
(with-editor--setup)
,@body))
+(defmacro with-editor* (envvar &rest body)
+ "Use the Emacsclient as the editor while evaluating BODY.
+Modify the `process-environment' for processes started in BODY,
+instructing them to use the Emacsclient as editor. ENVVAR is the
+environment variable that is exported to do so, it is evaluated
+at run-time.
+\n(fn [ENVVAR] BODY...)"
+ (declare (indent defun) (debug (body)))
+ `(let ((with-editor--envvar ,envvar)
+ (process-environment process-environment))
+ (with-editor--setup)
+ ,@body))
+
(defun with-editor--setup ()
(if (or (not with-editor-emacsclient-executable)
(file-remote-p default-directory))