[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3be0dc6: authinfo-mode: add option to not hide any elements (and
From: |
Lars Ingebrigtsen |
Subject: |
master 3be0dc6: authinfo-mode: add option to not hide any elements (and add font-lock) |
Date: |
Wed, 23 Dec 2020 16:34:50 -0500 (EST) |
branch: master
commit 3be0dc659fd1a5bc976a545c0bdeda9a3d39e084
Author: TEC <tec@tecosaur.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
authinfo-mode: add option to not hide any elements (and add font-lock)
* lisp/auth-source.el (authinfo-hide-elements): New user option.
(authinfo--keywords): New variable.
(authinfo-mode): Use it.
(authinfo--hide-passwords): Use doc-face instead of warning for
the passwords.
(authinfo--toggle-display): Ditto.
---
etc/NEWS | 4 ++++
lisp/auth-source.el | 45 +++++++++++++++++++++++++++++++++++++--------
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index bbd372c..b155ff9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1460,6 +1460,10 @@ that makes it a valid button.
** Miscellaneous
+---
+*** New user option 'authinfo-hide-elements'.
+This can be set to nil to inhibit hiding passwords in .authinfo files.
+
+++
*** A number of new string manipulation functions have been added.
'string-clean-whitespace', 'string-fill', 'string-limit',
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 50795ce..27cf94d 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -2408,23 +2408,51 @@ MODE can be \"login\" or \"password\"."
(list user password auth-info)))
;;; Tiny mode for editing .netrc/.authinfo modes (that basically just
-;;; hides passwords).
+;;; hides passwords and adds basic syntax highlighting).
(defcustom authinfo-hidden "password"
"Regexp matching elements in .authinfo/.netrc files that should be hidden."
:type 'regexp
:version "27.1")
+(defcustom authinfo-hide-elements t
+ "Whether to use `authinfo-hidden' to hide elements in authinfo files."
+ :type 'boolean
+ :version "28.1")
+
+(defvar authinfo--keywords
+ '(("^#.*" . font-lock-comment-face)
+ ("^\\(machine\\)[ \t]+\\([^ \t\n]+\\)"
+ (1 font-lock-variable-name-face)
+ (2 font-lock-builtin-face))
+ ("\\(login\\)[ \t]+\\([^ \t\n]+\\)"
+ (1 font-lock-comment-delimiter-face)
+ (2 font-lock-keyword-face))
+ ("\\(password\\)[ \t]+\\([^ \t\n]+\\)"
+ (1 font-lock-comment-delimiter-face)
+ (2 font-lock-doc-face))
+ ("\\(port\\)[ \t]+\\([^ \t\n]+\\)"
+ (1 font-lock-comment-delimiter-face)
+ (2 font-lock-type-face))
+ ("\\([^ \t\n]+\\)[, \t]+\\([^ \t\n]+\\)"
+ (1 font-lock-constant-face)
+ (2 nil))))
+
;;;###autoload
(define-derived-mode authinfo-mode fundamental-mode "Authinfo"
"Mode for editing .authinfo/.netrc files.
-This is just like `fundamental-mode', but hides passwords. The
-passwords are revealed when point moved into the password.
+This is just like `fundamental-mode', but has basic syntax
+highlighting and hides passwords. Passwords are revealed when
+point is moved into the passwords (see `authinfo-hide-elements').
\\{authinfo-mode-map}"
- (authinfo--hide-passwords (point-min) (point-max))
- (reveal-mode))
+ (font-lock-add-keywords nil authinfo--keywords)
+ (setq-local comment-start "#")
+ (setq-local comment-end "")
+ (when authinfo-hide-elements
+ (authinfo--hide-passwords (point-min) (point-max))
+ (reveal-mode)))
(defun authinfo--hide-passwords (start end)
(save-excursion
@@ -2436,14 +2464,15 @@ passwords are revealed when point moved into the
password.
nil t)
(when (auth-source-netrc-looking-at-token)
(let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
- (overlay-put overlay 'display (propertize "****"
- 'face 'warning))
+ (overlay-put overlay 'display
+ (propertize "****" 'face 'font-lock-doc-face))
(overlay-put overlay 'reveal-toggle-invisible
#'authinfo--toggle-display)))))))
(defun authinfo--toggle-display (overlay hide)
(if hide
- (overlay-put overlay 'display (propertize "****" 'face 'warning))
+ (overlay-put overlay 'display
+ (propertize "****" 'face 'font-lock-doc-face))
(overlay-put overlay 'display nil)))
(provide 'auth-source)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3be0dc6: authinfo-mode: add option to not hide any elements (and add font-lock),
Lars Ingebrigtsen <=