unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
@ 2021-08-23 22:25 Gabriel
  2021-08-24  6:44 ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel @ 2021-08-23 22:25 UTC (permalink / raw)
  To: 50176

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-to-clear-echo-area-after-repeat-exit-timeout.patch --]
[-- Type: text/x-patch, Size: 908 bytes --]

From e6de15337bf4516740c0e790f6a2bfb3deaf9b5b Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@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


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

* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2021-08-24  6:44 UTC (permalink / raw)
  To: Gabriel; +Cc: 50176

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.





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

* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
  2021-08-24  6:44 ` Juri Linkov
@ 2021-08-24 14:31   ` Gabriel
  2021-08-24 18:20     ` Juri Linkov
  2021-08-25 17:11     ` Juri Linkov
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriel @ 2021-08-24 14:31 UTC (permalink / raw)
  To: 50176

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

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

* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
  2021-08-24 14:31   ` Gabriel
@ 2021-08-24 18:20     ` Juri Linkov
  2021-08-25 17:11     ` Juri Linkov
  1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-08-24 18:20 UTC (permalink / raw)
  To: Gabriel; +Cc: 50176

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





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

* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
       [not found] <FB0B8735-EB16-44C4-8D9A-E0141DF4A552@acm.org>
@ 2021-08-25 17:06 ` Juri Linkov
  0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-08-25 17:06 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 50176, Gabriel

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





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

* bug#50176: [PATCH] 28.0.50; repeat-mode does not clear echo-area after timeout
  2021-08-24 14:31   ` Gabriel
  2021-08-24 18:20     ` Juri Linkov
@ 2021-08-25 17:11     ` Juri Linkov
  1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-08-25 17:11 UTC (permalink / raw)
  To: Gabriel; +Cc: 50176

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





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

end of thread, other threads:[~2021-08-25 17:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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