From bead2be87fd1d9fa381a7d0da1ad7fd33c2982a9 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 7 Nov 2024 12:54:30 +0100 Subject: [PATCH] update with-editor Signed-off-by: Andreas Gerler --- .../dir | 0 .../with-editor-autoloads.el | 2 +- .../with-editor-pkg.el | 6 +- .../with-editor.el | 85 ++++++++++--------- .../with-editor.info | 46 +++++----- 5 files changed, 70 insertions(+), 69 deletions(-) rename elpa/{with-editor-20240415.1558 => with-editor-20240725.1429}/dir (100%) rename elpa/{with-editor-20240415.1558 => with-editor-20240725.1429}/with-editor-autoloads.el (97%) rename elpa/{with-editor-20240415.1558 => with-editor-20240725.1429}/with-editor-pkg.el (72%) rename elpa/{with-editor-20240415.1558 => with-editor-20240725.1429}/with-editor.el (94%) rename elpa/{with-editor-20240415.1558 => with-editor-20240725.1429}/with-editor.info (93%) diff --git a/elpa/with-editor-20240415.1558/dir b/elpa/with-editor-20240725.1429/dir similarity index 100% rename from elpa/with-editor-20240415.1558/dir rename to elpa/with-editor-20240725.1429/dir diff --git a/elpa/with-editor-20240415.1558/with-editor-autoloads.el b/elpa/with-editor-20240725.1429/with-editor-autoloads.el similarity index 97% rename from elpa/with-editor-20240415.1558/with-editor-autoloads.el rename to elpa/with-editor-20240725.1429/with-editor-autoloads.el index 216c865d..bab4ee11 100644 --- a/elpa/with-editor-20240415.1558/with-editor-autoloads.el +++ b/elpa/with-editor-20240725.1429/with-editor-autoloads.el @@ -88,7 +88,7 @@ If COMMAND ends with \"&\" behave like the latter, else like the former. (fn COMMAND &optional OUTPUT-BUFFER ERROR-BUFFER ENVVAR)" t) -(register-definition-prefixes "with-editor" '("server-" "shell-command--shell-command-with-editor-mode" "start-file-process--with-editor-process-filter" "with-editor")) +(register-definition-prefixes "with-editor" '("server-" "shell-command" "start-file-process" "with-editor")) ;;; End of scraped data diff --git a/elpa/with-editor-20240415.1558/with-editor-pkg.el b/elpa/with-editor-20240725.1429/with-editor-pkg.el similarity index 72% rename from elpa/with-editor-20240415.1558/with-editor-pkg.el rename to elpa/with-editor-20240725.1429/with-editor-pkg.el index 55681086..2107e45b 100644 --- a/elpa/with-editor-20240415.1558/with-editor-pkg.el +++ b/elpa/with-editor-20240725.1429/with-editor-pkg.el @@ -1,7 +1,7 @@ -(define-package "with-editor" "20240415.1558" "Use the Emacsclient as $EDITOR" +(define-package "with-editor" "20240725.1429" "Use the Emacsclient as $EDITOR" '((emacs "25.1") - (compat "29.1.4.1")) - :commit "1b4526453ef6bdee30635f469aa26085c02b1ac1" :authors + (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")) diff --git a/elpa/with-editor-20240415.1558/with-editor.el b/elpa/with-editor-20240725.1429/with-editor.el similarity index 94% rename from elpa/with-editor-20240415.1558/with-editor.el rename to elpa/with-editor-20240725.1429/with-editor.el index 2ecc755c..bef3de92 100644 --- a/elpa/with-editor-20240415.1558/with-editor.el +++ b/elpa/with-editor-20240725.1429/with-editor.el @@ -6,8 +6,8 @@ ;; Homepage: https://github.com/magit/with-editor ;; Keywords: processes terminals -;; Package-Version: 3.3.2 -;; Package-Requires: ((emacs "25.1") (compat "29.1.4.1")) +;; Package-Version: 3.4.0 +;; Package-Requires: ((emacs "25.1") (compat "30.0.0.0")) ;; SPDX-License-Identifier: GPL-3.0-or-later @@ -86,8 +86,6 @@ (declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep)) (declare-function term-emulate-terminal "term" (proc str)) -(declare-function vterm-send-return "vterm" ()) -(declare-function vterm-send-string "vterm" (string &optional paste-p)) (defvar eshell-preoutput-filter-functions) (defvar git-commit-post-finish-hook) (defvar vterm--process) @@ -115,7 +113,7 @@ please see https://github.com/magit/magit/wiki/Emacsclient.")))) (defun with-editor-locate-emacsclient-1 (path depth) (let* ((version-lst (cl-subseq (split-string emacs-version "\\.") 0 depth)) - (version-reg (concat "^" (mapconcat #'identity version-lst "\\.")))) + (version-reg (concat "^" (string-join version-lst "\\.")))) (or (locate-file (cond ((equal (downcase invocation-name) "remacs") "remacsclient") @@ -127,7 +125,7 @@ please see https://github.com/magit/magit/wiki/Emacsclient.")))) (nconc (and (boundp 'debian-emacs-flavor) (list (format ".%s" debian-emacs-flavor))) (cl-mapcon (lambda (v) - (setq v (mapconcat #'identity (reverse v) ".")) + (setq v (string-join (reverse v) ".")) (list v (concat "-" v) (concat ".emacs" v))) (reverse version-lst)) (list "" "-snapshot" ".emacs-snapshot"))) @@ -415,11 +413,15 @@ And some tools that do not handle $EDITOR properly also break." (define-minor-mode with-editor-mode "Edit a file as the $EDITOR of an external process." :lighter with-editor-mode-lighter - ;; Protect the user from killing the buffer without using - ;; either `with-editor-finish' or `with-editor-cancel', - ;; and from removing the key bindings for these commands. - (unless with-editor-mode - (user-error "With-Editor mode cannot be turned off")) + ;; Protect the user from enabling or disabling the mode interactively. + ;; Manually enabling the mode is dangerous because canceling the buffer + ;; deletes the visited file. The mode must not be disabled manually, + ;; either `with-editor-finish' or `with-editor-cancel' must be used. + :interactive nil ; >= 28.1 + (when (called-interactively-p 'any) ; < 28.1 + (setq with-editor-mode (not with-editor-mode)) + (user-error "With-Editor mode is not intended for interactive use")) + ;; The buffer must also not be killed using regular kill commands. (add-hook 'kill-buffer-query-functions #'with-editor-kill-buffer-noop nil t) ;; `server-execute' displays a message which is not @@ -542,8 +544,9 @@ at run-time. with-editor-server-window-alist))) server-window)) -(defun server-switch-buffer--with-editor-server-window-alist - (fn &optional next-buffer &rest args) +(define-advice server-switch-buffer + (:around (fn &optional next-buffer &rest args) + with-editor-server-window-alist) "Honor `with-editor-server-window-alist' (which see)." (let ((server-window (with-current-buffer (or next-buffer (current-buffer)) @@ -553,11 +556,9 @@ at run-time. (with-editor-server-window)))) (apply fn next-buffer args))) -(advice-add 'server-switch-buffer :around - #'server-switch-buffer--with-editor-server-window-alist) - -(defun start-file-process--with-editor-process-filter - (fn name buffer program &rest program-args) +(define-advice start-file-process + (:around (fn name buffer program &rest program-args) + with-editor-process-filter) "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 @@ -580,10 +581,9 @@ the appropriate editor environment variable." (process-put process 'default-dir default-directory) process))) -(advice-add 'start-file-process :around - #'start-file-process--with-editor-process-filter) - -(cl-defun make-process--with-editor-process-filter +(advice-add #'make-process :around + #'make-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 &allow-other-keys) @@ -623,8 +623,6 @@ to set the appropriate editor environment variable." (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' @@ -716,16 +714,18 @@ OPEN \\([^]+?\\)\ (unless no-default-filter (internal-default-process-filter process string))) -(advice-add 'server-visit-files :after - #'server-visit-files--with-editor-file-name-history-exclude) - -(defun server-visit-files--with-editor-file-name-history-exclude - (files _proc &optional _nowait) +(define-advice server-visit-files + (:after (files _proc &optional _nowait) + with-editor-file-name-history-exclude) + "Prevent certain files from being added to `file-name-history'. +Files matching a regexp in `with-editor-file-name-history-exclude' +are prevented from being added to that list." (pcase-dolist (`(,file . ,_) files) (when (cl-find-if (lambda (regexp) (string-match-p regexp file)) with-editor-file-name-history-exclude) - (setq file-name-history (delete file file-name-history))))) + (setq file-name-history + (delete (abbreviate-file-name file) file-name-history))))) ;;; Augmentations @@ -756,7 +756,9 @@ This works in `shell-mode', `term-mode', `eshell-mode' and (add-to-list 'eshell-preoutput-filter-functions #'with-editor-output-filter) (setenv envvar with-editor-sleeping-editor)) - ((derived-mode-p 'vterm-mode) + ((and (derived-mode-p 'vterm-mode) + (fboundp 'vterm-send-return) + (fboundp 'vterm-send-string)) (if with-editor-emacsclient-executable (let ((with-editor--envvar envvar) (process-environment process-environment)) @@ -877,14 +879,15 @@ else like the former." shell-command-default-error-buffer (and async current-prefix-arg (with-editor-read-envvar))))) -(defun shell-command--shell-command-with-editor-mode - (fn command &optional output-buffer error-buffer) - ;; `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. +(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." (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))) @@ -909,9 +912,6 @@ else like the former." (with-editor-process-filter proc str t))) process)))))) -(advice-add 'shell-command :around - #'shell-command--shell-command-with-editor-mode) - ;;; _ (defun with-editor-debug () @@ -980,5 +980,6 @@ See info node `(with-editor)Debugging' for instructions." (provide 'with-editor) ;; Local Variables: ;; indent-tabs-mode: nil +;; byte-compile-warnings: (not docstrings-control-chars) ;; End: ;;; with-editor.el ends here diff --git a/elpa/with-editor-20240415.1558/with-editor.info b/elpa/with-editor-20240725.1429/with-editor.info similarity index 93% rename from elpa/with-editor-20240415.1558/with-editor.info rename to elpa/with-editor-20240725.1429/with-editor.info index 6f4aaf32..e9d476c7 100644 --- a/elpa/with-editor-20240415.1558/with-editor.info +++ b/elpa/with-editor-20240725.1429/with-editor.info @@ -1,4 +1,4 @@ -This is with-editor.info, produced by makeinfo version 6.7 from +This is with-editor.info, produced by makeinfo version 6.8 from with-editor.texi. Copyright (C) 2015-2024 Jonas Bernoulli @@ -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.3.2. +This manual is for With-Editor version 3.4.0. Copyright (C) 2015-2024 Jonas Bernoulli @@ -82,7 +82,7 @@ commit messages and rebase sequences. It also provides some commands and features which are useful by themselves, even if you don’t use Magit. - For information about using this library in you own package, see + For information about using this library in your own package, see *note Using With-Editor as a library::. * Menu: @@ -104,9 +104,9 @@ Emacs (most likely on macOS) without putting the executable on ‘$PATH’, and we have to add another kludge to find it anyway. -- User Option: with-editor-emacsclient-executable - The ‘emacsclient’ executable used as the editor by child process of - this Emacs instance. By using this executable, child processes can - call home to their parent process. + The ‘emacsclient’ executable used as the editor by child processes + of this Emacs instance. By using this executable, child processes + can call home to their parent process. This option is automatically set at startup by looking in ‘exec-path’, and other places where the executable could be @@ -117,19 +117,19 @@ and we have to add another kludge to find it anyway. do it, then you should consider that a temporary kludge and inform the Magit maintainer as described in *note Debugging::. - If With-Editor fails to find a suitable ‘emacsclient’ on you + If With-Editor fails to find a suitable ‘emacsclient’ on your system, then this should be fixed for all users at once, by teaching ‘with-editor-locate-emacsclient’ how to do so on your - system and system like yours. Doing it this way has the advantage, - that you won’t have do it again every time you update Emacs, and - that other users who have installed Emacs the same way as you have, - won’t have to go through the same trouble. + system and systems like yours. Doing it this way has the + advantage, that you won’t have do it again every time you update + Emacs, and that other users who have installed Emacs the same way + as you have, won’t have to go through the same trouble. Note that there also is a nuclear option; setting this variable to ‘nil’ causes the "sleeping editor" described below to be used even for local child processes. Obviously we don’t recommend that you use this except in "emergencies", i.e., before we had a change to - add a kludge appropriate for you setup. + add a kludge appropriate for your setup. -- Function: with-editor-locate-emacsclient The function used to set the initial value of the option @@ -150,7 +150,7 @@ it receives a signal. The sleeping editor is a shell script used as the editor of child processes when the ‘emacsclient’ executable cannot be used. - This fallback is used for asynchronous process started inside the + This fallback is used for asynchronous processes started inside the macro ‘with-editor’, when the process runs on a remote machine or for local processes when ‘with-editor-emacsclient-executable’ is ‘nil’. @@ -211,7 +211,7 @@ for an alternative environment variable such as ‘$GIT_EDITOR’. with ‘&’ and is therefore run asynchronously, then the current Emacs instance is exported as ‘$EDITOR’. - To always use these variants add this to you init file: + To always use these variants add this to your init file: (keymap-global-set " " #'with-editor-async-shell-command) @@ -288,7 +288,7 @@ package::. If BODY begins with a literal string, then that variable is set instead of ‘EDITOR’. - -- Macro: with-editor envvar &rest body + -- Macro: with-editor* envvar &rest body This macro is like ‘with-editor’ instead that the ENVVAR argument is required and that it is evaluated at run-time. @@ -298,7 +298,7 @@ package::. This is done by wrapping the two filter functions using a lambda, which becomes the actual filter. It calls FILTER first, which may or may not insert the text into the PROCESS’s buffer. Then it - calls ‘with-editor-process-filter’, passing t as + calls ‘with-editor-process-filter’, passing ‘t’ as NO-STANDARD-FILTER.  @@ -331,7 +331,7 @@ Appendix A Function and Command Index * with-editor: Using With-Editor as a library. (line 16) -* with-editor <1>: Using With-Editor as a library. +* with-editor*: Using With-Editor as a library. (line 31) * with-editor-async-shell-command: Using With-Editor commands. (line 17) @@ -369,12 +369,12 @@ Appendix B Variable Index Tag Table: Node: Top799 Node: Using the With-Editor package2615 -Node: Configuring With-Editor3201 -Node: Using With-Editor commands7750 -Node: Using With-Editor as a library11051 -Node: Debugging13076 -Node: Function and Command Index13968 -Node: Variable Index15466 +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  End Tag Table -- 2.47.3