unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
@ 2021-04-02  5:40 Ramesh Nedunchezian
  2021-04-03 22:08 ` Dmitry Gutov
  0 siblings, 1 reply; 23+ messages in thread
From: Ramesh Nedunchezian @ 2021-04-02  5:40 UTC (permalink / raw)
  To: 47566


28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'.

Commentary in `diff-hl' says

    ;; `diff-hl-mode' highlights uncommitted changes on the side of the
    ;; window (using the fringe, by default), allows you to jump between
    ;; the hunks and revert them selectively.

    ;; Provided commands:
    ;;
    ;; `diff-hl-diff-goto-hunk'  C-x v =
    ;; `diff-hl-revert-hunk'     C-x v n
    ;; `diff-hl-previous-hunk'   C-x v [
    ;; `diff-hl-next-hunk'       C-x v ]
    ;;
    ;; The mode takes advantage of `smartrep' if it is installed.

FWIW, `smartrep' is not part of GNU Emacs or GNU ELPA but available
elsewhere.  (I install it via MELPA)

Now, that `repeat-mode' is part of GNU Emacs, I think this dependency
on `smartrep' can be removed.

FWIW, this is what I have in my `.emacs'.

    (progn
      (defvar diff-hl--repeat-map
	(let
	    ((map
	      (make-sparse-keymap)))
	  map))
      (message "Installed %s" 'diff-hl--repeat-map)
      (cl-loop for
	       (cmd . key)
	       in
	       '((diff-hl-diff-goto-hunk . "=")
		 (diff-hl-revert-hunk . "n")
		 (diff-hl-previous-hunk . "[")
		 (diff-hl-next-hunk . "]"))
	       do
	       (define-key diff-hl--repeat-map key cmd)
	       (put cmd 'repeat-map 'diff-hl--repeat-map)))

----------------

In GNU Emacs 28.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-03-20 built on debian
Repository revision: 31544bc908d35bff513450bc4bea1d0283a7ddb0
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Debian GNU/Linux bullseye/sid





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-02  5:40 bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep' Ramesh Nedunchezian
@ 2021-04-03 22:08 ` Dmitry Gutov
  2021-04-05 20:43   ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-03 22:08 UTC (permalink / raw)
  To: Ramesh Nedunchezian, 47566, Juri Linkov

Hi!

On 02.04.2021 08:40, Ramesh Nedunchezian wrote:
> FWIW, `smartrep' is not part of GNU Emacs or GNU ELPA but available
> elsewhere.  (I install it via MELPA)
> 
> Now, that `repeat-mode' is part of GNU Emacs, I think this dependency
> on `smartrep' can be removed.

I'd be happy to migrate away from smartrep, as soon as the functionality 
is equal, and all supported Emacs versions have repeat-mode.

> FWIW, this is what I have in my `.emacs'.
> 
>      (progn
>        (defvar diff-hl--repeat-map
> 	(let
> 	    ((map
> 	      (make-sparse-keymap)))
> 	  map))
>        (message "Installed %s" 'diff-hl--repeat-map)
>        (cl-loop for
> 	       (cmd . key)
> 	       in
> 	       '((diff-hl-diff-goto-hunk . "=")
> 		 (diff-hl-revert-hunk . "n")
> 		 (diff-hl-previous-hunk . "[")
> 		 (diff-hl-next-hunk . "]"))
> 	       do
> 	       (define-key diff-hl--repeat-map key cmd)
> 	       (put cmd 'repeat-map 'diff-hl--repeat-map)))

Try this alternative too, seems shorter:

(map-keymap
  (lambda (_key cmd)
    (put cmd 'repeat-map 'diff-hl-command-map))
  diff-hl-command-map)

But either version (together with enabling repeat-mode) seems to break 
diff-hl-revert-hunk: as soon as it reaches the the y-or-n prompt, and I 
try to answer 'n', it enters the repeat loop again, instead of sending 
the result to the command.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-03 22:08 ` Dmitry Gutov
@ 2021-04-05 20:43   ` Juri Linkov
  2021-04-06 22:44     ` Dmitry Gutov
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2021-04-05 20:43 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Ramesh Nedunchezian, 47566

