unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 73768@debbugs.gnu.org
Subject: bug#73768: 'read-passwd-mode' can clobber user defined mode lines
Date: Mon, 14 Oct 2024 16:56:29 +0200	[thread overview]
Message-ID: <49fca25a-d5aa-4f14-ae09-52923eb5ce85@gmx.at> (raw)
In-Reply-To: <877cacvv0r.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 2487 bytes --]

 > Thanks! With this recipe, I can reproduce the problem. And your patch
 > fixes it :-)
 >
 > Please install in the emacs-30 branch.

Hold your horses.  First try another recipe: With emacs -Q do C-x 5 2
followed by C-x b to show *Messages* in either of the frames, read a
password, do C-x 5 o and type C-g.  One of the two buffers has the eye
icon the other has the botched mode line.  I'm using the more accurate
patch attached now to hopefully fix that too.  Note that whenever one
switches frames, the mode line showing the eye will always stay with the
initially chosen buffer and not the one where the minibuffer window is.

But there are other scenarios that don't seem right.  While reading one
password ask for reading another one.  You now should see two eye icons
which, however, cannot be attributed to any of the two read operations.
Clicking on either of them will toggle visibility of the password.  If
you don't want to show the password for the first operation but you do
want to show it for the second operation, then when the second operation
terminates you will see the password for the first one.  Same for typing
TAB in the minibuffer.  Resetting 'read-passwd--hide-password' when
terminating any read password operation might fix that.

Likely password visibility should be a property of the specific reading
process (aka as buffer-local value of 'read-passwd--hide-password') and
not something global.  But then we would also have to change the first
icon of the mode line too and doing that is more tricky.  Currently, all
eye icons are the same because 'read-passwd--mode-line-icon' has the
same value for them.

Probably it might be better to have only one eye icon on any mode line
informing about the visibility of the innermost minibuffer's password
status.  But this becomes tricky when terminating a password operation
because we would have to internally (on the C-level) scan all
minibuffers to find out whether there's another password operation in
progress and remove the eye icon only if there's none.

Otherwise we could try giving only the first eye icon the dynamic eval
property and have all other icons statically have the hide password
property.  Less tricky - we'd only have to hide a password when asking
for another one.

Obviously, we could also inhibit asking for a second password.  But I
suppose this was always possible and would imply an incompatible change.

If anyone has a good idea what to do here, please speak up.

Thanks, martin

[-- Attachment #2: read-passwd.diff --]
[-- Type: text/x-patch, Size: 1857 bytes --]

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 90b58f560c0..f71393721cb 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -2474,7 +2474,7 @@ read-passwd--mode-line-icon
   "Propertized mode line icon for showing/hiding passwords.")
 
 (defvar read-passwd--hide-password t
-  "Toggle whether password should be hidden in minubuffer.")
+  "Toggle whether password should be hidden in minibuffer.")
 
 (defun read-passwd--hide-password ()
   "Make password in minibuffer hidden or visible."
@@ -2534,13 +2534,14 @@ read-passwd-mode
   :keymap read-passwd-map
   :version "30.1"
 
-  (setq read-passwd--hide-password nil
-        ;; Stolen from `eldoc-minibuffer-message'.
-        read-passwd--mode-line-buffer
-        (window-buffer
-         (or (window-in-direction 'above (minibuffer-window))
-	     (minibuffer-selected-window)
-	     (get-largest-window))))
+  (setq read-passwd--hide-password nil)
+  ;; Stolen from `eldoc-minibuffer-message'.
+  (unless (buffer-live-p read-passwd--mode-line-buffer)
+    (setq read-passwd--mode-line-buffer
+          (window-buffer
+           (or (window-in-direction 'above (minibuffer-window))
+	       (minibuffer-selected-window)
+	       (get-largest-window)))))
 
   (if read-passwd-mode
       (with-current-buffer read-passwd--mode-line-buffer
@@ -2551,8 +2552,10 @@ read-passwd-mode
 	              mode-line-format))))
     (with-current-buffer read-passwd--mode-line-buffer
       ;; Remove `read-passwd--mode-line-icon'.
-      (when (listp mode-line-format)
-        (setq mode-line-format (cdr mode-line-format)))))
+      (when (equal (car mode-line-format)
+		   '(:eval read-passwd--mode-line-icon))
+        (setq mode-line-format (cdr mode-line-format))))
+    (setq read-passwd--mode-line-buffer nil))
 
   (when read-passwd-mode
     (read-passwd-toggle-visibility)))

  reply	other threads:[~2024-10-14 14:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12  9:26 bug#73768: 'read-passwd-mode' can clobber user defined mode lines martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 10:36 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 13:56   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13 13:49     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13  9:58   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13 14:19     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13 15:09       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13 16:15         ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-14 14:56           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-10-13 15:21       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49fca25a-d5aa-4f14-ae09-52923eb5ce85@gmx.at \
    --to=bug-gnu-emacs@gnu.org \
    --cc=73768@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).