From 0735c2bf39159335acf8bc9020691fa4583a634d Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 17:12:15 +0100 Subject: [PATCH] update with-editor --- .../dir | 0 .../with-editor-autoloads.el | 14 ++---- .../with-editor-pkg.el | 2 +- .../with-editor.el | 41 ++++++++++++---- .../with-editor.info | 16 +++---- elpa/with-editor-readme.txt | 47 +++++++++++++++++++ 6 files changed, 92 insertions(+), 28 deletions(-) rename elpa/{with-editor-20181113.1845 => with-editor-20191024.1905}/dir (100%) rename elpa/{with-editor-20181113.1845 => with-editor-20191024.1905}/with-editor-autoloads.el (86%) rename elpa/{with-editor-20181113.1845 => with-editor-20191024.1905}/with-editor-pkg.el (81%) rename elpa/{with-editor-20181113.1845 => with-editor-20191024.1905}/with-editor.el (96%) rename elpa/{with-editor-20181113.1845 => with-editor-20191024.1905}/with-editor.info (97%) create mode 100644 elpa/with-editor-readme.txt diff --git a/elpa/with-editor-20181113.1845/dir b/elpa/with-editor-20191024.1905/dir similarity index 100% rename from elpa/with-editor-20181113.1845/dir rename to elpa/with-editor-20191024.1905/dir diff --git a/elpa/with-editor-20181113.1845/with-editor-autoloads.el b/elpa/with-editor-20191024.1905/with-editor-autoloads.el similarity index 86% rename from elpa/with-editor-20181113.1845/with-editor-autoloads.el rename to elpa/with-editor-20191024.1905/with-editor-autoloads.el index cdfafa8e..272dd42f 100644 --- a/elpa/with-editor-20181113.1845/with-editor-autoloads.el +++ b/elpa/with-editor-20191024.1905/with-editor-autoloads.el @@ -1,12 +1,10 @@ ;;; with-editor-autoloads.el --- automatically extracted autoloads ;; ;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "with-editor" "with-editor.el" (0 0 0 0)) +;;;### (autoloads nil "with-editor" "with-editor.el" (23994 46374 +;;;;;; 560489 147000)) ;;; Generated autoloads from with-editor.el (autoload 'with-editor-export-editor "with-editor" "\ @@ -82,11 +80,10 @@ else like the former. \(fn COMMAND &optional OUTPUT-BUFFER ERROR-BUFFER ENVVAR)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "with-editor" '("with-editor" "start-file-process--with-editor-process-filter" "server-" "shell-command--shell-command-with-editor-mode"))) - ;;;*** -;;;### (autoloads nil nil ("with-editor-pkg.el") (0 0 0 0)) +;;;### (autoloads nil nil ("with-editor-pkg.el") (23994 46374 561492 +;;;;;; 929000)) ;;;*** @@ -94,6 +91,5 @@ else like the former. ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 ;; End: ;;; with-editor-autoloads.el ends here diff --git a/elpa/with-editor-20181113.1845/with-editor-pkg.el b/elpa/with-editor-20191024.1905/with-editor-pkg.el similarity index 81% rename from elpa/with-editor-20181113.1845/with-editor-pkg.el rename to elpa/with-editor-20191024.1905/with-editor-pkg.el index b74275f3..f2a28209 100644 --- a/elpa/with-editor-20181113.1845/with-editor-pkg.el +++ b/elpa/with-editor-20191024.1905/with-editor-pkg.el @@ -1,4 +1,4 @@ -(define-package "with-editor" "20181113.1845" "Use the Emacsclient as $EDITOR" +(define-package "with-editor" "20191024.1905" "Use the Emacsclient as $EDITOR" '((emacs "24.4") (async "1.9")) :keywords diff --git a/elpa/with-editor-20181113.1845/with-editor.el b/elpa/with-editor-20191024.1905/with-editor.el similarity index 96% rename from elpa/with-editor-20181113.1845/with-editor.el rename to elpa/with-editor-20191024.1905/with-editor.el index 80929d5d..2d282379 100644 --- a/elpa/with-editor-20181113.1845/with-editor.el +++ b/elpa/with-editor-20191024.1905/with-editor.el @@ -1,6 +1,6 @@ ;;; with-editor.el --- Use the Emacsclient as $EDITOR -*- lexical-binding: t -*- -;; Copyright (C) 2014-2018 The Magit Project Contributors +;; Copyright (C) 2014-2019 The Magit Project Contributors ;; ;; You should have received a copy of the AUTHORS.md file. If not, ;; see https://github.com/magit/with-editor/blob/master/AUTHORS.md. @@ -86,7 +86,10 @@ (require 'shell) (and (require 'async-bytecomp nil t) - (memq 'magit (bound-and-true-p async-bytecomp-allowed-packages)) + (let ((pkgs (bound-and-true-p async-bytecomp-allowed-packages))) + (if (consp pkgs) + (cl-intersection '(all magit) pkgs) + (memq pkgs '(all t)))) (fboundp 'async-bytecomp-package-mode) (async-bytecomp-package-mode 1)) @@ -432,18 +435,36 @@ And some tools that do not handle $EDITOR properly also break." (put 'with-editor-mode 'permanent-local t) (defun with-editor-kill-buffer-noop () - (user-error (substitute-command-keys "\ -Don't kill this buffer. Instead cancel using \\[with-editor-cancel]"))) + ;; We started doing this in response to #64, but it is not safe + ;; to do so, because the client has already been killed, causing + ;; `with-editor-return' (called by `with-editor-cancel') to delete + ;; the file, see #66. The reason we delete the file in the first + ;; place are https://github.com/magit/magit/issues/2258 and + ;; https://github.com/magit/magit/issues/2248. + ;; (if (memq this-command '(save-buffers-kill-terminal + ;; save-buffers-kill-emacs)) + ;; (let ((with-editor-cancel-query-functions nil)) + ;; (with-editor-cancel nil) + ;; t) + ;; ...) + ;; So go back to always doing this instead: + (user-error (substitute-command-keys (format "\ +Don't kill this buffer %S. Instead cancel using \\[with-editor-cancel]" + (current-buffer))))) + +(defvar-local with-editor-usage-message "\ +Type \\[with-editor-finish] to finish, \ +or \\[with-editor-cancel] to cancel") (defun with-editor-usage-message () ;; Run after `server-execute', which is run using ;; a timer which starts immediately. - (run-with-timer - 0.01 nil `(lambda () - (with-current-buffer ,(current-buffer) - (message (substitute-command-keys "\ -Type \\[with-editor-finish] to finish, \ -or \\[with-editor-cancel] to cancel")))))) + (let ((buffer (current-buffer))) + (run-with-timer + 0.05 nil + (lambda () + (with-current-buffer buffer + (message (substitute-command-keys with-editor-usage-message))))))) ;;; Wrappers diff --git a/elpa/with-editor-20181113.1845/with-editor.info b/elpa/with-editor-20191024.1905/with-editor.info similarity index 97% rename from elpa/with-editor-20181113.1845/with-editor.info rename to elpa/with-editor-20191024.1905/with-editor.info index 157b4ce7..0addeba0 100644 --- a/elpa/with-editor-20181113.1845/with-editor.info +++ b/elpa/with-editor-20191024.1905/with-editor.info @@ -1,7 +1,7 @@ This is with-editor.info, produced by makeinfo version 6.5 from with-editor.texi. - Copyright (C) 2015-2018 Jonas Bernoulli + Copyright (C) 2015-2019 Jonas Bernoulli You can redistribute this document and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -39,9 +39,9 @@ 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 2.8.0 (v2.8.0-2-g87c96b3+1). +This manual is for With-Editor version 2.8.3. - Copyright (C) 2015-2018 Jonas Bernoulli + Copyright (C) 2015-2019 Jonas Bernoulli You can redistribute this document and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -329,11 +329,11 @@ Emacs and what is the output of ‘M-x with-editor-debug RET’.  Tag Table: Node: Top773 -Node: Using the With-Editor package2535 -Node: Configuring With-Editor3121 -Node: Using With-Editor commands7670 -Node: Using With-Editor as a library10865 -Node: Debugging12828 +Node: Using the With-Editor package2513 +Node: Configuring With-Editor3099 +Node: Using With-Editor commands7648 +Node: Using With-Editor as a library10843 +Node: Debugging12806  End Tag Table diff --git a/elpa/with-editor-readme.txt b/elpa/with-editor-readme.txt new file mode 100644 index 00000000..34de03bb --- /dev/null +++ b/elpa/with-editor-readme.txt @@ -0,0 +1,47 @@ +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