unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gabriel <gabriel376@hotmail.com>
To: 50176@debbugs.gnu.org
Subject: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
Date: Tue, 24 Aug 2021 11:31:30 -0300	[thread overview]
Message-ID: <CH2PR01MB5879FA82880FF659063686E98BC59@CH2PR01MB5879.prod.exchangelabs.com> (raw)
In-Reply-To: <87o89nxrxf.fsf@mail.linkov.net> (Juri Linkov's message of "Tue,  24 Aug 2021 09:44:44 +0300")

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

Juri Linkov <juri@linkov.net> writes:

>
> Thanks for the patch.  This is a known problem without a good solution.
> But your patch handles the case much better than before, so pushed now.

Thank you, Juri

Perhaps we could store in a defvar the last message echoed by
repeat-mode to make easier this check?

Today I caught a small problem with the patch I sent. The
'string-prefix-p' and 'string-match-p' handle nil inputs differently:

(string-prefix-p "Repeat with " nil) ;; returns nil
(string-match-p "Repeat with " nil)  ;; throws an error

The problem can be reproduced by writing some elisp code in *scratch*
buffer, putting the cursor in the function definition and invoking the
'other-window' with 'repeat-mode' using my original steps. The
'eldoc-mode' will echo the function name and '(current-message)' will
return nil.

A simple patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-nil-messages-in-repeat-echo-message.patch --]
[-- Type: text/x-patch, Size: 1007 bytes --]

From 4e67546e2a9a878418d9dd766d234699fd58da34 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Tue, 24 Aug 2021 11:23:49 -0300
Subject: [PATCH] Handle nil messages in repeat-echo-message.

* lisp/repeat.el (repeat-echo-message): Handle cases where
'current-message' is nil (bug#50176).
---
 lisp/repeat.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/repeat.el b/lisp/repeat.el
index e3e7a7568e..3b30ba2a60 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -474,8 +474,9 @@ repeat-echo-message
         (if (current-message)
             (message "%s [%s]" (current-message) mess)
           (message mess)))
-    (when (string-match-p "Repeat with " (or (current-message) ""))
-      (message nil))))
+    (and (current-message)
+         (string-match-p "Repeat with " (current-message))
+         (message nil))))
 
 (defvar repeat-echo-mode-line-string
   (propertize "[Repeating...] " 'face 'mode-line-emphasis)
-- 
2.32.0


[-- Attachment #3: Type: text/plain, Size: 137 bytes --]


(The call to '(current-message)' does not seem to be expensive;
otherwise, we could store it into a variable to avoid duplicated calls)

  reply	other threads:[~2021-08-24 14:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 22:25 bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout Gabriel
2021-08-24  6:44 ` Juri Linkov
2021-08-24 14:31   ` Gabriel [this message]
2021-08-24 18:20     ` Juri Linkov
2021-08-25 17:11     ` Juri Linkov
     [not found] <FB0B8735-EB16-44C4-8D9A-E0141DF4A552@acm.org>
2021-08-25 17:06 ` Juri Linkov

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=CH2PR01MB5879FA82880FF659063686E98BC59@CH2PR01MB5879.prod.exchangelabs.com \
    --to=gabriel376@hotmail.com \
    --cc=50176@debbugs.gnu.org \
    /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).