From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael.albinus@gmx.de, emacs-devel@gnu.org
Subject: Re: master 39e3fce0d5e0: 'read-passwd' can toggle the visibility of passwords
Date: Fri, 15 Mar 2024 13:55:34 -0400 [thread overview]
Message-ID: <jwvil1nfksn.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <864jd78r80.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 15 Mar 2024 17:11:43 +0200")
> No, it makes things worse:
>
> In read-passwd-mode:
> simple.el:10907:16: Warning: reference to free variable `read-passwd--show-password-icon'
> simple.el:10912:12: Warning: reference to free variable `mode-line-faces'
> simple.el:10915:4: Error: `define-icon' defined after use in (define-icon
> read-passwd--hide-password-icon nil '((image "conceal.svg"
> "conceal.pbm" :height (0.8 . em)) (symbol " ") (text "<\\>")) "Mode line
> icon to hide a visible password." :group mode-line-faces :version
> "30.1" :help-echo "mouse-1: Toggle password visibility") (missing `require'
> of a library file?)
> simple.el:10915:16: Warning: reference to free variable `read-passwd--hide-password-icon'
>
> In end of data:
> simple.el:10907:4: Warning: the function `define-icon' might not be defined at runtime.
> simple.el:10883:19: Warning: the function `icon-string' might not be defined at runtime.
> Makefile:289: recipe for target `../lisp/simple.elc' failed
Ah, right: the code as written only works if there's a warning earlier,
because it uses `define-icon` inside a function and that macro is
defined in `icons` and is not autoloaded, so the only reason it
currently works is that `display-warning` loads `icons`: as soon as we
fix the warning, the core problem shows up.
The hideous patch below should result in working code without warnings,
but I hope we can find a better solution (e.g. one that lets us move
the two `define-icon`s to the toplevel of some file rather than being
inside a function).
Stefan
diff --git a/lisp/simple.el b/lisp/simple.el
index 0645f18cc78..5ce3e27e99b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10873,6 +10873,9 @@ read-passwd-toggle-visibility
"Toggle minibuffer contents visibility.
Adapt also mode line."
(interactive)
+ (require 'icons) ;; Should usually be loaded already.
+ (defvar icon-preference)
+ (declare-function icon-string "icons" (name))
(setq read-passwd--hide-password (not read-passwd--hide-password))
(with-current-buffer read-passwd--mode-line-buffer
(setq read-passwd--mode-line-icon
@@ -10902,22 +10905,25 @@ read-passwd-mode
;; no corresponding Unicode char with a slash. So we use symbols as
;; fallback only, with "⦵" ("\N{CIRCLE WITH HORIZONTAL BAR}") for
;; hiding the password.
- (define-icon read-passwd--show-password-icon nil
- '((image "reveal.svg" "reveal.pbm" :height (0.8 . em))
- (symbol "👁")
- (text "<o>"))
- "Mode line icon to show a hidden password."
- :group mode-line-faces
- :version "30.1"
- :help-echo "mouse-1: Toggle password visibility")
- (define-icon read-passwd--hide-password-icon nil
- '((image "conceal.svg" "conceal.pbm" :height (0.8 . em))
- (symbol "⦵")
- (text "<\\>"))
- "Mode line icon to hide a visible password."
- :group mode-line-faces
- :version "30.1"
- :help-echo "mouse-1: Toggle password visibility")
+ (eval
+ '(progn
+ (define-icon read-passwd--show-password-icon nil
+ '((image "reveal.svg" "reveal.pbm" :height (0.8 . em))
+ (symbol "👁")
+ (text "<o>"))
+ "Mode line icon to show a hidden password."
+ :group mode-line-faces
+ :version "30.1"
+ :help-echo "mouse-1: Toggle password visibility")
+ (define-icon read-passwd--hide-password-icon nil
+ '((image "conceal.svg" "conceal.pbm" :height (0.8 . em))
+ (symbol "⦵")
+ (text "<\\>"))
+ "Mode line icon to hide a visible password."
+ :group mode-line-faces
+ :version "30.1"
+ :help-echo "mouse-1: Toggle password visibility"))
+ t)
(setq read-passwd--hide-password nil
;; Stolen from `eldoc-minibuffer-message'.
next prev parent reply other threads:[~2024-03-15 17:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 8:07 master 39e3fce0d5e0: 'read-passwd' can toggle the visibility of passwords Eli Zaretskii
2024-03-15 8:23 ` Michael Albinus
2024-03-15 8:55 ` Eli Zaretskii
2024-03-15 11:55 ` Andreas Schwab
2024-03-15 12:19 ` Michael Albinus
2024-03-15 12:47 ` Andreas Schwab
2024-03-15 12:52 ` Eli Zaretskii
2024-03-15 18:20 ` Michael Albinus
2024-03-15 18:25 ` Stefan Monnier
2024-03-15 13:29 ` Stefan Monnier
2024-03-15 15:11 ` Eli Zaretskii
2024-03-15 17:55 ` Stefan Monnier [this message]
2024-03-15 18:23 ` Michael Albinus
2024-03-22 17:43 ` Michael Albinus
2024-04-04 15:24 ` Michael Albinus
2024-03-15 18:37 ` 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=jwvil1nfksn.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=michael.albinus@gmx.de \
/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).