>>        (cl-loop for
>> 	       (cmd . key)
>> 	       in
>> 	       '((diff-hl-diff-goto-hunk . "=")
>> 		 (diff-hl-revert-hunk . "n")
>> 		 (diff-hl-previous-hunk . "[")
>> 		 (diff-hl-next-hunk . "]"))
>> 	       do
>> 	       (define-key diff-hl--repeat-map key cmd)
>> 	       (put cmd 'repeat-map 'diff-hl--repeat-map)))
>
> Try this alternative too, seems shorter:
>
> (map-keymap
>  (lambda (_key cmd)
>    (put cmd 'repeat-map 'diff-hl-command-map))
>  diff-hl-command-map)
>
> But either version (together with enabling repeat-mode) seems to break
> diff-hl-revert-hunk: as soon as it reaches the the y-or-n prompt, and I try
> to answer 'n', it enters the repeat loop again, instead of sending the
> result to the command.

Could you provide a minimal test case?  I tried with:

#+begin_src emacs-lisp
(defun hl-test ()
  (interactive)
  (message "OK")
  (y-or-n-p "Yes? "))

(defvar hl-repeat-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "r") 'hl-test)
    map)
  "Keymap to repeat hl-test.")
(put 'hl-test 'repeat-map 'hl-repeat-map)
#+end_src

Then typing `M-x hl-test RET', and `y r y r y r ...' keeps the loop.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-05 20:43   ` Juri Linkov
@ 2021-04-06 22:44     ` Dmitry Gutov
  2021-04-08 18:57       ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-06 22:44 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Ramesh Nedunchezian, 47566

Hi Juri,

On 05.04.2021 23:43, Juri Linkov wrote:
> Could you provide a minimal test case?  I tried with:
> 
> #+begin_src emacs-lisp
> (defun hl-test ()
>    (interactive)
>    (message "OK")
>    (y-or-n-p "Yes? "))
> 
> (defvar hl-repeat-map
>    (let ((map (make-sparse-keymap)))
>      (define-key map (kbd "r") 'hl-test)
>      map)
>    "Keymap to repeat hl-test.")
> (put 'hl-test 'repeat-map 'hl-repeat-map)
> #+end_src
> 
> Then typing `M-x hl-test RET', and `y r y r y r ...' keeps the loop.

Here you go:

(defun hl-test ()
   (interactive)
   (message "OK")
   (message "result: %s"
            (y-or-n-p "Yes? ")))

(defvar hl-repeat-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "n") 'hl-test) ; Note the changed key binding.
     map)
   "Keymap to repeat hl-test.")

