diff options
| author | Michael R. Mauger | 2019-12-22 23:56:05 -0500 |
|---|---|---|
| committer | Michael R. Mauger | 2019-12-22 23:56:05 -0500 |
| commit | 3df7d06d4187d402e4df1177461862af638d96de (patch) | |
| tree | ceb522ae690fec95a1ee7118293cd93edd460479 /lisp | |
| parent | eea05713bef7b86ff84ca843948f944e4c856119 (diff) | |
| download | emacs-3df7d06d4187d402e4df1177461862af638d96de.tar.gz emacs-3df7d06d4187d402e4df1177461862af638d96de.zip | |
Added `comint-password-function' hook
* etc/NEWS:
* lisp/comint.el (comint-password-function): New variable.
(comint-send-invisible): Use it.
* test/lisp/comint-tests.el (comint-test-no-password-function,
comint-test-password-function-with-value,
comint-test-password-function-with-nil): Test new variable.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/comint.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 4bb43670354..c06a63fbd24 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -2356,6 +2356,13 @@ a buffer local variable." | |||
| 2356 | ;; saved -- typically passwords to ftp, telnet, or somesuch. | 2356 | ;; saved -- typically passwords to ftp, telnet, or somesuch. |
| 2357 | ;; Just enter m-x comint-send-invisible and type in your line. | 2357 | ;; Just enter m-x comint-send-invisible and type in your line. |
| 2358 | 2358 | ||
| 2359 | (defvar comint-password-function nil | ||
| 2360 | "Abnormal hook run when prompted for a password. | ||
| 2361 | This function gets one argument, a string containing the prompt. | ||
| 2362 | It may return a string containing the password, or nil if normal | ||
| 2363 | password prompting should occur.") | ||
| 2364 | (make-variable-buffer-local 'comint-password-function) | ||
| 2365 | |||
| 2359 | (defun comint-send-invisible (&optional prompt) | 2366 | (defun comint-send-invisible (&optional prompt) |
| 2360 | "Read a string without echoing. | 2367 | "Read a string without echoing. |
| 2361 | Then send it to the process running in the current buffer. | 2368 | Then send it to the process running in the current buffer. |
| @@ -2370,8 +2377,13 @@ Security bug: your string can still be temporarily recovered with | |||
| 2370 | (format "(In buffer %s) " | 2377 | (format "(In buffer %s) " |
| 2371 | (current-buffer))))) | 2378 | (current-buffer))))) |
| 2372 | (if proc | 2379 | (if proc |
| 2373 | (let ((str (read-passwd (concat prefix | 2380 | (let ((prefix-prompt (concat prefix |
| 2374 | (or prompt "Non-echoed text: "))))) | 2381 | (or prompt "Non-echoed text: "))) |
| 2382 | str) | ||
| 2383 | (when comint-password-function | ||
| 2384 | (setq str (funcall comint-password-function prefix-prompt))) | ||
| 2385 | (unless str | ||
| 2386 | (setq str (read-passwd prefix-prompt))) | ||
| 2375 | (if (stringp str) | 2387 | (if (stringp str) |
| 2376 | (progn | 2388 | (progn |
| 2377 | (comint-snapshot-last-prompt) | 2389 | (comint-snapshot-last-prompt) |