From fe506775a5ce2f9c48ec43c37852d0a324d11c0a Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:23:57 +0100 Subject: [PATCH] update with-editor Signed-off-by: Andreas Gerler --- .../with-editor-pkg.el | 15 --- .../dir | 0 .../with-editor-autoloads.el | 14 +-- .../with-editor-pkg.el | 11 +++ .../with-editor.el | 92 ++++++++++--------- .../with-editor.info | 16 ++-- elpa/with-editor-readme.txt | 47 ---------- 7 files changed, 76 insertions(+), 119 deletions(-) delete mode 100644 elpa/with-editor-20240725.1429/with-editor-pkg.el rename elpa/{with-editor-20240725.1429 => with-editor-20241201.1419}/dir (100%) rename elpa/{with-editor-20240725.1429 => with-editor-20241201.1419}/with-editor-autoloads.el (96%) create mode 100644 elpa/with-editor-20241201.1419/with-editor-pkg.el rename elpa/{with-editor-20240725.1429 => with-editor-20241201.1419}/with-editor.el (93%) rename elpa/{with-editor-20240725.1429 => with-editor-20241201.1419}/with-editor.info (97%) delete mode 100644 elpa/with-editor-readme.txt diff --git a/elpa/with-editor-20240725.1429/with-editor-pkg.el b/elpa/with-editor-20240725.1429/with-editor-pkg.el deleted file mode 100644 index 2107e45b..00000000 --- a/elpa/with-editor-20240725.1429/with-editor-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "with-editor" "20240725.1429" "Use the Emacsclient as $EDITOR" - '((emacs "25.1") - (compat "30.0.0.0")) - :commit "62dc8ba2184bef074ff0e90eefb70bfa34c21d3c" :authors - '(("Jonas Bernoulli" . "emacs.with-editor@jonas.bernoulli.dev")) - :maintainers - '(("Jonas Bernoulli" . "emacs.with-editor@jonas.bernoulli.dev")) - :maintainer - '("Jonas Bernoulli" . "emacs.with-editor@jonas.bernoulli.dev") - :keywords - '("processes" "terminals") - :url "https://github.com/magit/with-editor") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/with-editor-20240725.1429/dir b/elpa/with-editor-20241201.1419/dir similarity index 100% rename from elpa/with-editor-20240725.1429/dir rename to elpa/with-editor-20241201.1419/dir diff --git a/elpa/with-editor-20240725.1429/with-editor-autoloads.el b/elpa/with-editor-20241201.1419/with-editor-autoloads.el similarity index 96% rename from elpa/with-editor-20240725.1429/with-editor-autoloads.el rename to elpa/with-editor-20241201.1419/with-editor-autoloads.el index bab4ee11..fe538d44 100644 --- a/elpa/with-editor-20240725.1429/with-editor-autoloads.el +++ b/elpa/with-editor-20241201.1419/with-editor-autoloads.el @@ -50,18 +50,18 @@ which also allows the use of another variable instead of This is a global minor mode. If called interactively, toggle the `Shell-Command-With-Editor mode' mode. If the prefix argument is -positive, enable the mode, and if it is zero or negative, disable -the mode. +positive, enable the mode, and if it is zero or negative, disable the +mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `(default-value \\='shell-command-with-editor-mode)'. -The mode's hook is called both when the mode is enabled and when -it is disabled. +The mode's hook is called both when the mode is enabled and when it is +disabled. (fn &optional ARG)" t) (autoload 'with-editor-async-shell-command "with-editor" "\ diff --git a/elpa/with-editor-20241201.1419/with-editor-pkg.el b/elpa/with-editor-20241201.1419/with-editor-pkg.el new file mode 100644 index 00000000..5b93f7ed --- /dev/null +++ b/elpa/with-editor-20241201.1419/with-editor-pkg.el @@ -0,0 +1,11 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "with-editor" "20241201.1419" + "Use the Emacsclient as $EDITOR." + '((emacs "26.1") + (compat "30.0.0.0")) + :url "https://github.com/magit/with-editor" + :commit "ca902ae02972bdd6919a902be2593d8cb6bd991b" + :revdesc "ca902ae02972" + :keywords '("processes" "terminals") + :authors '(("Jonas Bernoulli" . "emacs.with-editor@jonas.bernoulli.dev")) + :maintainers '(("Jonas Bernoulli" . "emacs.with-editor@jonas.bernoulli.dev"))) diff --git a/elpa/with-editor-20240725.1429/with-editor.el b/elpa/with-editor-20241201.1419/with-editor.el similarity index 93% rename from elpa/with-editor-20240725.1429/with-editor.el rename to elpa/with-editor-20241201.1419/with-editor.el index bef3de92..2f854e43 100644 --- a/elpa/with-editor-20240725.1429/with-editor.el +++ b/elpa/with-editor-20241201.1419/with-editor.el @@ -6,8 +6,9 @@ ;; Homepage: https://github.com/magit/with-editor ;; Keywords: processes terminals -;; Package-Version: 3.4.0 -;; Package-Requires: ((emacs "25.1") (compat "30.0.0.0")) +;; Package-Version: 20241201.1419 +;; Package-Revision: ca902ae02972 +;; Package-Requires: ((emacs "26.1") (compat "30.0.0.0")) ;; SPDX-License-Identifier: GPL-3.0-or-later @@ -111,6 +112,10 @@ Determining an Emacsclient executable suitable for the current Emacs instance failed. For more information please see https://github.com/magit/magit/wiki/Emacsclient.")))) +(defvar with-editor-emacsclient-program-suffixes + (list "-snapshot" ".emacs-snapshot") + "Suffixes to append to append when looking for a Emacsclient executables.") + (defun with-editor-locate-emacsclient-1 (path depth) (let* ((version-lst (cl-subseq (split-string emacs-version "\\.") 0 depth)) (version-reg (concat "^" (string-join version-lst "\\.")))) @@ -120,15 +125,16 @@ please see https://github.com/magit/magit/wiki/Emacsclient.")))) ((bound-and-true-p emacsclient-program-name)) ("emacsclient")) path - (cl-mapcan - (lambda (v) (cl-mapcar (lambda (e) (concat v e)) exec-suffixes)) - (nconc (and (boundp 'debian-emacs-flavor) - (list (format ".%s" debian-emacs-flavor))) - (cl-mapcon (lambda (v) - (setq v (string-join (reverse v) ".")) - (list v (concat "-" v) (concat ".emacs" v))) - (reverse version-lst)) - (list "" "-snapshot" ".emacs-snapshot"))) + (mapcan (lambda (v) (cl-mapcar (lambda (e) (concat v e)) exec-suffixes)) + (nconc (and (boundp 'debian-emacs-flavor) + (list (format ".%s" debian-emacs-flavor))) + (cl-mapcon (lambda (v) + (setq v (string-join (reverse v) ".")) + (list v + (concat "-" v) + (concat ".emacs" v))) + (reverse version-lst)) + (cons "" with-editor-emacsclient-program-suffixes))) (lambda (exec) (ignore-errors (string-match-p version-reg @@ -488,7 +494,7 @@ 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...)" +\n(fn ENVVAR BODY...)" (declare (indent defun) (debug (sexp body))) `(let ((with-editor--envvar ,envvar) (process-environment process-environment)) @@ -747,7 +753,7 @@ This works in `shell-mode', `term-mode', `eshell-mode' and (process-send-string process (format " export %s=%s\n" envvar (shell-quote-argument with-editor-sleeping-editor))) - (while (accept-process-output process 0.1)) + (while (accept-process-output process 1 nil t)) (if (derived-mode-p 'term-mode) (with-editor-set-process-filter process #'with-editor-emulate-terminal) (add-hook 'comint-output-filter-functions #'with-editor-output-filter @@ -763,7 +769,7 @@ This works in `shell-mode', `term-mode', `eshell-mode' and (let ((with-editor--envvar envvar) (process-environment process-environment)) (with-editor--setup) - (while (accept-process-output vterm--process 0.1)) + (while (accept-process-output vterm--process 1 nil t)) (when-let ((v (getenv envvar))) (vterm-send-string (format " export %s=%S" envvar v)) (vterm-send-return)) @@ -882,35 +888,37 @@ else like the former." (define-advice shell-command (:around (fn command &optional output-buffer error-buffer) shell-command-with-editor-mode) - "`shell-mode' and its hook are intended for buffers in which an -interactive shell is running, but `shell-command' also turns on -that mode, even though it only runs the shell to run a single -command. The `with-editor-export-editor' hook function is only -intended to be used in buffers in which an interactive shell is -running, so it has to be removed here." + "Set editor envvar, if `shell-command-with-editor-mode' is enabled. +Also take care of that for `with-editor-[async-]shell-command'." + ;; `shell-mode' and its hook are intended for buffers in which an + ;; interactive shell is running, but `shell-command' also turns on + ;; that mode, even though it only runs the shell to run a single + ;; command. The `with-editor-export-editor' hook function is only + ;; intended to be used in buffers in which an interactive shell is + ;; running, so it has to be removed here. (let ((shell-mode-hook (remove 'with-editor-export-editor shell-mode-hook))) - (cond ((or (not (or with-editor--envvar shell-command-with-editor-mode)) - (not (string-suffix-p "&" command))) - (funcall fn command output-buffer error-buffer)) - ((and with-editor-shell-command-use-emacsclient - with-editor-emacsclient-executable - (not (file-remote-p default-directory))) - (with-editor (funcall fn command output-buffer error-buffer))) - (t - (funcall fn (format "%s=%s %s" - (or with-editor--envvar "EDITOR") - (shell-quote-argument with-editor-sleeping-editor) - command) - output-buffer error-buffer) - (ignore-errors - (let ((process (get-buffer-process - (or output-buffer - (get-buffer "*Async Shell Command*"))))) - (set-process-filter - process (lambda (proc str) - (comint-output-filter proc str) - (with-editor-process-filter proc str t))) - process)))))) + (cond + ;; If `with-editor-async-shell-command' was used, then `with-editor' + ;; was used, and `with-editor--envvar'. `with-editor-shell-command' + ;; only goes down that path if the command ends with "&". We might + ;; still have to use `with-editor' here, for `async-shell-command' + ;; or `shell-command', if the mode is enabled. + ((and (string-suffix-p "&" command) + (or with-editor--envvar + shell-command-with-editor-mode)) + (if with-editor--envvar + (funcall fn command output-buffer error-buffer) + (with-editor (funcall fn command output-buffer error-buffer))) + ;; The comint filter was overridden with our filter. Use both. + (and-let* ((process (get-buffer-process + (or output-buffer + (get-buffer "*Async Shell Command*"))))) + (prog1 process + (set-process-filter process + (lambda (proc str) + (comint-output-filter proc str) + (with-editor-process-filter proc str t)))))) + ((funcall fn command output-buffer error-buffer))))) ;;; _ diff --git a/elpa/with-editor-20240725.1429/with-editor.info b/elpa/with-editor-20241201.1419/with-editor.info similarity index 97% rename from elpa/with-editor-20240725.1429/with-editor.info rename to elpa/with-editor-20241201.1419/with-editor.info index e9d476c7..fe78f80b 100644 --- a/elpa/with-editor-20240725.1429/with-editor.info +++ b/elpa/with-editor-20241201.1419/with-editor.info @@ -40,7 +40,7 @@ library is made available as a separate package. It also defines some additional functionality which makes it useful even for end-users, who don’t use Magit or another package which uses it internally. -This manual is for With-Editor version 3.4.0. +This manual is for With-Editor version 3.4.3. Copyright (C) 2015-2024 Jonas Bernoulli @@ -115,7 +115,7 @@ and we have to add another kludge to find it anyway. You should *not* customize this option permanently. If you have to do it, then you should consider that a temporary kludge and inform - the Magit maintainer as described in *note Debugging::. + the Magit maintainer as described in *note Debugging: Debugging. If With-Editor fails to find a suitable ‘emacsclient’ on your system, then this should be fixed for all users at once, by @@ -289,7 +289,7 @@ package::. instead of ‘EDITOR’. -- Macro: with-editor* envvar &rest body - This macro is like ‘with-editor’ instead that the ENVVAR argument + This macro is like ‘with-editor’, except that the ENVVAR argument is required and that it is evaluated at run-time. -- Function: with-editor-set-process-filter process filter @@ -370,11 +370,11 @@ Tag Table: Node: Top799 Node: Using the With-Editor package2615 Node: Configuring With-Editor3202 -Node: Using With-Editor commands7758 -Node: Using With-Editor as a library11060 -Node: Debugging13092 -Node: Function and Command Index13984 -Node: Variable Index15482 +Node: Using With-Editor commands7767 +Node: Using With-Editor as a library11069 +Node: Debugging13101 +Node: Function and Command Index13993 +Node: Variable Index15491  End Tag Table diff --git a/elpa/with-editor-readme.txt b/elpa/with-editor-readme.txt deleted file mode 100644 index 34de03bb..00000000 --- a/elpa/with-editor-readme.txt +++ /dev/null @@ -1,47 +0,0 @@ -This library makes it possible to reliably use the Emacsclient as -the `$EDITOR' of child processes. It makes sure that they know how -to call home. For remote processes a substitute is provided, which -communicates with Emacs on standard output/input instead of using a -socket as the Emacsclient does. - -It provides the commands `with-editor-async-shell-command' and -`with-editor-shell-command', which are intended as replacements -for `async-shell-command' and `shell-command'. They automatically -export `$EDITOR' making sure the executed command uses the current -Emacs instance as "the editor". With a prefix argument these -commands prompt for an alternative environment variable such as -`$GIT_EDITOR'. To always use these variants add this to your init -file: - - (define-key (current-global-map) - [remap async-shell-command] 'with-editor-async-shell-command) - (define-key (current-global-map) - [remap shell-command] 'with-editor-shell-command) - -Alternatively use the global `shell-command-with-editor-mode', -which always sets `$EDITOR' for all Emacs commands which ultimately -use `shell-command' to asynchronously run some shell command. - -The command `with-editor-export-editor' exports `$EDITOR' or -another such environment variable in `shell-mode', `term-mode' and -`eshell-mode' buffers. Use this Emacs command before executing a -shell command which needs the editor set, or always arrange for the -current Emacs instance to be used as editor by adding it to the -appropriate mode hooks: - - (add-hook 'shell-mode-hook 'with-editor-export-editor) - (add-hook 'term-exec-hook 'with-editor-export-editor) - (add-hook 'eshell-mode-hook 'with-editor-export-editor) - -Some variants of this function exist, these two forms are -equivalent: - - (add-hook 'shell-mode-hook - (apply-partially 'with-editor-export-editor "GIT_EDITOR")) - (add-hook 'shell-mode-hook 'with-editor-export-git-editor) - -This library can also be used by other packages which need to use -the current Emacs instance as editor. In fact this library was -written for Magit and its `git-commit-mode' and `git-rebase-mode'. -Consult `git-rebase.el' and the related code in `magit-sequence.el' -for a simple example. -- 2.47.3