aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/auth-source.el19
2 files changed, 15 insertions, 7 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 73f0ca2497b..e28bb2c0bd9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1497,7 +1497,8 @@ To recover the previous behavior, set new user option
1497*** .authinfo and .netrc files now use a new mode: 'authinfo-mode'. 1497*** .authinfo and .netrc files now use a new mode: 'authinfo-mode'.
1498This is just like 'fundamental-mode', except that it hides passwords 1498This is just like 'fundamental-mode', except that it hides passwords
1499under a "****" display property. When the cursor moves to this text, 1499under a "****" display property. When the cursor moves to this text,
1500the real password is revealed (via 'reveal-mode'). 1500the real password is revealed (via 'reveal-mode'). The
1501'authinfo-hidden' variable can be used to control what to hide.
1501 1502
1502** Tramp 1503** Tramp
1503 1504
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