*** .authinfo and .netrc files now use a new mode: 'authinfo-mode'.
This is just like 'fundamental-mode', except that it hides passwords
under a "****" display property. When the cursor moves to this text,
-the real password is revealed (via 'reveal-mode').
+the real password is revealed (via 'reveal-mode'). The
+'authinfo-hidden' variable can be used to control what to hide.
** Tramp
;;; Tiny mode for editing .netrc/.authinfo modes (that basically just
;;; hides passwords).
+(defcustom authinfo-hidden "password"
+ "Regexp matching elements in .authinfo/.netrc files that should be hidden."
+ :type 'regexp
+ :version "27.1")
+
;;;###autoload
(define-derived-mode authinfo-mode fundamental-mode "Authinfo"
"Mode for editing .authinfo/.netrc files.
(save-restriction
(narrow-to-region start end)
(goto-char start)
- (while (re-search-forward "\\(\\s-\\|^\\)password\\s-+\\([^\n\t ]+\\)"
+ (while (re-search-forward (format "\\(\\s-\\|^\\)\\(%s\\)\\s-+"
+ authinfo-hidden)
nil t)
- (let ((overlay (make-overlay (match-beginning 2) (match-end 2))))
- (overlay-put overlay 'display (propertize "****"
- 'face 'warning))
- (overlay-put overlay 'reveal-toggle-invisible
- #'authinfo--toggle-display))))))
+ (when (looking-at "[^\n\t ]+")
+ (let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
+ (overlay-put overlay 'display (propertize "****"
+ 'face 'warning))
+ (overlay-put overlay 'reveal-toggle-invisible
+ #'authinfo--toggle-display)))))))
(defun authinfo--toggle-display (overlay hide)
(if hide