[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 8b3acf7473 4/6: Fix killing process if user inp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 8b3acf7473 4/6: Fix killing process if user input is aborted |
Date: |
Sat, 22 Jul 2023 22:01:16 -0400 (EDT) |
branch: elpa/git-commit
commit 8b3acf7473f4ba7a734fd5e0d7c24cd2fe1b146b
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Fix killing process if user input is aborted
Closes #4962.
---
lisp/magit-process.el | 62 ++++++++++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 64295e3bd8..17c4607bd1 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -773,20 +773,24 @@ Magit status buffer."
(run-hook-with-args-until-success 'magit-process-prompt-functions
proc string))))
-(defmacro magit-process-kill-on-abort (proc &rest body)
- (declare (indent 1) (debug (form body)))
- (let ((map (cl-gensym)))
- `(let ((,map (make-sparse-keymap)))
- (set-keymap-parent ,map minibuffer-local-map)
- ;; Note: Leaving (kbd ...) unevaluated leads to the
- ;; magit-process:password-prompt test failing.
- (keymap-set ,map "C-g"
- (lambda ()
- (interactive)
- (ignore-errors (kill-process ,proc))
- (abort-recursive-edit)))
- (let ((minibuffer-local-map ,map))
- ,@body))))
+(defun magit-process-make-keymap (process parent)
+ "Remap `abort-minibuffers' to a command that also kills PROCESS.
+PARENT is used as the parent of the returned keymap."
+ (let ((cmd (lambda ()
+ (interactive)
+ (ignore-errors (kill-process process))
+ (abort-minibuffers))))
+ (define-keymap :parent parent
+ "C-g" cmd
+ "<remap> <abort-minibuffers>" cmd)))
+
+(defmacro magit-process-kill-on-abort (process &rest body)
+ (declare (indent 1)
+ (debug (form body))
+ (obsolete magit-process-make-keymap "Magit 4.0.0"))
+ `(let ((minibuffer-local-map
+ (magit-process-make-keymap ,process minibuffer-local-map)))
+ ,@body))
(defun magit-process-remove-bogus-errors (str)
(save-match-data
@@ -805,9 +809,14 @@ Magit status buffer."
(process-send-string
process
(if (save-match-data
- (let ((max-mini-window-height 30))
- (magit-process-kill-on-abort process
- (yes-or-no-p (substring string 0 beg)))))
+ (let ((max-mini-window-height 30)
+ (minibuffer-local-map
+ (magit-process-make-keymap process minibuffer-local-map))
+ ;; In case yes-or-no-p is fset to that, but does
+ ;; not cover use-dialog-box-p and y-or-n-p-read-key.
+ (y-or-n-p-map
+ (magit-process-make-keymap process y-or-n-p-map)))
+ (yes-or-no-p (substring string 0 beg))))
(concat (downcase (match-string 1 string)) "\n")
(concat (downcase (match-string 2 string)) "\n")))))
@@ -890,12 +899,14 @@ from the user."
(when-let ((prompt (magit-process-match-prompt
magit-process-password-prompt-regexps string)))
(process-send-string
- process (magit-process-kill-on-abort process
- (concat (or (and-let* ((key (match-string 99 string)))
- (run-hook-with-args-until-success
- 'magit-process-find-password-functions key))
- (read-passwd prompt))
- "\n")))))
+ process
+ (concat (or (and-let* ((key (match-string 99 string)))
+ (run-hook-with-args-until-success
+ 'magit-process-find-password-functions key))
+ (let ((read-passwd-map
+ (magit-process-make-keymap process read-passwd-map)))
+ (read-passwd prompt)))
+ "\n"))))
(defun magit-process-username-prompt (process string)
"Forward username prompts to the user."
@@ -903,8 +914,9 @@ from the user."
magit-process-username-prompt-regexps string)))
(process-send-string
process
- (magit-process-kill-on-abort process
- (concat (read-string process nil nil (user-login-name)) "\n")))))
+ (let ((minibuffer-local-map
+ (magit-process-make-keymap process minibuffer-local-map)))
+ (concat (read-string prompt nil nil (user-login-name)) "\n")))))
(defun magit-process-match-prompt (prompts string)
"Match STRING against PROMPTS and set match data.
- [nongnu] elpa/git-commit updated (2126eab6a9 -> eba1e855f3), ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit 38138c14e8 1/6: Don't try to load magit-libgit when magit-inhibit-libgit is set, ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit 1127aa8b3d 2/6: magit-process-username-prompt: Cosmetics, ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit 4efdc7066f 3/6: magit-process-yes-or-no-prompt: Cosmetics, ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit f620d6899f 5/6: Use abort-recursive-edit if abort-minibuffers is not available yet, ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit eba1e855f3 6/6: Silence byte-compiler on Emacs 26.3 and older, ELPA Syncer, 2023/07/22
- [nongnu] elpa/git-commit 8b3acf7473 4/6: Fix killing process if user input is aborted,
ELPA Syncer <=