GNU bug report logs - #50176
[PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout

Previous Next

Package: emacs;

Reported by: Gabriel <gabriel376 <at> hotmail.com>

Date: Mon, 23 Aug 2021 22:31:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50176 in the body.
You can then email your comments to 50176 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Mon, 23 Aug 2021 22:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gabriel <gabriel376 <at> hotmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Aug 2021 22:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gabriel <gabriel376 <at> hotmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
Date: Mon, 23 Aug 2021 19:25:30 -0300
[Message part 1 (text/plain, inline)]
Description:
When repeat-mode is enabled and a repeat-exit-timeout is set, the
echo-area is not cleared in case the echo-area has some content and a
single repeat-command is executed.

Steps:
1) emacs -Q (from master branch)
2) eval
    (setq repeat-exit-timeout 1)
    (repeat-mode 1)
3) create some windows with 'C-x 2' and 'C-x 3'
4) 'C-x'
5) wait prefix "C-x" to appear on echo-area
6) 'o' (echo-area will now contain "C-x o [Repeat with o, O]")
7) wait a few seconds so 'repeat-exit-timeout' takes effect
Expected: the echo-area is cleared
Actual: the echo-area is not cleared

If 'o' is pressed again, it will run 'self-insert-command' even though
the echo-area is still showing "C-x o [Repeat with o, O]".

Now repeat steps 1-5 but press 'o' quickly to invoke the repeat command
multiple times (which will trigger other-window multiple times). The
echo-area changes to "Repeat o, O" and is properly cleaned after
'repeat-exit-timeout' seconds.

Patch:
I created a simple patch that seems to fix this probem. The
'string-prefix-p' was replaced with 'string-match-p' to handle cases
where echo-area contains some other message. This check seems very poor,
though, so any better approach is welcome.

[0001-Fix-to-clear-echo-area-after-repeat-exit-timeout.patch (text/x-patch, inline)]
From e6de15337bf4516740c0e790f6a2bfb3deaf9b5b Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376 <at> hotmail.com>
Date: Mon, 23 Aug 2021 19:05:58 -0300
Subject: [PATCH] Fix to clear echo-area after repeat-exit-timeout.

* lisp/repeat.el (repeat-echo-message): Use 'string-match-p'
to handle cases where echo-area contains other messages.
---
 lisp/repeat.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/repeat.el b/lisp/repeat.el
index cec3cb643a..054eacf8ec 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -474,7 +474,7 @@ repeat-echo-message
         (if (current-message)
             (message "%s [%s]" (current-message) mess)
           (message mess)))
-    (when (string-prefix-p "Repeat with " (current-message))
+    (when (string-match-p "Repeat with " (current-message))
       (message nil))))
 
 (defvar repeat-echo-mode-line-string
-- 
2.32.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Tue, 24 Aug 2021 06:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 50176 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gabriel <gabriel376 <at> hotmail.com>
Cc: 50176 <at> debbugs.gnu.org
Subject: Re: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear
 echo-area after timeout
Date: Tue, 24 Aug 2021 09:44:44 +0300
tags 50176 fixed
close 50176 28.0.50
thanks

> Patch:
> I created a simple patch that seems to fix this probem. The
> 'string-prefix-p' was replaced with 'string-match-p' to handle cases
> where echo-area contains some other message. This check seems very poor,
> though, so any better approach is welcome.

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.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 24 Aug 2021 06:49:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 50176 <at> debbugs.gnu.org and Gabriel <gabriel376 <at> hotmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 24 Aug 2021 06:49:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Tue, 24 Aug 2021 14:33:01 GMT) Full text and rfc822 format available.

Message #15 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gabriel <gabriel376 <at> hotmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear
 echo-area after timeout
Date: Tue, 24 Aug 2021 11:31:30 -0300
[Message part 1 (text/plain, inline)]
Juri Linkov <juri <at> 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:

[0001-Handle-nil-messages-in-repeat-echo-message.patch (text/x-patch, inline)]
From 4e67546e2a9a878418d9dd766d234699fd58da34 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376 <at> 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

[Message part 3 (text/plain, inline)]
(The call to '(current-message)' does not seem to be expensive;
otherwise, we could store it into a variable to avoid duplicated calls)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Tue, 24 Aug 2021 18:22:02 GMT) Full text and rfc822 format available.

Message #18 received at 50176 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gabriel <gabriel376 <at> hotmail.com>
Cc: 50176 <at> debbugs.gnu.org
Subject: Re: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear
 echo-area after timeout
Date: Tue, 24 Aug 2021 21:20:13 +0300
> 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.

Please look in the repo that Mattias already changed string-match-p
to string-search.  But (string-search "Repeat with " nil)
still throws an error.  I wonder why string-search is different
from string-prefix-p is its argument handling?
They both operate on the strings.

Also the name 'string-search' is too confusing since
it is too similar to 'search-forward' that searches
in the buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Wed, 25 Aug 2021 17:12:02 GMT) Full text and rfc822 format available.

Message #21 received at 50176 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Mattias EngdegÄrd <mattiase <at> acm.org>
Cc: 50176 <at> debbugs.gnu.org, Gabriel <gabriel376 <at> hotmail.com>
Subject: Re: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear
 echo-area after timeout
Date: Wed, 25 Aug 2021 20:06:07 +0300
>> Also the name 'string-search' is too confusing since it is too
>> similar to 'search-forward' that searches in the buffer.
>
> Well, maybe could give it the alias `is-substring-of` when used in a Boolean context...

Some languages use the name `include?`, other use the name `contains?`,
so actually I see no better name than the current `string-search`.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50176; Package emacs. (Wed, 25 Aug 2021 17:13:01 GMT) Full text and rfc822 format available.

Message #24 received at 50176 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gabriel <gabriel376 <at> hotmail.com>
Cc: 50176 <at> debbugs.gnu.org
Subject: Re: bug#50176: [PATCH] 28.0.50; repeat-mode does not clear
 echo-area after timeout
Date: Wed, 25 Aug 2021 20:11:10 +0300
> A simple patch:
>
> @@ -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))))

Thanks, pushed with small changes.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Sep 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 273 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.