]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify comint-watch-for-password-prompt
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2021 14:47:30 +0000 (15:47 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2021 14:47:30 +0000 (15:47 +0100)
* lisp/comint.el (comint-watch-for-password-prompt): Simplify by
using `string-trim'.

lisp/comint.el

index ea69c3b1f113efab0e60473ab303b3f342705efa..5c307febe2af65753cfebcfc4c28e6ae7b54c936 100644 (file)
 (require 'ring)
 (require 'ansi-color)
 (require 'regexp-opt)                   ;For regexp-opt-charset.
+(eval-when-compile (require 'subr-x))
 \f
 ;; Buffer Local Variables:
 ;;============================================================================
@@ -2430,14 +2431,11 @@ This function could be in the list `comint-output-filter-functions'."
   (when (let ((case-fold-search t))
          (string-match comint-password-prompt-regexp
                         (replace-regexp-in-string "\r" "" string)))
-    (when (string-match "^[ \n\r\t\v\f\b\a]+" string)
-      (setq string (replace-match "" t t string)))
-    (when (string-match "\n+\\'" string)
-      (setq string (replace-match "" t t 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)))))
+        (comint-send-invisible
+         (string-trim string "[ \n\r\t\v\f\b\a]+" "\n+"))))))
 \f
 ;; Low-level process communication