aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2024-10-18 17:47:43 +0200
committerMichael Albinus2024-10-18 17:47:43 +0200
commit7dbbd58d6c9cafde2136b83ff149aa608203e207 (patch)
treef1f578f2f28212ae8c53b3ab97040b2e7e47f63a
parent19049efd30f5476baa4b69c4b79af15674c2650b (diff)
downloademacs-7dbbd58d6c9cafde2136b83ff149aa608203e207.tar.gz
emacs-7dbbd58d6c9cafde2136b83ff149aa608203e207.zip
Locate password icon in global-mode-string
* doc/emacs/mini.texi (Passwords): Precise the location of the password icon. * doc/lispref/minibuf.texi (Reading a Password): The password icon is added to global-mode-string. * lisp/auth-source.el (read-passwd--mode-line-buffer): Remove. (read-passwd--hide-password): Fix docstring. (read-passwd-toggle-visibility): Don't use `read-passwd--mode-line-buffer'. Check for `read-passwd-mode'. Force update in all mode lines. (read-passwd-mode): Set `read-passwd--mode-line-icon' in `global-mode-string'. (Bug#73768)
-rw-r--r--doc/emacs/mini.texi4
-rw-r--r--doc/lispref/minibuf.texi6
-rw-r--r--lisp/auth-source.el38
3 files changed, 19 insertions, 29 deletions
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 3be9b76ad88..b1361695211 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -975,8 +975,8 @@ password. You may type either @key{RET} or @key{ESC} to submit the
975password. Any other self-inserting character key inserts the associated 975password. Any other self-inserting character key inserts the associated
976character into the password, and all other input is ignored. 976character into the password, and all other input is ignored.
977 977
978 There is also an icon at the front of the mode line indicating the 978 There is also an icon in the mode line indicating the password
979password visibility. Clicking @kbd{mouse-1} on it toggles the password 979visibility. Clicking @kbd{mouse-1} on it toggles the password
980visibility as well. 980visibility as well.
981 981
982@node Yes or No Prompts 982@node Yes or No Prompts
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index f0b7fef30c7..c5b9176d628 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -2562,9 +2562,9 @@ This function uses @code{read-passwd-mode}, a minor mode. It binds two
2562keys in the minbuffer: @kbd{C-u} (@code{delete-minibuffer-contents}) 2562keys in the minbuffer: @kbd{C-u} (@code{delete-minibuffer-contents})
2563deletes the password, and @kbd{TAB} 2563deletes the password, and @kbd{TAB}
2564(@code{read-passwd--toggle-visibility}) toggles the visibility of the 2564(@code{read-passwd--toggle-visibility}) toggles the visibility of the
2565password. There is also an additional icon in the mode-line. Clicking 2565password. There is also an additional icon in the mode-line's
2566on this icon with @key{mouse-1} toggles the visibility of the password 2566@code{global-mode-string}. Clicking on this icon with @key{mouse-1}
2567as well. 2567toggles the visibility of the password as well.
2568@end defun 2568@end defun
2569 2569
2570@node Minibuffer Commands 2570@node Minibuffer Commands
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 90b58f560c0..557d360bc6a 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -2467,14 +2467,11 @@ point is moved into the passwords (see `authinfo-hide-elements').
2467 :version "30.1" 2467 :version "30.1"
2468 :help-echo "mouse-1: Toggle password visibility") 2468 :help-echo "mouse-1: Toggle password visibility")
2469 2469
2470(defvar read-passwd--mode-line-buffer nil
2471 "Buffer to modify `mode-line-format' for showing/hiding passwords.")
2472
2473(defvar read-passwd--mode-line-icon nil 2470(defvar read-passwd--mode-line-icon nil
2474 "Propertized mode line icon for showing/hiding passwords.") 2471 "Propertized mode line icon for showing/hiding passwords.")
2475 2472
2476(defvar read-passwd--hide-password t 2473(defvar read-passwd--hide-password t
2477 "Toggle whether password should be hidden in minubuffer.") 2474 "Toggle whether password should be hidden in minibuffer.")
2478 2475
2479(defun read-passwd--hide-password () 2476(defun read-passwd--hide-password ()
2480 "Make password in minibuffer hidden or visible." 2477 "Make password in minibuffer hidden or visible."
@@ -2497,8 +2494,8 @@ Adapt also mode line."
2497 ;; FIXME: In case of a recursive minibuffer, this may select the wrong 2494 ;; FIXME: In case of a recursive minibuffer, this may select the wrong
2498 ;; mini-buffer. 2495 ;; mini-buffer.
2499 (with-current-buffer (window-buffer win) 2496 (with-current-buffer (window-buffer win)
2500 (setq read-passwd--hide-password (not read-passwd--hide-password)) 2497 (when (memq 'read-passwd-mode local-minor-modes)
2501 (with-current-buffer read-passwd--mode-line-buffer 2498 (setq read-passwd--hide-password (not read-passwd--hide-password))
2502 (setq read-passwd--mode-line-icon 2499 (setq read-passwd--mode-line-icon
2503 `(:propertize 2500 `(:propertize
2504 ,(if icon-preference 2501 ,(if icon-preference
@@ -2514,8 +2511,8 @@ Adapt also mode line."
2514 (define-key map [mode-line mouse-1] 2511 (define-key map [mode-line mouse-1]
2515 #'read-passwd-toggle-visibility) 2512 #'read-passwd-toggle-visibility)
2516 map)))) 2513 map))))
2517 (force-mode-line-update)) 2514 (force-mode-line-update 'all)
2518 (read-passwd--hide-password)))) 2515 (read-passwd--hide-password)))))
2519 2516
2520(defvar read-passwd-map 2517(defvar read-passwd-map
2521 ;; BEWARE: `defconst' would purecopy it, breaking the sharing with 2518 ;; BEWARE: `defconst' would purecopy it, breaking the sharing with
@@ -2534,25 +2531,18 @@ Adapt also mode line."
2534 :keymap read-passwd-map 2531 :keymap read-passwd-map
2535 :version "30.1" 2532 :version "30.1"
2536 2533
2537 (setq read-passwd--hide-password nil 2534 (setq read-passwd--hide-password nil)
2538 ;; Stolen from `eldoc-minibuffer-message'. 2535 (or global-mode-string (setq global-mode-string '("")))
2539 read-passwd--mode-line-buffer
2540 (window-buffer
2541 (or (window-in-direction 'above (minibuffer-window))
2542 (minibuffer-selected-window)
2543 (get-largest-window))))
2544 2536
2545 (if read-passwd-mode 2537 (let ((mode-string '(:eval read-passwd--mode-line-icon)))
2546 (with-current-buffer read-passwd--mode-line-buffer 2538 (if read-passwd-mode
2547 ;; Add `read-passwd--mode-line-icon'. 2539 ;; Add `read-passwd--mode-line-icon'.
2548 (when (listp mode-line-format) 2540 (or (member mode-string global-mode-string)
2549 (setq mode-line-format 2541 (setq global-mode-string
2550 (cons '(:eval read-passwd--mode-line-icon) 2542 (append global-mode-string (list mode-string))))
2551 mode-line-format))))
2552 (with-current-buffer read-passwd--mode-line-buffer
2553 ;; Remove `read-passwd--mode-line-icon'. 2543 ;; Remove `read-passwd--mode-line-icon'.
2554 (when (listp mode-line-format) 2544 (setq global-mode-string
2555 (setq mode-line-format (cdr mode-line-format))))) 2545 (delete mode-string global-mode-string))))
2556 2546
2557 (when read-passwd-mode 2547 (when read-passwd-mode
2558 (read-passwd-toggle-visibility))) 2548 (read-passwd-toggle-visibility)))