1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Simplify comint-watch-for-password-prompt

* lisp/comint.el (comint-watch-for-password-prompt): Simplify by
using `string-trim'.
This commit is contained in:
Lars Ingebrigtsen 2021-02-22 15:47:30 +01:00
parent c1712f5507
commit 0c170c64b1

View file

@ -104,6 +104,7 @@
(require 'ring)
(require 'ansi-color)
(require 'regexp-opt) ;For regexp-opt-charset.
(eval-when-compile (require 'subr-x))
;; 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+"))))))
;; Low-level process communication