unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73986: 31.0.50; Allow suppressing message passed to set-transient-map
@ 2024-10-24 14:06 Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-24 17:12 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-24 14:06 UTC (permalink / raw)
  To: 73986

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

If a caller of set-transient-map passes a suitable format string, this
is displayed as a message on activating the transient map.  An example
is text-scale-adjust, which displays the message "Use +, =, -, 0, C-+,
C-=, C--, C-0 for further adjustment".  So if after typing `C-x C-+' you
immediately type `+ + + - - -', the text size increases three times and
then decreases three times.  But on each key press the message is
redisplayed, which is slighty annoying (it actually looks like it stays
in the echo area but there is a brief flicker on each key press); the
message is helpful the first time, if you're unfamiliar with the
command, but on repeated uses, it becomes visual noise.  So I propose a
user option to suppress the message, as in the attached patch.

One thing I'm not sure about is whether the call to `message' in the
local function `clearfun' of set-transient-map, which is added to
pre-command-hook, should also be conditioned on the proposed user
option; I tested both with and without such conditioning and saw no
difference, so the patch omits it.  But I admit I don't see what the
purpose of clearfun is, so maybe it should be so conditioned.

If the patch (or a corrected version of it) is accepted, I will also
update the elisp manual and NEWS accordingly.

(An alternative to the above proposal is suppressing the message after
displaying it once (or perhaps n times, though that seems extravagant).
Or allowing both alternatives (or all three) as values of the user
option.  I prefer the simpler display-or-suppress proposal, but can
implement an alternative if desired.)


In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2024-10-21 built on strobelfssd
Repository revision: b3af195213518514f78ac6f66f9598e45befd1ec
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Linux From Scratch r12.2-17-systemd

Configured using:
 'configure -C 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt6/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: set-transient-map patch --]
[-- Type: text/x-patch, Size: 2069 bytes --]

diff --git a/lisp/subr.el b/lisp/subr.el
index 4771ac1fba2..6716c975318 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6549,6 +6549,13 @@ set-transient-map-timeout
 (defvar set-transient-map-timer nil
   "Timer for `set-transient-map-timeout'.")

+(defcustom set-transient-map-suppress-message nil
+  "Whether to suppress a message on activating the transient map.
+If non-nil, do not display a message passed to `set-transient-map'."
+  :group 'convenience
+  :type 'boolean
+  :version "31.1")
+
 (defun set-transient-map (map &optional keep-pred on-exit message timeout)
   "Set MAP as a temporary keymap taking precedence over other keymaps.
 Normally, MAP is used only once, to look up the very next key.
@@ -6561,10 +6568,11 @@ set-transient-map
 called, with no arguments, after MAP is deactivated.

 Optional arg MESSAGE, if non-nil, requests display of an informative
-message after activating the transient map.  If MESSAGE is a string,
-it specifies the format string for the message to display, and the %k
-specifier in the string is replaced with the list of keys from the
-transient map.  Any other non-nil value of MESSAGE means to use the
+message after activating the transient map, unless the user option
+`set-transient-map-suppress-message' is also non-nil.  If MESSAGE is a
+string, it specifies the format string for the message to display, and
+the %k specifier in the string is replaced with the list of keys from
+the transient map.  Any other non-nil value of MESSAGE means to use the
 message format string \"Repeat with %k\".  Upon deactivating the map,
 the displayed message will be cleared out.

@@ -6638,7 +6646,8 @@ set-transient-map
     (when timeout
       (when set-transient-map-timer (cancel-timer set-transient-map-timer))
       (setq set-transient-map-timer (run-with-idle-timer timeout nil exitfun)))
-    (when message (message "%s" message))
+    (unless set-transient-map-suppress-message
+      (when message (message "%s" message)))
     exitfun))

 ;;;; Progress reporters.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#73986: 31.0.50; Allow suppressing message passed to set-transient-map
  2024-10-24 14:06 bug#73986: 31.0.50; Allow suppressing message passed to set-transient-map Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-24 17:12 ` Juri Linkov
  2024-10-24 18:12   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2024-10-24 17:12 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 73986

> If a caller of set-transient-map passes a suitable format string, this
> is displayed as a message on activating the transient map.  An example
> is text-scale-adjust, which displays the message "Use +, =, -, 0, C-+,
> C-=, C--, C-0 for further adjustment".  So if after typing `C-x C-+' you
> immediately type `+ + + - - -', the text size increases three times and
> then decreases three times.  But on each key press the message is
> redisplayed, which is slighty annoying (it actually looks like it stays
> in the echo area but there is a brief flicker on each key press); the
> message is helpful the first time, if you're unfamiliar with the
> command, but on repeated uses, it becomes visual noise.  So I propose a
> user option to suppress the message, as in the attached patch.

Instead of adding a myriad of user options for every command
that displays a message, we decided to create a single point
of customization, so you could just set these options:

  (add-to-list 'set-message-functions 'inhibit-message)
  (add-to-list 'inhibit-message-regexps "for further adjustment")





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73986: 31.0.50; Allow suppressing message passed to set-transient-map
  2024-10-24 17:12 ` Juri Linkov
@ 2024-10-24 18:12   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-24 18:12 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 73986

On Thu, 24 Oct 2024 20:12:20 +0300 Juri Linkov <juri@linkov.net> wrote:

>> If a caller of set-transient-map passes a suitable format string, this
>> is displayed as a message on activating the transient map.  An example
>> is text-scale-adjust, which displays the message "Use +, =, -, 0, C-+,
>> C-=, C--, C-0 for further adjustment".  So if after typing `C-x C-+' you
>> immediately type `+ + + - - -', the text size increases three times and
>> then decreases three times.  But on each key press the message is
>> redisplayed, which is slighty annoying (it actually looks like it stays
>> in the echo area but there is a brief flicker on each key press); the
>> message is helpful the first time, if you're unfamiliar with the
>> command, but on repeated uses, it becomes visual noise.  So I propose a
>> user option to suppress the message, as in the attached patch.
>
> Instead of adding a myriad of user options for every command
> that displays a message, we decided to create a single point
> of customization, so you could just set these options:
>
>   (add-to-list 'set-message-functions 'inhibit-message)
>   (add-to-list 'inhibit-message-regexps "for further adjustment")

Ah, thanks, I now vaguely recall seeing these but forgot about them.
They indeed do work just as well as my proposed change to
set-transient-map for text-scale-adjust as well as two private functions
I use that pass a message string matching the same regexp, so that
satisfies my immediate wish.  Still, there could be any number of
callers of set-transient-map that pass message strings users may want to
suppress but that require a different regexp, in which case the burden
on the user is more than with my patch.  But since that's AFAIK
currently only a theoretical possibility, I won't pursue the proposal.
I'll wait a few days in case someone does chime in favor of my patch,
but otherwise I'll then close the bug.

Steve Berman





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-24 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 14:06 bug#73986: 31.0.50; Allow suppressing message passed to set-transient-map Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-24 17:12 ` Juri Linkov
2024-10-24 18:12   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors

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).