(put 'hl-test 'repeat-map 'hl-repeat-map)

To try it:

1. M-x hl-test.
2. Press 'n' a few times.

Expected behavior:

It alternates between the prompt "Yes? " and message "result: nil".

Actual behavior:

It enters some sort of recursive state, only showing the prompt. I have 
to press 'y' a bunch of times to get out of it.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-06 22:44     ` Dmitry Gutov
@ 2021-04-08 18:57       ` Juri Linkov
  2021-04-10  1:40         ` Dmitry Gutov
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2021-04-08 18:57 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Ramesh Nedunchezian, 47566

> (defun hl-test ()
>   (interactive)
>   (message "OK")
>   (message "result: %s"
>            (y-or-n-p "Yes? ")))
>
> (defvar hl-repeat-map
>   (let ((map (make-sparse-keymap)))
>     (define-key map (kbd "n") 'hl-test) ; Note the changed key binding.
>     map)
>   "Keymap to repeat hl-test.")
>
> (put 'hl-test 'repeat-map 'hl-repeat-map)
>
> To try it:
>
> 1. M-x hl-test.
> 2. Press 'n' a few times.
>
> Expected behavior:
>
> It alternates between the prompt "Yes? " and message "result: nil".
>
> Actual behavior:
>
> It enters some sort of recursive state, only showing the prompt. I have to
> press 'y' a bunch of times to get out of it.

Thanks for the detailed test case.  Now it's fixed in 580c4c6510.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-08 18:57       ` Juri Linkov
@ 2021-04-10  1:40         ` Dmitry Gutov
  2021-04-10  8:38           ` Ramesh Nedunchezian
  2021-04-10 22:58           ` Juri Linkov
  0 siblings, 2 replies; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-10  1:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 47566-done, Ramesh Nedunchezian

On 08.04.2021 21:57, Juri Linkov wrote:
> Thanks for the detailed test case.  Now it's fixed in 580c4c6510.

Thanks! repeat-mode is looking good now (*).

I've added integration for it to diff-hl master, and with that we can 
close this issue.

Thanks all.

(*) Though the first impression, in comparison, was that it is too 
chatty. The hints are definitely helpful for discovery at first, though.

Maybe something like this would be an improvement? Experimental code 
warning.

diff --git a/lisp/repeat.el b/lisp/repeat.el
index b3c58f2f81..e704e4da56 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -404,7 +404,7 @@ repeat-post-hook
                                         (key-description repeat-exit-key))
                               ""))))
                  (if (current-message)
-                    (message "%s [%s]" (current-message) mess)
+                    (message #("%s [%s]" 3 7 (face deemphasized)) 
(current-message) mess)
                    (message mess))))

              ;; Adding an exit key





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10  1:40         ` Dmitry Gutov
@ 2021-04-10  8:38           ` Ramesh Nedunchezian
  2021-04-10 22:59             ` Juri Linkov
  2021-04-10 22:58           ` Juri Linkov
  1 sibling, 1 reply; 23+ messages in thread
From: Ramesh Nedunchezian @ 2021-04-10  8:38 UTC (permalink / raw)
  To: Dmitry Gutov, Juri Linkov; +Cc: 47566-done



On 10/04/21 7:10 am, Dmitry Gutov wrote:

> (*) Though the first impression, in comparison, was that it is too chatty. The hints are definitely helpful for discovery at first, though.
> 
> Maybe something like this would be an improvement? Experimental code warning.
> 
> diff --git a/lisp/repeat.el b/lisp/repeat.el
> index b3c58f2f81..e704e4da56 100644
> --- a/lisp/repeat.el
> +++ b/lisp/repeat.el
> @@ -404,7 +404,7 @@ repeat-post-hook
>                                         (key-description repeat-exit-key))
>                               ""))))
>                  (if (current-message)
> -                    (message "%s [%s]" (current-message) mess)
> +                    (message #("%s [%s]" 3 7 (face deemphasized)) (current-message) mess)
>                    (message mess))))
> 
>              ;; Adding an exit key

I created a repeat map for rectangle commands, and the echo area
becomes much more chattier. See
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47688.

It seems to me that repeat-mode is essentially a poor man's hydra.
May be the the symbol that holds the repeat map can specify a
`:help'-er property.

This `:help'-er can either

(a) give a fancy help string which the `repet-mode' can display in a
    pop-up

or

(b) the helper itself can prepare the string and arrange for providing
    a pop-up.

What I am saying is let the repeat map provide it's own `:help'-er
which the `repeat-mode' can hook in to.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10  1:40         ` Dmitry Gutov
  2021-04-10  8:38           ` Ramesh Nedunchezian
@ 2021-04-10 22:58           ` Juri Linkov
  2021-04-10 23:27             ` Dmitry Gutov
  1 sibling, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2021-04-10 22:58 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 47566-done, Ramesh Nedunchezian

> Maybe something like this would be an improvement? Experimental
> code warning.
>
> diff --git a/lisp/repeat.el b/lisp/repeat.el
> index b3c58f2f81..e704e4da56 100644
> --- a/lisp/repeat.el
> +++ b/lisp/repeat.el
> @@ -404,7 +404,7 @@ repeat-post-hook
>                                         (key-description repeat-exit-key))
>                               ""))))
>                  (if (current-message)
> -                    (message "%s [%s]" (current-message) mess)
> +                    (message #("%s [%s]" 3 7 (face deemphasized)) (current-message) mess)

I can't find the face named 'deemphasized'.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10  8:38           ` Ramesh Nedunchezian
@ 2021-04-10 22:59             ` Juri Linkov
  2021-04-11  6:48               ` Ramesh Nedunchezian
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2021-04-10 22:59 UTC (permalink / raw)
  To: Ramesh Nedunchezian; +Cc: 47566-done, Dmitry Gutov

> It seems to me that repeat-mode is essentially a poor man's hydra.

It is.  It provides only the basic functionality.
Don't expect many fancy things from repeat-mode.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10 22:58           ` Juri Linkov
@ 2021-04-10 23:27             ` Dmitry Gutov
  2021-04-12 16:17               ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-10 23:27 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 47566-done, Ramesh Nedunchezian

On 11.04.2021 01:58, Juri Linkov wrote:
> I can't find the face named 'deemphasized'.

Sorry.

Apparently, it's a face that only the tango-plus theme defines (unwisely).

It simply looks like less contrasting text. Try 'shadow' instead, it's 
about the same.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10 22:59             ` Juri Linkov
@ 2021-04-11  6:48               ` Ramesh Nedunchezian
  2021-04-11 22:51                 ` Juri Linkov
  2021-04-12 16:16                 ` Juri Linkov
  0 siblings, 2 replies; 23+ messages in thread
From: Ramesh Nedunchezian @ 2021-04-11  6:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 47566-done, Dmitry Gutov, Juri Linkov


On 11/04/21 4:29 am, Juri Linkov wrote:
>> It seems to me that repeat-mode is essentially a poor man's hydra.
> 
> It is.  It provides only the basic functionality.
> Don't expect many fancy things from repeat-mode.

The code below is pulled out from the existing code i.e., it doesn't
add any additional layer of complexity or does anything fanciful.  But
it does add a bit of extensibility.

This is what I was suggesting:

    (defvar repeat-mode-helper
      (defun repeat-mode-helper (map)
	(let (keys)
	  (message "Coming here")
	  (map-keymap (lambda (key _) (push key keys)) map)
	  (let ((mess (format-message
		       "Repeat with %s%s"
		       (mapconcat (lambda (key)
				    (key-description (vector key)))
				  keys ", ")
		       (if repeat-exit-key
			   (format ", or exit with %s"
				   (key-description repeat-exit-key))
			 ""))))
	    (if (current-message)
		(message "%s [%s]" (current-message) mess)
	      (message mess))))))


And in `repeat-post-hook', do something like

    ;; Messaging
    (unless prefix-arg
      (funcall (or (get rep-sym 'help) repeat-mode-helper) rep-map))


For those who don't want hints, they can use

    (setq repeat-mode-helper #'ignore)

For those who want hints, but do /not/ want the hints hogging the echo
area, they could have their own custom helper like the one above,
after replacing

	(message mess)

with

	(tooltip-show mess)

--------------------------------

I would also appreciate if you could assess adding the exit key as a
property to the repeat mode symbol.







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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-11  6:48               ` Ramesh Nedunchezian
@ 2021-04-11 22:51                 ` Juri Linkov
  2021-04-12 16:16                 ` Juri Linkov
  1 sibling, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-11 22:51 UTC (permalink / raw)
  To: Ramesh Nedunchezian; +Cc: 47566-done, Dmitry Gutov

> This is what I was suggesting:
>
>     (defvar repeat-mode-helper
>       (defun repeat-mode-helper (map)
>[...]
>
> For those who don't want hints, they can use
>
>     (setq repeat-mode-helper #'ignore)

Thanks, this is a good idea.  Maybe the name is not the best one
since the word "helper" often means a place that provides some
utility functions.

Using the Emacs terminology, a better name would be 'repeat-mode-echo'.
I'll add such option soon.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-11  6:48               ` Ramesh Nedunchezian
  2021-04-11 22:51                 ` Juri Linkov
@ 2021-04-12 16:16                 ` Juri Linkov
  1 sibling, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-12 16:16 UTC (permalink / raw)
  To: Ramesh Nedunchezian; +Cc: 47566-done, Dmitry Gutov

> For those who don't want hints, they can use
>
>     (setq repeat-mode-helper #'ignore)
>
> For those who want hints, but do /not/ want the hints hogging the echo
> area, they could have their own custom helper like the one above,
> after replacing
>
> 	(message mess)
>
> with
>
> 	(tooltip-show mess)

This is implemented now, so you can customize it to disable messaging,
to do truncation of long messages, or to use tooltip-show, etc.

> I would also appreciate if you could assess adding the exit key as a
> property to the repeat mode symbol.

The exit key specific to some keymap can be easily added to that keymap.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-10 23:27             ` Dmitry Gutov
@ 2021-04-12 16:17               ` Juri Linkov
  2021-04-13 23:54                 ` Dmitry Gutov
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2021-04-12 16:17 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 47566-done, Ramesh Nedunchezian

>> I can't find the face named 'deemphasized'.
>
> Sorry.
>
> Apparently, it's a face that only the tango-plus theme defines (unwisely).
>
> It simply looks like less contrasting text. Try 'shadow' instead, it's
> about the same.

I'm not sure about deemphasizing by default.  But now it's easy to
customize this, and add any emphazing.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-12 16:17               ` Juri Linkov
@ 2021-04-13 23:54                 ` Dmitry Gutov
  2021-04-14  7:14                   ` Kévin Le Gouguec
  0 siblings, 1 reply; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-13 23:54 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 47566-done, Ramesh Nedunchezian

On 12.04.2021 19:17, Juri Linkov wrote:
>>> I can't find the face named 'deemphasized'.
>>
>> Sorry.
>>
>> Apparently, it's a face that only the tango-plus theme defines (unwisely).
>>
>> It simply looks like less contrasting text. Try 'shadow' instead, it's
>> about the same.
> 
> I'm not sure about deemphasizing by default.  But now it's easy to
> customize this, and add any emphazing.

Thanks.

Consider adding a repeat-mode-echo option which follows what Smartrep 
does: instead of adding to the echo area, it just highlights the changed 
state in the mode line (basically a long mode lighter saying 
"========SMARTREP=======") and also colors the mode-line green.

IME that works well as an indicator that we're in a "special" state.

Though perhaps we could use a smaller text (like "[REPEAT]") and only 
color the text inside the brackets, rather than the whole mode-line. 
Could use some experimentation.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-13 23:54                 ` Dmitry Gutov
@ 2021-04-14  7:14                   ` Kévin Le Gouguec
  2021-04-14 18:10                     ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Kévin Le Gouguec @ 2021-04-14  7:14 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 47566-done, Ramesh Nedunchezian, Juri Linkov

Dmitry Gutov <dgutov@yandex.ru> writes:

> Consider adding a repeat-mode-echo option which follows what Smartrep
> does: instead of adding to the echo area, it just highlights the
> changed state in the mode line (basically a long mode lighter saying
> "========SMARTREP=======") and also colors the mode-line green.
>
> IME that works well as an indicator that we're in a "special" state.
>
> Though perhaps we could use a smaller text (like "[REPEAT]") and only
> color the text inside the brackets, rather than the whole
> mode-line. Could use some experimentation.

An entry in mode-line-modes, à la compilation-in-progress, would be
lovely IMO.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14  7:14                   ` Kévin Le Gouguec
@ 2021-04-14 18:10                     ` Juri Linkov
  2021-04-14 19:12                       ` Kévin Le Gouguec
  2021-04-14 23:35                       ` Dmitry Gutov
  0 siblings, 2 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-14 18:10 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

>> Consider adding a repeat-mode-echo option which follows what Smartrep
>> does: instead of adding to the echo area, it just highlights the
>> changed state in the mode line (basically a long mode lighter saying
>> "========SMARTREP=======") and also colors the mode-line green.
>>
>> IME that works well as an indicator that we're in a "special" state.
>>
>> Though perhaps we could use a smaller text (like "[REPEAT]") and only
>> color the text inside the brackets, rather than the whole
>> mode-line. Could use some experimentation.
>
> An entry in mode-line-modes, à la compilation-in-progress, would be
> lovely IMO.

compilation-in-progress is a good example of an unobtrusive indicator
in the mode line.  Now added to repeat-mode.

PS: like your message-subject-re-regexp turned the subject into
"Re: peat lambda" on emacs-devel, it removed the bug number
from the subject here :)





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 18:10                     ` Juri Linkov
@ 2021-04-14 19:12                       ` Kévin Le Gouguec
  2021-04-14 19:52                         ` Juri Linkov
  2021-04-14 23:35                       ` Dmitry Gutov
  1 sibling, 1 reply; 23+ messages in thread
From: Kévin Le Gouguec @ 2021-04-14 19:12 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

Juri Linkov <juri@linkov.net> writes:

>> An entry in mode-line-modes, à la compilation-in-progress, would be
>> lovely IMO.
>
> compilation-in-progress is a good example of an unobtrusive indicator
> in the mode line.  Now added to repeat-mode.

Thanks!  Was this bit intentional?

> ;;;###autoload
> (put 'mode-line-defining-kbd-macro 'risky-local-variable t)

Also, AFAICT the indication (whether in the mode-line or in the echo
area) only shows up once I start repeating a key (e.g. after C-x o o),
not when I first hit a repeatable key (e.g. after C-x o).

Is this intended?  I figure it would make sense to display the
indication before the user starts repeating, since the indication can
serve as a warning that repetition might occur.


At any rate, thanks a lot for working on this.  (And thanks to all for
the addition to diff-hl!)


> PS: like your message-subject-re-regexp turned the subject into
> "Re: peat lambda" on emacs-devel, it removed the bug number
> from the subject here :)

🤦 Thanks for the heads-up.  IIUC message-subject-re-regexp is used both
by Gnus summary buffers to "canonicalize" subjects in order to only show
them for thread roots, *and* by message-mode to strip cruft before
adding "Re:" to a reply.  I'll need to figure a way to decorrelate those
two uses…

(This is completely off-topic of course; I'm just thinking out loud)





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 19:12                       ` Kévin Le Gouguec
@ 2021-04-14 19:52                         ` Juri Linkov
  2021-04-14 20:21                           ` Juri Linkov
  2021-04-14 20:48                           ` Kévin Le Gouguec
  0 siblings, 2 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-14 19:52 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

> Thanks!  Was this bit intentional?
>
>> ;;;###autoload
>> (put 'mode-line-defining-kbd-macro 'risky-local-variable t)

Thanks for noticing this, I stole this from bindings.el,
but now that repeat-echo-mode-line-string is highlighted
correctly in the mode-line, I wonder if such property is needed
for repeat-echo-mode-line-string at all?  And why it was needed
for mode-line-defining-kbd-macro to keep its text properties?

After removing this line from bindings.el:
  (put 'mode-line-defining-kbd-macro 'risky-local-variable t)
mode-line-defining-kbd-macro loses its text property
face=font-lock-warning-face, but repeat-echo-mode-line-string keeps it.

This is explained in (info "(elisp) Properties in Mode"),
but I don't understand why text properties are preserved for
repeat-echo-mode-line-string without ‘risky-local-variable’ property?

> Also, AFAICT the indication (whether in the mode-line or in the echo
> area) only shows up once I start repeating a key (e.g. after C-x o o),
> not when I first hit a repeatable key (e.g. after C-x o).

Strange, I see it immediately after C-x o.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 19:52                         ` Juri Linkov
@ 2021-04-14 20:21                           ` Juri Linkov
  2021-04-14 20:48                           ` Kévin Le Gouguec
  1 sibling, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-14 20:21 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

>> Also, AFAICT the indication (whether in the mode-line or in the echo
>> area) only shows up once I start repeating a key (e.g. after C-x o o),
>> not when I first hit a repeatable key (e.g. after C-x o).
>
> Strange, I see it immediately after C-x o.

Could you please try to move 'force-mode-line-update' out of condition,
so it updates the mode-line on activating the repeat map as well:

#+begin_src emacs-lisp
(defun repeat-echo-mode-line (map)
  "Display the repeat indicator in the mode line."
  (if map
      (unless (assq 'repeat-in-progress mode-line-modes)
        (add-to-list 'mode-line-modes (list 'repeat-in-progress
                                            repeat-echo-mode-line-string))))
  (force-mode-line-update t))
#+end_src

Maybe your mode-line is not updated immediately?





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 19:52                         ` Juri Linkov
  2021-04-14 20:21                           ` Juri Linkov
@ 2021-04-14 20:48                           ` Kévin Le Gouguec
  2021-04-14 21:58                             ` Juri Linkov
  1 sibling, 1 reply; 23+ messages in thread
From: Kévin Le Gouguec @ 2021-04-14 20:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

Juri Linkov <juri@linkov.net> writes:

>> Also, AFAICT the indication (whether in the mode-line or in the echo
>> area) only shows up once I start repeating a key (e.g. after C-x o o),
>> not when I first hit a repeatable key (e.g. after C-x o).
>
> Strange, I see it immediately after C-x o.

🤦 My apologies, I should have tried with emacs -Q before jumping to
conclusions; I actually had left C-x o bound to my own command…  I hope
I didn't waste too much of your time on this.






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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 20:48                           ` Kévin Le Gouguec
@ 2021-04-14 21:58                             ` Juri Linkov
  0 siblings, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2021-04-14 21:58 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Dmitry Gutov, Ramesh Nedunchezian, 47566

>>> Also, AFAICT the indication (whether in the mode-line or in the echo
>>> area) only shows up once I start repeating a key (e.g. after C-x o o),
>>> not when I first hit a repeatable key (e.g. after C-x o).
>>
>> Strange, I see it immediately after C-x o.
>
> 🤦 My apologies, I should have tried with emacs -Q before jumping to
> conclusions; I actually had left C-x o bound to my own command…  I hope
> I didn't waste too much of your time on this.

No problem.  I just wondered why the mode-line is automatically updated
when repeat-in-progress in mode-line-modes is non-nil, but not updated
when it becomes nil.





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

* bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep'
  2021-04-14 18:10                     ` Juri Linkov
  2021-04-14 19:12                       ` Kévin Le Gouguec
@ 2021-04-14 23:35                       ` Dmitry Gutov
  1 sibling, 0 replies; 23+ messages in thread
From: Dmitry Gutov @ 2021-04-14 23:35 UTC (permalink / raw)
  To: Juri Linkov, Kévin Le Gouguec; +Cc: Ramesh Nedunchezian, 47566

On 14.04.2021 21:10, Juri Linkov wrote:
> compilation-in-progress is a good example of an unobtrusive indicator
> in the mode line.  Now added to repeat-mode.

Looks nice, thank you.





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

end of thread, other threads:[~2021-04-14 23:35 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02  5:40 bug#47566: 28.0.50; diff-hl should use `repeat-mode' ... and not `smartrep' Ramesh Nedunchezian
2021-04-03 22:08 ` Dmitry Gutov
2021-04-05 20:43   ` Juri Linkov
2021-04-06 22:44     ` Dmitry Gutov
2021-04-08 18:57       ` Juri Linkov
2021-04-10  1:40         ` Dmitry Gutov
2021-04-10  8:38           ` Ramesh Nedunchezian
2021-04-10 22:59             ` Juri Linkov
2021-04-11  6:48               ` Ramesh Nedunchezian
2021-04-11 22:51                 ` Juri Linkov
2021-04-12 16:16                 ` Juri Linkov
2021-04-10 22:58           ` Juri Linkov
2021-04-10 23:27             ` Dmitry Gutov
2021-04-12 16:17               ` Juri Linkov
2021-04-13 23:54                 ` Dmitry Gutov
2021-04-14  7:14                   ` Kévin Le Gouguec
2021-04-14 18:10                     ` Juri Linkov
2021-04-14 19:12                       ` Kévin Le Gouguec
2021-04-14 19:52                         ` Juri Linkov
2021-04-14 20:21                           ` Juri Linkov
2021-04-14 20:48                           ` Kévin Le Gouguec
2021-04-14 21:58                             ` Juri Linkov
2021-04-14 23:35                       ` Dmitry Gutov

unofficial mirror of bug-gnu-emacs@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/emacs-bugs/0 emacs-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 emacs-bugs emacs-bugs/ https://yhetil.org/emacs-bugs \
		bug-gnu-emacs@gnu.org
	public-inbox-index emacs-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.bugs
	nntp://news.gmane.io/gmane.emacs.bugs


code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs.git

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git