[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-editor 4d3d50b 049/140: with-editor--setup: create fr
From: |
Jonas Bernoulli |
Subject: |
[nongnu] elpa/with-editor 4d3d50b 049/140: with-editor--setup: create from code previously in with-editor |
Date: |
Fri, 6 Aug 2021 12:51:18 -0400 (EDT) |
branch: elpa/with-editor
commit 4d3d50b09dee3305a365d7eb005313d42dddd6ea
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
with-editor--setup: create from code previously in with-editor
This makes it easier to make changes without having to recompile
all packages that use the `with-editor' macro, and the result of
macro-expansion gets smaller too.
---
with-editor.el | 65 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 34 insertions(+), 31 deletions(-)
diff --git a/with-editor.el b/with-editor.el
index de9f3f9..fb60724 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -408,39 +408,42 @@ ENVVAR is provided then bind that environment variable
instead.
(pop body)
'(or with-editor--envvar "EDITOR")))
(process-environment process-environment))
- (if (or (not with-editor-emacsclient-executable)
- (file-remote-p default-directory))
- (push (concat with-editor--envvar "=" with-editor-sleeping-editor)
- process-environment)
- ;; Make sure server-use-tcp's value is valid.
- (unless (featurep 'make-network-process '(:family local))
- (setq server-use-tcp t))
- ;; Make sure the server is running.
- (unless server-process
- (when (server-running-p server-name)
- (setq server-name (format "server%s" (emacs-pid)))
- (when (server-running-p server-name)
- (server-force-delete server-name)))
- (server-start))
- ;; Tell $EDITOR to use the Emacsclient.
- (push (concat with-editor--envvar "="
- (shell-quote-argument with-editor-emacsclient-executable)
- ;; Tell the process where the server file is.
- (and (not server-use-tcp)
- (concat " --socket-name="
- (shell-quote-argument
- (expand-file-name server-name
- server-socket-dir)))))
- process-environment)
- (when server-use-tcp
- (push (concat "EMACS_SERVER_FILE="
- (expand-file-name server-name server-auth-dir))
- process-environment))
- ;; As last resort fallback to the sleeping editor.
- (push (concat "ALTERNATE_EDITOR=" with-editor-sleeping-editor)
- process-environment))
+ (with-editor--setup)
,@body))
+(defun with-editor--setup ()
+ (if (or (not with-editor-emacsclient-executable)
+ (file-remote-p default-directory))
+ (push (concat with-editor--envvar "=" with-editor-sleeping-editor)
+ process-environment)
+ ;; Make sure server-use-tcp's value is valid.
+ (unless (featurep 'make-network-process '(:family local))
+ (setq server-use-tcp t))
+ ;; Make sure the server is running.
+ (unless server-process
+ (when (server-running-p server-name)
+ (setq server-name (format "server%s" (emacs-pid)))
+ (when (server-running-p server-name)
+ (server-force-delete server-name)))
+ (server-start))
+ ;; Tell $EDITOR to use the Emacsclient.
+ (push (concat with-editor--envvar "="
+ (shell-quote-argument with-editor-emacsclient-executable)
+ ;; Tell the process where the server file is.
+ (and (not server-use-tcp)
+ (concat " --socket-name="
+ (shell-quote-argument
+ (expand-file-name server-name
+ server-socket-dir)))))
+ process-environment)
+ (when server-use-tcp
+ (push (concat "EMACS_SERVER_FILE="
+ (expand-file-name server-name server-auth-dir))
+ process-environment))
+ ;; As last resort fallback to the sleeping editor.
+ (push (concat "ALTERNATE_EDITOR=" with-editor-sleeping-editor)
+ process-environment)))
+
(defun with-editor-server-window ()
(or (and buffer-file-name
(cdr (cl-find-if (lambda (cons)
- [nongnu] elpa/with-editor fb9e560 057/140: .travis.yml: fail on byte compilation warnings, (continued)
- [nongnu] elpa/with-editor fb9e560 057/140: .travis.yml: fail on byte compilation warnings, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d68fe1c 061/140: make: rename and sanitize some variables, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 8d3d639 063/140: make: use ox-texinfo+-update-version-strings, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 05338d8 069/140: make: inject style switcher into generated html manual, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 04d59d6 070/140: Release version 2.7.1, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor a77813b 074/140: Update .gitignore, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor ab73c02 027/140: manual: adjust for ox-texinfo+ v1, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 8fa5cef 028/140: Remove spurious paranthesis from Makefile recipe, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 8c95e7d 036/140: Use when-let instead of macros from dash, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 1d34c65 047/140: Use user-error when appropriate, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 4d3d50b 049/140: with-editor--setup: create from code previously in with-editor,
Jonas Bernoulli <=
- [nongnu] elpa/with-editor b591c28 050/140: with-editor-locate-emacsclient: don't assume version string length, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 99d3278 058/140: shell-command: enable with-editor-mode when appropriate, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 50b40a8 059/140: manual: enforce preservation of indentation, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor d34824c 009/140: add .mailmap file, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor fab38c4 016/140: with-editor-export-editor: don't suppress output during setup, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor e300dab 041/140: with-editor-locate-emacsclient: cosmetics, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 791f985 042/140: with-editor-locate-emacsclient: fix previous commit, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor b8641ac 054/140: with-editor-output-filter: don't assume default-directory is valid, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor b0ff338 060/140: manual: put local-variables into an ignored section, Jonas Bernoulli, 2021/08/06
- [nongnu] elpa/with-editor 6147262 064/140: make: remove clean-texi and clean-all targets, Jonas Bernoulli, 2021/08/06