diff options
| author | Lars Ingebrigtsen | 2019-09-23 12:27:42 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-09-23 12:27:42 +0200 |
| commit | 87b685f4365f663ef1258cd60616034cd2cc89c9 (patch) | |
| tree | 01188c37f996df8688ca4a8e17c379756e1ac523 /lisp/auth-source.el | |
| parent | 0f45f383b9e66e90f092a6095b2f0faa19e55af3 (diff) | |
| download | emacs-87b685f4365f663ef1258cd60616034cd2cc89c9.tar.gz emacs-87b685f4365f663ef1258cd60616034cd2cc89c9.zip | |
Add an `authinfo-hidden' variable
* lisp/auth-source.el (authinfo-hidden): New variable.
(authinfo--hide-passwords): Use it to allow users to decide what
to hide.
Diffstat (limited to 'lisp/auth-source.el')
| -rw-r--r-- | lisp/auth-source.el | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 6d53a222e98..9061d41556f 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el | |||
| @@ -2400,6 +2400,11 @@ MODE can be \"login\" or \"password\"." | |||
| 2400 | ;;; Tiny mode for editing .netrc/.authinfo modes (that basically just | 2400 | ;;; Tiny mode for editing .netrc/.authinfo modes (that basically just |
| 2401 | ;;; hides passwords). | 2401 | ;;; hides passwords). |
| 2402 | 2402 | ||
| 2403 | (defcustom authinfo-hidden "password" | ||
| 2404 | "Regexp matching elements in .authinfo/.netrc files that should be hidden." | ||
| 2405 | :type 'regexp | ||
| 2406 | :version "27.1") | ||
| 2407 | |||
| 2403 | ;;;###autoload | 2408 | ;;;###autoload |
| 2404 | (define-derived-mode authinfo-mode fundamental-mode "Authinfo" | 2409 | (define-derived-mode authinfo-mode fundamental-mode "Authinfo" |
| 2405 | "Mode for editing .authinfo/.netrc files. | 2410 | "Mode for editing .authinfo/.netrc files. |
| @@ -2416,13 +2421,15 @@ passwords are revealed when point moved into the password. | |||
| 2416 | (save-restriction | 2421 | (save-restriction |
| 2417 | (narrow-to-region start end) | 2422 | (narrow-to-region start end) |
| 2418 | (goto-char start) | 2423 | (goto-char start) |
| 2419 | (while (re-search-forward "\\(\\s-\\|^\\)password\\s-+\\([^\n\t ]+\\)" | 2424 | (while (re-search-forward (format "\\(\\s-\\|^\\)\\(%s\\)\\s-+" |
| 2425 | authinfo-hidden) | ||
| 2420 | nil t) | 2426 | nil t) |
| 2421 | (let ((overlay (make-overlay (match-beginning 2) (match-end 2)))) | 2427 | (when (looking-at "[^\n\t ]+") |
| 2422 | (overlay-put overlay 'display (propertize "****" | 2428 | (let ((overlay (make-overlay (match-beginning 0) (match-end 0)))) |
| 2423 | 'face 'warning)) | 2429 | (overlay-put overlay 'display (propertize "****" |
| 2424 | (overlay-put overlay 'reveal-toggle-invisible | 2430 | 'face 'warning)) |
| 2425 | #'authinfo--toggle-display)))))) | 2431 | (overlay-put overlay 'reveal-toggle-invisible |
| 2432 | #'authinfo--toggle-display))))))) | ||
| 2426 | 2433 | ||
| 2427 | (defun authinfo--toggle-display (overlay hide) | 2434 | (defun authinfo--toggle-display (overlay hide) |
| 2428 | (if hide | 2435 | (if hide |