]> git.eshelyaron.com Git - emacs.git/commitdiff
*-watch-for-password-prompt: Use run-at-time to read password
authorMiha Rihtaršič <miha@kamnitnik.top>
Mon, 18 Oct 2021 13:24:54 +0000 (15:24 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 18 Oct 2021 13:24:54 +0000 (15:24 +0200)
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/eshell/esh-mode.el (eshell-watch-for-password-prompt):
* lisp/term.el (term-watch-for-password-prompt):
Use run-at-time to read a password (bug#51263).

lisp/comint.el
lisp/eshell/esh-mode.el
lisp/term.el

index a0873c0b6a1f1d54be53c0e42fb72c428028a750..e925b3a4b632a5532093e1276b566fa52bdebee1 100644 (file)
@@ -2455,11 +2455,19 @@ This function could be in the list `comint-output-filter-functions'."
   (when (let ((case-fold-search t))
          (string-match comint-password-prompt-regexp
                         (string-replace "\r" "" string)))
-    (let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth)))
-      (if (> comint--prompt-recursion-depth 10)
-          (message "Password prompt recursion too deep")
-        (comint-send-invisible
-         (string-trim string "[ \n\r\t\v\f\b\a]+" "\n+"))))))
+    ;; Use `run-at-time' in order not to pause execution of the
+    ;; process filter with a minibuffer
+    (run-at-time
+     0 nil
+     (lambda (current-buf)
+       (with-current-buffer current-buf
+         (let ((comint--prompt-recursion-depth
+                (1+ comint--prompt-recursion-depth)))
+           (if (> comint--prompt-recursion-depth 10)
+               (message "Password prompt recursion too deep")
+             (comint-send-invisible
+              (string-trim string "[ \n\r\t\v\f\b\a]+" "\n+"))))))
+     (current-buffer))))
 \f
 ;; Low-level process communication
 
index 98e89037f330bc35ed19292cf2c1289959631126..579b01f4d1f1e8f9962a4a9893a0cc722f533ea5 100644 (file)
@@ -940,7 +940,14 @@ This function could be in the list `eshell-output-filter-functions'."
        (beginning-of-line)
        (if (re-search-forward eshell-password-prompt-regexp
                               eshell-last-output-end t)
-           (eshell-send-invisible))))))
+            ;; Use `run-at-time' in order not to pause execution of
+            ;; the process filter with a minibuffer
+           (run-at-time
+             0 nil
+             (lambda (current-buf)
+               (with-current-buffer current-buf
+                 (eshell-send-invisible)))
+             (current-buffer)))))))
 
 (custom-add-option 'eshell-output-filter-functions
                   'eshell-watch-for-password-prompt)
index dd5457745bdcfb0a1d8f600cd0527965ab112d8f..530b93484edae84ccbcdced9f5f7972f067f0bd0 100644 (file)
@@ -2409,7 +2409,14 @@ Checks if STRING contains a password prompt as defined by
   (when (term-in-line-mode)
     (when (let ((case-fold-search t))
             (string-match comint-password-prompt-regexp string))
-      (term-send-invisible (read-passwd string)))))
+      ;; Use `run-at-time' in order not to pause execution of the
+      ;; process filter with a minibuffer
+      (run-at-time
+       0 nil
+       (lambda (current-buf)
+         (with-current-buffer current-buf
+           (term-send-invisible (read-passwd string))))
+       (current-buffer)))))
 
 \f
 ;;; Low-level process communication