unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* POLL: make C-x o transient
@ 2021-01-24  6:12 Zhiwei Chen
  2021-01-24 11:32 ` Kévin Le Gouguec
                   ` (6 more replies)
  0 siblings, 7 replies; 74+ messages in thread
From: Zhiwei Chen @ 2021-01-24  6:12 UTC (permalink / raw)
  To: emacs-devel; +Cc: condy0919@gmail.com, emacs-devel

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

Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’ does.

What benefits from this change:
1. Fewer keystrokes for multi windows navigation
2. Reduce the probability of RSI
3. Able to navigate windows backwards

POC follows:

(defcustom transient-other-window nil)

(defun other-window-backward ()
  (interactive)
  (other-window -1))

(defun transient-other-window ()
  (interactive)
  (let ((echo-keystrokes nil))
    (other-window 1)
    (set-transient-map
     (let ((map (make-sparse-keymap)))
       (define-key map "o" #'other-window)
       (define-key map "O" #'other-window-backward)
       map)
     t)))

(if transient-other-window
    (global-set-key (kbd "C-x o") #'transient-other-window)
  (global-set-key (kbd "C-x o") #'other-window))

--
Zhiwei Chen



[-- Attachment #2: Type: text/html, Size: 2749 bytes --]

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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
@ 2021-01-24 11:32 ` Kévin Le Gouguec
  2021-01-24 14:40   ` andrés ramírez
  2021-01-25  5:52 ` Richard Stallman
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 74+ messages in thread
From: Kévin Le Gouguec @ 2021-01-24 11:32 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: condy0919@gmail.com, emacs-devel

Zhiwei Chen <chenzhiwei03@kuaishou.com> writes:

> Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’ does.

Heartfelt agreement.  I have a somewhat dumber version of your
transient-other-window in my config; I'd love to scrap it for another
entry in custom-set-variables.

Two improvements I never bothered implementing, but I'd love to see in a
builtin command:

1. Display something in the echo area, to remind me that the transient
   map is active: once in a blue moon, I move to another window, think
   for a bit (forgetting about the map), start typing something that
   begins with 'o', and get startled because I moved to another window.

   With some luck, a message would help remind me to hit C-g first.

2. Define the keymap outside transient-other-window?  I'm sure some
   creative users will come up with interesting commands to add to it
   (e.g. 'b' for switch-to-buffer).

Of course, I'd be delighted if your current version made it to Emacs
core; I wouldn't want this to be delayed by feature creep :)



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

* Re: POLL: make C-x o transient
  2021-01-24 11:32 ` Kévin Le Gouguec
@ 2021-01-24 14:40   ` andrés ramírez
  0 siblings, 0 replies; 74+ messages in thread
From: andrés ramírez @ 2021-01-24 14:40 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: condy0919@gmail.com, Zhiwei Chen, emacs-devel

Hi. 
>>>>> "Kévin" == Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:

    Kévin> Zhiwei Chen <chenzhiwei03@kuaishou.com> writes:
    >> Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’
    >> does.

Same could be applied to C-x f other-frame

Best Regards



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
  2021-01-24 11:32 ` Kévin Le Gouguec
@ 2021-01-25  5:52 ` Richard Stallman
  2021-01-25 12:21   ` Zhiwei Chen
  2021-01-25 14:39 ` Stefan Monnier
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-01-25  5:52 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: condy0919, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > What benefits from this change:
  > 1. Fewer keystrokes for multi windows navigation
  > 2. Reduce the probability of RSI
  > 3. Able to navigate windows backwards

Would you please spell out the behavior of your proposed new command?
What would the change be for a user?

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-01-25  5:52 ` Richard Stallman
@ 2021-01-25 12:21   ` Zhiwei Chen
  2021-01-26  6:02     ` Richard Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: Zhiwei Chen @ 2021-01-25 12:21 UTC (permalink / raw)
  To: rms@gnu.org; +Cc: condy0919@gmail.com, emacs-devel


> On Jan 25, 2021, at 1:52 PM, Richard Stallman <rms@gnu.org> wrote:
> 
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> 
>> What benefits from this change:
>> 1. Fewer keystrokes for multi windows navigation
>> 2. Reduce the probability of RSI
>> 3. Able to navigate windows backwards
> 
> Would you please spell out the behavior of your proposed new command?
> What would the change be for a user?


Presume `other-window' navigates clockwise, and current focus is on window 1.

,-----.-----.
| [1] |  2  |
|--- -+-----|
|  4  |  3  |
'-----.-----'

3/4 windows in Emacs are common in HiDPI users.

You have to press {C-x o} twice to go to window 3. Meanwhile, you have to
release the Control key to avoid the invocation of `delete-blank-lines' which is
bound to {C-x C-o} by default. It's painful for your little finger without an
external keyboard.

What will happen if we make {C-x o} bind to a transient map? {C-x o}, forget the
Control key and press "o" twice. It's easier to navigate to window 3 when
compared with the previous one. An analogue is `windmove-left' which is bound to
{S-<left>} by default. In practice, we press {S-<left>} without releasing of
Shift key since it's convenient for the next movement. The same for {C-x o} but
"the Shift key" is pressed implicitly when we enter transient state

Bonus: we can bind "O" to a counterclockwise `other-window' function.

--
Zhiwei Chen



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
  2021-01-24 11:32 ` Kévin Le Gouguec
  2021-01-25  5:52 ` Richard Stallman
@ 2021-01-25 14:39 ` Stefan Monnier
  2021-01-25 15:30   ` aitor
                     ` (3 more replies)
  2021-01-25 21:12 ` Sean Whitton
                   ` (3 subsequent siblings)
  6 siblings, 4 replies; 74+ messages in thread
From: Stefan Monnier @ 2021-01-25 14:39 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: condy0919@gmail.com, emacs-devel

> Which will make `C-x o` invoke a transient version of `other-window'
> like `text-scale-adjust’ does.

I think the pattern is clear: `C-x <letter>` are good candidates ;-)

> (defcustom transient-other-window nil)
>
> (defun other-window-backward ()
>   (interactive)
>   (other-window -1))
>
> (defun transient-other-window ()
>   (interactive)
>   (let ((echo-keystrokes nil))
>     (other-window 1)
>     (set-transient-map
>      (let ((map (make-sparse-keymap)))
>        (define-key map "o" #'other-window)
>        (define-key map "O" #'other-window-backward)
>        map)
>      t)))
>
> (if transient-other-window
>     (global-set-key (kbd "C-x o") #'transient-other-window)
>   (global-set-key (kbd "C-x o") #'other-window))

It needs work, but I agree with the intention.


        Stefan




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

* Re: POLL: make C-x o transient
  2021-01-25 14:39 ` Stefan Monnier
@ 2021-01-25 15:30   ` aitor
  2021-01-25 16:38     ` Philip K.
                       ` (2 more replies)
  2021-01-25 15:47   ` [External] : " Drew Adams
                     ` (2 subsequent siblings)
  3 siblings, 3 replies; 74+ messages in thread
From: aitor @ 2021-01-25 15:30 UTC (permalink / raw)
  To: emacs-devel

On Mon, Jan 25, 2021 at 09:39:00AM -0500, Stefan Monnier wrote:
> > Which will make `C-x o` invoke a transient version of `other-window'
> > like `text-scale-adjust’ does.
> 
> I think the pattern is clear: `C-x <letter>` are good candidates ;-)

Sorry to chime in with an off-topic issue, but I once wrote the following in my
init.el file:

;; move thorugh windows
(global-set-key (kbd "C-x <left>")  'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <up>")    'windmove-up)
(global-set-key (kbd "C-x <down>")  'windmove-down)

and never have looked back since. This is very useful for me, particularly when
dealing with many windows (gdb-many-windows, etc).

best,
                        aitor



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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-25 14:39 ` Stefan Monnier
  2021-01-25 15:30   ` aitor
@ 2021-01-25 15:47   ` Drew Adams
  2021-01-25 17:01   ` Juri Linkov
  2021-01-25 17:27   ` Jose E. Marchesi
  3 siblings, 0 replies; 74+ messages in thread
From: Drew Adams @ 2021-01-25 15:47 UTC (permalink / raw)
  To: Stefan Monnier, Zhiwei Chen; +Cc: condy0919@gmail.com, emacs-devel

> > Which will make `C-x o` invoke a transient version of `other-window'
> > like `text-scale-adjust’ does.
> 
> I think the pattern is clear: `C-x <letter>` are good candidates ;-)

Please do NOT sacrifice any more <letter>s here.
Leave them, to be available generally, for users
and libraries.

Repurposing the existing `C-x o' would be fine,
of course.  It should definitely be made more
useful by making it repeatable (`C-x o o ...').

Whether that's used for window navigation or
something else is a different question. (Use
for window navigation is fine by me.)

And if used for window navigation, just how that
navigation proceeds is yet another question.
(Any reversible systematic cycling is fine by me.)

> It needs work, but I agree with the intention.

+1

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

* Re: POLL: make C-x o transient
  2021-01-25 15:30   ` aitor
@ 2021-01-25 16:38     ` Philip K.
  2021-01-25 17:23     ` Colin Baxter
  2021-01-26  5:59     ` Richard Stallman
  2 siblings, 0 replies; 74+ messages in thread
From: Philip K. @ 2021-01-25 16:38 UTC (permalink / raw)
  To: aitor; +Cc: emacs-devel

aitor <a.soroa@gmail.com> writes:

> On Mon, Jan 25, 2021 at 09:39:00AM -0500, Stefan Monnier wrote:
>> > Which will make `C-x o` invoke a transient version of `other-window'
>> > like `text-scale-adjust’ does.
>> 
>> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>
> Sorry to chime in with an off-topic issue, but I once wrote the following in my
> init.el file:
>
> ;; move thorugh windows
> (global-set-key (kbd "C-x <left>")  'windmove-left)
> (global-set-key (kbd "C-x <right>") 'windmove-right)
> (global-set-key (kbd "C-x <up>")    'windmove-up)
> (global-set-key (kbd "C-x <down>")  'windmove-down)

If you don't use the arrow keys for regular navigation, you could just
as well bind the windmove commands directly to up/down/left/right.

> and never have looked back since. This is very useful for me, particularly when
> dealing with many windows (gdb-many-windows, etc).
>
> best,
>                         aitor
>
>

-- 
	Philip K.



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

* Re: POLL: make C-x o transient
  2021-01-25 14:39 ` Stefan Monnier
  2021-01-25 15:30   ` aitor
  2021-01-25 15:47   ` [External] : " Drew Adams
@ 2021-01-25 17:01   ` Juri Linkov
  2021-01-25 17:21     ` Omar Polo
  2021-01-27 17:55     ` Juri Linkov
  2021-01-25 17:27   ` Jose E. Marchesi
  3 siblings, 2 replies; 74+ messages in thread
From: Juri Linkov @ 2021-01-25 17:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: condy0919@gmail.com, Zhiwei Chen, emacs-devel

>> Which will make `C-x o` invoke a transient version of `other-window'
>> like `text-scale-adjust’ does.
>
> I think the pattern is clear: `C-x <letter>` are good candidates ;-)

And non-letters too, especially `C-x {`, `C-x }`, `C-x ^`, ...
need to be repeatable.  I'm using such quite messy blob of code,
it would be nice if someone would generalize this mess
without using advice-add.

#+begin_src emacs-lisp
(defvar window-command-keymap
  (let ((map (make-sparse-keymap)))
    ;; Standard keys:
    (define-key map "0" 'delete-window)
    (define-key map "1" 'delete-other-windows)
    (define-key map "2" 'split-window-below)
    (define-key map "3" 'split-window-right)
    (define-key map "o" 'other-window)
    (define-key map "^" 'enlarge-window)
    (define-key map "}" 'enlarge-window-horizontally)
    (define-key map "{" 'shrink-window-horizontally)
    (define-key map "-" 'shrink-window-if-larger-than-buffer)
    (define-key map "+" 'balance-windows)
    ;; Additional keys:
    (define-key map "v"     'shrink-window)
    (define-key map [down]  'shrink-window)
    (define-key map [up]    'enlarge-window)
    (define-key map [left]  'shrink-window-horizontally)
    (define-key map [right] 'enlarge-window-horizontally)
    map)
  "Keymap for commands that operate on windows.")

(advice-add 'enlarge-window-horizontally
            :after (lambda (&rest _args)
                     (set-transient-map window-command-keymap)))
(advice-add 'shrink-window-horizontally
            :after (lambda (&rest _args)
                     (set-transient-map window-command-keymap)))
(advice-add 'enlarge-window
            :after (lambda (&rest _args)
                     (set-transient-map window-command-keymap)))
(advice-add 'shrink-window
            :after (lambda (&rest _args)
                     (set-transient-map window-command-keymap)))
(defun window-command-prefix ()
  (interactive)
  (message "Use window prefix keys...")
  (set-transient-map window-command-keymap))
(define-key ctl-x-map "wr" window-command-prefix)

;; (define-key window-command-keymap [digit-argument] 'ignore)
;; (define-key window-command-keymap [universal-argument] 'ignore)
;; (define-key window-command-keymap [?\C-u] 'universal-argument)
#+end_src



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

* Re: POLL: make C-x o transient
  2021-01-25 17:01   ` Juri Linkov
@ 2021-01-25 17:21     ` Omar Polo
  2021-01-27 17:55     ` Juri Linkov
  1 sibling, 0 replies; 74+ messages in thread
From: Omar Polo @ 2021-01-25 17:21 UTC (permalink / raw)
  To: Juri Linkov; +Cc: condy0919@gmail.com, Stefan Monnier, Zhiwei Chen, emacs-devel


Juri Linkov <juri@linkov.net> writes:

>>> Which will make `C-x o` invoke a transient version of `other-window'
>>> like `text-scale-adjust’ does.
>>
>> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>
> And non-letters too, especially `C-x {`, `C-x }`, `C-x ^`, ...
> need to be repeatable.  I'm using such quite messy blob of code,
> it would be nice if someone would generalize this mess
> without using advice-add.

FWIW, I completely agree, and I'm using various hydras to achieve the
same

  (defhydra hydra-other-window (global-map "C-x")
    ("o" other-window "next window")
    ("O" (other-window -1) "previous window"))

  (defhydra hydra-grep-like (global-map "M-g")
    ("n" next-error "next")
    ("p" previous-error "prev")
    ("RET" nil :exit t)
    ("q" nil :exit t))

  (defhydra hydra-windowsize (global-map "C-x")
    ("{" shrink-window-horizontally)
    ("}" enlarge-window-horizontally))

  (defhydra hydra-pages (global-map "C-x" :hint nil)
    ("[" backward-page)
    ("]" forward-page)
    ("RET" nil :exit t)
    ("q" nil :exit t))

  (defhydra hydra-hscroll (global-map "C-x" :hint nil)
    (">" scroll-left)
    ("<" scroll-right))

> #+begin_src emacs-lisp
> (defvar window-command-keymap
>   (let ((map (make-sparse-keymap)))
>     ;; Standard keys:
>     (define-key map "0" 'delete-window)
>     (define-key map "1" 'delete-other-windows)
>     (define-key map "2" 'split-window-below)
>     (define-key map "3" 'split-window-right)
>     (define-key map "o" 'other-window)
>     (define-key map "^" 'enlarge-window)
>     (define-key map "}" 'enlarge-window-horizontally)
>     (define-key map "{" 'shrink-window-horizontally)
>     (define-key map "-" 'shrink-window-if-larger-than-buffer)
>     (define-key map "+" 'balance-windows)
>     ;; Additional keys:
>     (define-key map "v"     'shrink-window)
>     (define-key map [down]  'shrink-window)
>     (define-key map [up]    'enlarge-window)
>     (define-key map [left]  'shrink-window-horizontally)
>     (define-key map [right] 'enlarge-window-horizontally)
>     map)
>   "Keymap for commands that operate on windows.")
>
> (advice-add 'enlarge-window-horizontally
>             :after (lambda (&rest _args)
>                      (set-transient-map window-command-keymap)))
> (advice-add 'shrink-window-horizontally
>             :after (lambda (&rest _args)
>                      (set-transient-map window-command-keymap)))
> (advice-add 'enlarge-window
>             :after (lambda (&rest _args)
>                      (set-transient-map window-command-keymap)))
> (advice-add 'shrink-window
>             :after (lambda (&rest _args)
>                      (set-transient-map window-command-keymap)))
> (defun window-command-prefix ()
>   (interactive)
>   (message "Use window prefix keys...")
>   (set-transient-map window-command-keymap))
> (define-key ctl-x-map "wr" window-command-prefix)
>
> ;; (define-key window-command-keymap [digit-argument] 'ignore)
> ;; (define-key window-command-keymap [universal-argument] 'ignore)
> ;; (define-key window-command-keymap [?\C-u] 'universal-argument)
> #+end_src




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

* Re: POLL: make C-x o transient
  2021-01-25 15:30   ` aitor
  2021-01-25 16:38     ` Philip K.
@ 2021-01-25 17:23     ` Colin Baxter
  2021-01-26  5:59     ` Richard Stallman
  2 siblings, 0 replies; 74+ messages in thread
From: Colin Baxter @ 2021-01-25 17:23 UTC (permalink / raw)
  To: aitor; +Cc: emacs-devel

>>>>> aitor  <a.soroa@gmail.com> writes:

    > On Mon, Jan 25, 2021 at 09:39:00AM -0500, Stefan Monnier wrote:
    >> > Which will make `C-x o` invoke a transient version of
    >> `other-window' > like `text-scale-adjust’ does.
    >> 
    >> I think the pattern is clear: `C-x <letter>` are good candidates
    >> ;-)

    > Sorry to chime in with an off-topic issue, but I once wrote the
    > following in my init.el file:

    > ;; move thorugh windows
    > (global-set-key (kbd "C-x <left>") 'windmove-left)
    > (global-set-key (kbd "C-x <right>") 'windmove-right)
    > (global-set-key (kbd "C-x <up>") 'windmove-up)
    > (global-set-key (kbd "C-x <down>") 'windmove-down)

Isn't C-x <ARROW> linked to next/previous buffer?

Best wishes,


Colin Baxter



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

* Re: POLL: make C-x o transient
  2021-01-25 14:39 ` Stefan Monnier
                     ` (2 preceding siblings ...)
  2021-01-25 17:01   ` Juri Linkov
@ 2021-01-25 17:27   ` Jose E. Marchesi
  3 siblings, 0 replies; 74+ messages in thread
From: Jose E. Marchesi @ 2021-01-25 17:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: condy0919@gmail.com, Zhiwei Chen, emacs-devel


>> Which will make `C-x o` invoke a transient version of `other-window'
>> like `text-scale-adjust’ does.
>
> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>
>> (defcustom transient-other-window nil)
>>
>> (defun other-window-backward ()
>>   (interactive)
>>   (other-window -1))
>>
>> (defun transient-other-window ()
>>   (interactive)
>>   (let ((echo-keystrokes nil))
>>     (other-window 1)
>>     (set-transient-map
>>      (let ((map (make-sparse-keymap)))
>>        (define-key map "o" #'other-window)
>>        (define-key map "O" #'other-window-backward)
>>        map)
>>      t)))
>>
>> (if transient-other-window
>>     (global-set-key (kbd "C-x o") #'transient-other-window)
>>   (global-set-key (kbd "C-x o") #'other-window))
>
> It needs work, but I agree with the intention.

+1



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
                   ` (2 preceding siblings ...)
  2021-01-25 14:39 ` Stefan Monnier
@ 2021-01-25 21:12 ` Sean Whitton
  2021-01-27 21:46 ` Gregory Heytings
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 74+ messages in thread
From: Sean Whitton @ 2021-01-25 21:12 UTC (permalink / raw)
  To: Zhiwei Chen, emacs-devel; +Cc: condy0919@gmail.com, emacs-devel

Hello,

On Sun 24 Jan 2021 at 06:12AM GMT, Zhiwei Chen wrote:

> Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’ does.
>
> What benefits from this change:
> 1. Fewer keystrokes for multi windows navigation
> 2. Reduce the probability of RSI
> 3. Able to navigate windows backwards

Seems useful to have this be something you can toggle on, but I'd prefer
not to have the default change.  Transient maps with self-inserting
chars lead to commands when you intended just to type, in my experience.

-- 
Sean Whitton



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

* Re: POLL: make C-x o transient
  2021-01-25 15:30   ` aitor
  2021-01-25 16:38     ` Philip K.
  2021-01-25 17:23     ` Colin Baxter
@ 2021-01-26  5:59     ` Richard Stallman
  2021-01-26 10:44       ` Olivier Certner
  2 siblings, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-01-26  5:59 UTC (permalink / raw)
  To: aitor; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > (global-set-key (kbd "C-x <left>")  'windmove-left)
  > (global-set-key (kbd "C-x <right>") 'windmove-right)

Those two have current bindings in the same spirit: previous-buffer
and next-buffer.  Which ones are better, I have no opinion.

  > (global-set-key (kbd "C-x <up>")    'windmove-up)
  > (global-set-key (kbd "C-x <down>")  'windmove-down)

These two are undefined.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-01-25 12:21   ` Zhiwei Chen
@ 2021-01-26  6:02     ` Richard Stallman
  0 siblings, 0 replies; 74+ messages in thread
From: Richard Stallman @ 2021-01-26  6:02 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: condy0919, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Thanks for explaining.  I don't have strong feelings about it.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-01-26  5:59     ` Richard Stallman
@ 2021-01-26 10:44       ` Olivier Certner
  2021-01-26 23:38         ` Sean Whitton
  0 siblings, 1 reply; 74+ messages in thread
From: Olivier Certner @ 2021-01-26 10:44 UTC (permalink / raw)
  To: rms; +Cc: aitor, emacs-devel

Hi,

> Those two have current bindings in the same spirit: previous-buffer
> and next-buffer.  Which ones are better, I have no opinion.

These commands are also available through C-x C-<left> and C-x C-<right> by 
default.

Personally, I find these commands less useful than those for changing the 
current window. I've been happy for a long which with rebinding C-x <left> and 
C-x <right>, especially given the existence of the abovementioned alternative 
shortcuts to `previous-buffer' and `next-buffer'.

Regards.

-- 
Olivier Certner





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

* Re: POLL: make C-x o transient
  2021-01-26 10:44       ` Olivier Certner
@ 2021-01-26 23:38         ` Sean Whitton
  2021-01-27  6:51           ` Colin Baxter
  0 siblings, 1 reply; 74+ messages in thread
From: Sean Whitton @ 2021-01-26 23:38 UTC (permalink / raw)
  To: Olivier Certner, rms; +Cc: aitor, emacs-devel

Hello,

On Tue 26 Jan 2021 at 11:44AM +01, Olivier Certner wrote:

> Hi,
>
>> Those two have current bindings in the same spirit: previous-buffer
>> and next-buffer.  Which ones are better, I have no opinion.
>
> These commands are also available through C-x C-<left> and C-x C-<right> by
> default.

Those bindings are unlikely to work on text terminals, however.

-- 
Sean Whitton



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

* Re: POLL: make C-x o transient
  2021-01-26 23:38         ` Sean Whitton
@ 2021-01-27  6:51           ` Colin Baxter
  0 siblings, 0 replies; 74+ messages in thread
From: Colin Baxter @ 2021-01-27  6:51 UTC (permalink / raw)
  To: Sean Whitton; +Cc: emacs-devel, rms, aitor, Olivier Certner

>>>>> Sean Whitton <spwhitton@spwhitton.name> writes:

    > Hello,
    > On Tue 26 Jan 2021 at 11:44AM +01, Olivier Certner wrote:

    >> Hi,
    >> 
    >>> Those two have current bindings in the same spirit:
    >>> previous-buffer and next-buffer.  Which ones are better, I have
    >>> no opinion.
    >> 
    >> These commands are also available through C-x C-<left> and C-x
    >> C-<right> by default.

    > Those bindings are unlikely to work on text terminals, however.

Not so. They work for me in emacs-28 running in an xterm within tmux. 

Best wishes,



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

* Re: POLL: make C-x o transient
  2021-01-25 17:01   ` Juri Linkov
  2021-01-25 17:21     ` Omar Polo
@ 2021-01-27 17:55     ` Juri Linkov
  2021-01-28  7:46       ` Philip K.
  2021-01-28  9:40       ` martin rudalics
  1 sibling, 2 replies; 74+ messages in thread
From: Juri Linkov @ 2021-01-27 17:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: condy0919@gmail.com, Zhiwei Chen, emacs-devel

>>> Which will make `C-x o` invoke a transient version of `other-window'
>>> like `text-scale-adjust’ does.
>>
>> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>
> And non-letters too, especially `C-x {`, `C-x }`, `C-x ^`, ...
> need to be repeatable.  I'm using such quite messy blob of code,
> it would be nice if someone would generalize this mess
> without using advice-add.

Maybe something simple like:

#+begin_src emacs-lisp
(put 'other-window 'repeatable-command t)
(put 'enlarge-window 'repeatable-command t)
(put 'enlarge-window-horizontally 'repeatable-command t)
(put 'shrink-window-horizontally 'repeatable-command t)

(add-hook 'post-command-hook 'repeatable-command)

(defun repeatable-command ()
  (when (get this-command 'repeatable-command)
    (let* ((keys (this-single-command-keys))
           (last-key (elt keys (1- (length keys)))))
      (set-transient-map
       (let ((map (make-sparse-keymap)))
         (define-key map (vector last-key) this-command)
         map)))))
#+end_src



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
                   ` (3 preceding siblings ...)
  2021-01-25 21:12 ` Sean Whitton
@ 2021-01-27 21:46 ` Gregory Heytings
  2021-01-31  7:06 ` Teemu Likonen
  2021-02-08  7:13 ` Jefferson Carpenter
  6 siblings, 0 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-01-27 21:46 UTC (permalink / raw)
  To: emacs-devel

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


>
> Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’ does.
>
> What benefits from this change:
> 1. Fewer keystrokes for multi windows navigation
> 2. Reduce the probability of RSI
> 3. Able to navigate windows backwards 
>

Note that in vanilla Emacs C-x z repeats the last command; C-x z z z... 
repeats it again and again.  It displays a message in the echo area 
"Repeating command <name of last command>".

You can also for example (global-set-key (kbd "C-z") 'repeat) to repeat 
any command with a single keystroke, in which case you can also change the 
prefix argument while repeating the command: C-x o C-z C-z C-- C-z 
executes (other-window 1) three times, then (other-window -1).

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

* Re: POLL: make C-x o transient
  2021-01-27 17:55     ` Juri Linkov
@ 2021-01-28  7:46       ` Philip K.
  2021-01-28  8:50         ` Juri Linkov
  2021-01-28  9:40       ` martin rudalics
  1 sibling, 1 reply; 74+ messages in thread
From: Philip K. @ 2021-01-28  7:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: condy0919@gmail.com, Stefan Monnier, Zhiwei Chen, emacs-devel

Juri Linkov <juri@linkov.net> writes:

>>>> Which will make `C-x o` invoke a transient version of `other-window'
>>>> like `text-scale-adjust’ does.
>>>
>>> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>>
>> And non-letters too, especially `C-x {`, `C-x }`, `C-x ^`, ...
>> need to be repeatable.  I'm using such quite messy blob of code,
>> it would be nice if someone would generalize this mess
>> without using advice-add.
>
> Maybe something simple like:
>
> #+begin_src emacs-lisp
> (put 'other-window 'repeatable-command t)
> (put 'enlarge-window 'repeatable-command t)
> (put 'enlarge-window-horizontally 'repeatable-command t)
> (put 'shrink-window-horizontally 'repeatable-command t)
>
> (add-hook 'post-command-hook 'repeatable-command)
>
> (defun repeatable-command ()
>   (when (get this-command 'repeatable-command)
>     (let* ((keys (this-single-command-keys))
>            (last-key (elt keys (1- (length keys)))))
>       (set-transient-map
>        (let ((map (make-sparse-keymap)))
>          (define-key map (vector last-key) this-command)
>          map)))))
> #+end_src

I like this idea, but would the hook be added by default?

-- 
	Philip K.



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

* Re: POLL: make C-x o transient
  2021-01-28  7:46       ` Philip K.
@ 2021-01-28  8:50         ` Juri Linkov
  0 siblings, 0 replies; 74+ messages in thread
From: Juri Linkov @ 2021-01-28  8:50 UTC (permalink / raw)
  To: Philip K.; +Cc: condy0919@gmail.com, Stefan Monnier, Zhiwei Chen, emacs-devel

>> Maybe something simple like:
>>
>> #+begin_src emacs-lisp
>> (put 'other-window 'repeatable-command t)
>> (put 'enlarge-window 'repeatable-command t)
>> (put 'enlarge-window-horizontally 'repeatable-command t)
>> (put 'shrink-window-horizontally 'repeatable-command t)
>>
>> (add-hook 'post-command-hook 'repeatable-command)
>
> I like this idea, but would the hook be added by default?

The comment in emacs/lisp/repeat.el says:

  ;; It would of course be trivial to implement last-prefix-arg &
  ;; true-last-command by putting something in post-command-hook, but that
  ;; entails a performance hit; the approach taken below avoids that.

so better to avoid the hook.



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

* Re: POLL: make C-x o transient
  2021-01-27 17:55     ` Juri Linkov
  2021-01-28  7:46       ` Philip K.
@ 2021-01-28  9:40       ` martin rudalics
  2021-01-28 18:43         ` Juri Linkov
  1 sibling, 1 reply; 74+ messages in thread
From: martin rudalics @ 2021-01-28  9:40 UTC (permalink / raw)
  To: Juri Linkov, Stefan Monnier; +Cc: condy0919@gmail.com, Zhiwei Chen, emacs-devel

 > Maybe something simple like:
 >
 > #+begin_src emacs-lisp
 > (put 'other-window 'repeatable-command t)

After having done one 'other-window' too many, how would I get easily
back to the previous window?

martin



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

* Re: POLL: make C-x o transient
  2021-01-28  9:40       ` martin rudalics
@ 2021-01-28 18:43         ` Juri Linkov
  2021-01-28 19:13           ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Juri Linkov @ 2021-01-28 18:43 UTC (permalink / raw)
  To: martin rudalics
  Cc: condy0919@gmail.com, Stefan Monnier, Zhiwei Chen, emacs-devel

>> Maybe something simple like:
>>
>> #+begin_src emacs-lisp
>> (put 'other-window 'repeatable-command t)
>
> After having done one 'other-window' too many, how would I get easily
> back to the previous window?

Just switch the direction by the prefix arg '-'.  Its handling could be
easily implemented.  It seems better to extend repeat.el to allow using
the last key of the last command, add handling of universal arguments,
and all this without using add-advice and hooks.



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

* Re: POLL: make C-x o transient
  2021-01-28 18:43         ` Juri Linkov
@ 2021-01-28 19:13           ` Gregory Heytings
  2021-01-28 20:34             ` Kévin Le Gouguec
                               ` (2 more replies)
  0 siblings, 3 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-01-28 19:13 UTC (permalink / raw)
  To: emacs-devel


>
> Just switch the direction by the prefix arg '-'.  Its handling could be 
> easily implemented.  It seems better to extend repeat.el to allow using 
> the last key of the last command, add handling of universal arguments, 
> and all this without using add-advice and hooks.
>

IMO it is would be much better to map the existing repeat command to a 
single keystroke, it would make any command repeatable without changing 
anything else, and it already handles universal arguments.  I think C-= 
would be the best key for this: not only is "=" a good mnemonic for "same 
command", but it is also next to the "-" key to change the direction.



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

* Re: POLL: make C-x o transient
  2021-01-28 19:13           ` Gregory Heytings
@ 2021-01-28 20:34             ` Kévin Le Gouguec
  2021-01-28 21:27               ` Gregory Heytings
  2021-01-28 21:58             ` Alan Mackenzie
  2021-01-29  2:38             ` chad
  2 siblings, 1 reply; 74+ messages in thread
From: Kévin Le Gouguec @ 2021-01-28 20:34 UTC (permalink / raw)
  To: emacs-devel

Gregory Heytings <gregory@heytings.org> writes:

> IMO it is would be much better to map the existing repeat command to a
> single keystroke, it would make any command repeatable without
> changing anything else, and it already handles universal arguments.  I
> think C-= would be the best key for this

FWIW, one of the reasons Zhiwei gave for his initial "C-x o o o…"
proposal was:

> 2. Reduce the probability of RSI

I'm assuming this would stem from having to hit Control less often.

Not that we couldn't have both a repeatable C-x o *and* bind C-= to
repeat; I merely want to point out that C-x o C-= wouldn't fully satisfy
the OP's requirements.




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

* Re: POLL: make C-x o transient
  2021-01-28 20:34             ` Kévin Le Gouguec
@ 2021-01-28 21:27               ` Gregory Heytings
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-01-28 21:27 UTC (permalink / raw)
  To: emacs-devel

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



>> IMO it is would be much better to map the existing repeat command to a 
>> single keystroke, it would make any command repeatable without changing 
>> anything else, and it already handles universal arguments.  I think C-= 
>> would be the best key for this
>
> FWIW, one of the reasons Zhiwei gave for his initial "C-x o o o…" 
> proposal was:
>
>> 2. Reduce the probability of RSI
>
> I'm assuming this would stem from having to hit Control less often.
>
> Not that we couldn't have both a repeatable C-x o *and* bind C-= to 
> repeat; I merely want to point out that C-x o C-= wouldn't fully satisfy 
> the OP's requirements.
>

IIUC, what the OP said is that hitting C-x o multiple times is painful, 
because it requires releasing and pressing the control key mutiple times. 
For example C-x o C-x o C-x o C-x o requires pressing and releasing the 
control key three times.  With C-= bound to "repeat", you could achieve 
the same effect with C-x o C-= C-= C-=, which requires releasing and 
pressing the control key only once.  You could also achieve the same 
effect with C-x o C-= C-= C-= C-= C-- C-=, which also requires releasing 
and pressing the control key only once.

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

* Re: POLL: make C-x o transient
  2021-01-28 19:13           ` Gregory Heytings
  2021-01-28 20:34             ` Kévin Le Gouguec
@ 2021-01-28 21:58             ` Alan Mackenzie
  2021-01-28 23:19               ` Philip K.
  2021-02-01 17:09               ` Yuan Fu
  2021-01-29  2:38             ` chad
  2 siblings, 2 replies; 74+ messages in thread
From: Alan Mackenzie @ 2021-01-28 21:58 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

Hello, Gregory.

On Thu, Jan 28, 2021 at 19:13:22 +0000, Gregory Heytings wrote:


> > Just switch the direction by the prefix arg '-'.  Its handling could be 
> > easily implemented.  It seems better to extend repeat.el to allow using 
> > the last key of the last command, add handling of universal arguments, 
> > and all this without using add-advice and hooks.

> IMO it is would be much better to map the existing repeat command to a 
> single keystroke, it would make any command repeatable without changing 
> anything else, and it already handles universal arguments.  I think C-= 
> would be the best key for this: not only is "=" a good mnemonic for "same 
> command", but it is also next to the "-" key to change the direction.

It depends entirely on your keyboard layout.  On a standard German
keyboard, for example, = is <shift>0, so C-= would mean pressing three
keys at the same time.  Also on the same keyboard, - and = are nowhere
near eachother.

Also, does C-= even exist on a typical tty layout?

Also[2], C-= is likely bound to many users' personal commands.

So I think I would be against using C-= for this command.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: POLL: make C-x o transient
  2021-01-28 21:58             ` Alan Mackenzie
@ 2021-01-28 23:19               ` Philip K.
  2021-01-29  0:03                 ` [External] : " Drew Adams
  2021-02-01 17:09               ` Yuan Fu
  1 sibling, 1 reply; 74+ messages in thread
From: Philip K. @ 2021-01-28 23:19 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Gregory Heytings, emacs-devel

Alan Mackenzie <acm@muc.de> writes:

> Hello, Gregory.
>
> On Thu, Jan 28, 2021 at 19:13:22 +0000, Gregory Heytings wrote:
>
>
>> > Just switch the direction by the prefix arg '-'.  Its handling could be 
>> > easily implemented.  It seems better to extend repeat.el to allow using 
>> > the last key of the last command, add handling of universal arguments, 
>> > and all this without using add-advice and hooks.
>
>> IMO it is would be much better to map the existing repeat command to a 
>> single keystroke, it would make any command repeatable without changing 
>> anything else, and it already handles universal arguments.  I think C-= 
>> would be the best key for this: not only is "=" a good mnemonic for "same 
>> command", but it is also next to the "-" key to change the direction.
>
> It depends entirely on your keyboard layout.  On a standard German
> keyboard, for example, = is <shift>0, so C-= would mean pressing three
> keys at the same time.  Also on the same keyboard, - and = are nowhere
> near eachother.
>
> Also, does C-= even exist on a typical tty layout?
>
> Also[2], C-= is likely bound to many users' personal commands.

I know of at least one (MELPA) package that recommend this key:

https://github.com/magnars/expand-region.el#expand-regionel--

So I'd agree that this is a reasonable objection.

> So I think I would be against using C-= for this command.

-- 
	Philip K.



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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-28 23:19               ` Philip K.
@ 2021-01-29  0:03                 ` Drew Adams
  2021-01-29  2:43                   ` chad
  2021-01-29  7:54                   ` Gregory Heytings
  0 siblings, 2 replies; 74+ messages in thread
From: Drew Adams @ 2021-01-29  0:03 UTC (permalink / raw)
  To: Philip K., Alan Mackenzie; +Cc: Gregory Heytings, emacs-devel

> > So I think I would be against using C-= for this command.
> I know of at least one (MELPA) package that recommend this key:
> So I'd agree that this is a reasonable objection.

FWIW, I use `C-=' as a prefix key for comparison commands:

 C-= b           ediff-buffers
 C-= d           diff
 C-= e .. C-= f  ediff-files
 C-= w           compare-windows-repeat

Please do NOT sacrifice ANY new key for what's proposed.

If the aim is "a transient version of `other-window'"
then just use `C-x o'.  Anyone who prefers the old,
non-repeatable version can rebind to that.

Why on earth would we want to sacrifice two keys by
default: one for repeatable `other-window' and one
for non-repeatable?

Now, if people can't agree to bind repeatable by
default, OK; no problem.  Or if we can't agree about
just what repeatable `other-window' should do, OK.

But default bindings for both repeatable and
non-repeatable would be a ridiculous waste (IMHO).
___

FWIW, there are other Emacs keys that could usefully
be made repeatable.  I.e., no need for new keys, just
replace the binding to the non-repeatable command by
a repeatable one.

E.g., I've long used repeatable `C-a' and `C-e'.
I wouldn't be without them.  `C-a' repeated just goes
to the end of the next line...  `C-e' repeated goes
to the beginning of the previous line...

Not a big deal.  But (IMHO) hugely useful.  Just as
useful, for example, as `C-n' and `C-p'.



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

* Re: POLL: make C-x o transient
  2021-01-28 19:13           ` Gregory Heytings
  2021-01-28 20:34             ` Kévin Le Gouguec
  2021-01-28 21:58             ` Alan Mackenzie
@ 2021-01-29  2:38             ` chad
  2021-01-29  8:44               ` Juri Linkov
  2 siblings, 1 reply; 74+ messages in thread
From: chad @ 2021-01-29  2:38 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

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

On Thu, Jan 28, 2021 at 11:16 AM Gregory Heytings <gregory@heytings.org>
wrote:

> > Just switch the direction by the prefix arg '-'.  Its handling could be
> > easily implemented.  It seems better to extend repeat.el to allow using
> > the last key of the last command, add handling of universal arguments,
> > and all this without using add-advice and hooks.
>
> IMO it is would be much better to map the existing repeat command to a
> single keystroke, it would make any command repeatable without changing
> anything else, and it already handles universal arguments.  I think C-=
> would be the best key for this: not only is "=" a good mnemonic for "same
> command", but it is also next to the "-" key to change the direction.
>

I played with a version of Juri's patch that bound "." to repeat the
repeatable command, and then tried to implement "," to that command passed
-1, but I had a little trouble getting it to DTRT, and then got sidetracked
by a version that used #'repeat instead of this-command.

I mention this mostly to say that the actual ui of last key/./, was pretty
nice in my testing.

~Chad

[-- Attachment #2: Type: text/html, Size: 1603 bytes --]

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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-29  0:03                 ` [External] : " Drew Adams
@ 2021-01-29  2:43                   ` chad
  2021-01-29 19:11                     ` Drew Adams
  2021-01-30  5:58                     ` Richard Stallman
  2021-01-29  7:54                   ` Gregory Heytings
  1 sibling, 2 replies; 74+ messages in thread
From: chad @ 2021-01-29  2:43 UTC (permalink / raw)
  To: Drew Adams; +Cc: Alan Mackenzie, Philip K., Gregory Heytings, emacs-devel

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

On Thu, Jan 28, 2021 at 4:03 PM Drew Adams <drew.adams@oracle.com> wrote:

> > > So I think I would be against using C-= for this command.
>
> Please do NOT sacrifice ANY new key for what's proposed.
>

I think there's a miscommunication here; the suggestion to bind C-= wasn't
(as I understand it) to bind it at the top level, but in the transient
keymap, as an addition (or perhaps alternative?) to "whatever key was hit
last", ala Juri's prototype.

Hope that helps,
~Chad

[-- Attachment #2: Type: text/html, Size: 874 bytes --]

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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-29  0:03                 ` [External] : " Drew Adams
  2021-01-29  2:43                   ` chad
@ 2021-01-29  7:54                   ` Gregory Heytings
  2021-01-29 13:45                     ` Stefan Monnier
  1 sibling, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-01-29  7:54 UTC (permalink / raw)
  To: emacs-devel


>
> Why on earth would we want to sacrifice two keys by default: one for 
> repeatable `other-window' and one for non-repeatable?
>
> [...]
>
> But default bindings for both repeatable and non-repeatable would be a 
> ridiculous waste (IMHO). to the beginning of the previous line...
>

My proposal is not to bind C-= to a repeatable other-window, which would 
indeed be ridiculous.

It is to bind C-= to the existing "repeat" command, which is already in 
Emacs, does what has been suggested in this thread (repeat the last 
command with its argument, display a message in echo area, and handle 
universal argument), but is I believe underused. It needs to be bound to a 
single keystroke to be used at its full power: otherwise it is not 
possible to change the prefix argument between two repeats.

I expected that this C-= binding would not please everyone, for example 
because some already bind it to another command. This would be the case 
with virtually any possible key binding. But it's only a default binding, 
and those who already use C-= for another purpose, or would not like that 
binding for one reason or another, can bind "repeat" to something else.



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

* Re: POLL: make C-x o transient
  2021-01-29  2:38             ` chad
@ 2021-01-29  8:44               ` Juri Linkov
  0 siblings, 0 replies; 74+ messages in thread
From: Juri Linkov @ 2021-01-29  8:44 UTC (permalink / raw)
  To: chad; +Cc: Gregory Heytings, emacs-devel

> I played with a version of Juri's patch that bound "." to repeat the
> repeatable command, and then tried to implement "," to that command passed -
> 1, but I had a little trouble getting it to DTRT, and then got sidetracked
> by a version that used #'repeat instead of this-command.

Clever idea.  It looks like you changed this line in my version:

         (define-key map (vector last-key) this-command)
to
         (define-key map "." 'repeat)

and it gives a wonderful result: typing 'C-- .' reverses the direction
of window navigation, so every next '.' traverses windows in the opposite
direction (then it's possible to change direction again with 'C-u .')



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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-29  7:54                   ` Gregory Heytings
@ 2021-01-29 13:45                     ` Stefan Monnier
  2021-01-29 16:56                       ` Óscar Fuentes
                                         ` (2 more replies)
  0 siblings, 3 replies; 74+ messages in thread
From: Stefan Monnier @ 2021-01-29 13:45 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

> It is to bind C-= to the existing "repeat" command, which is already in

FWIW, I agree that `repeat` deserves a single-key bindings.
But I don't think `C-=` can be it, and I don't have a counter-offer.

This said, I expect that all modal layers (viper, evil, god-mode, ...)
satisfy this desire.  That's one of the benefits of a modal structure:
it gives you more keys to bind ;-)


        Stefan




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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-29 13:45                     ` Stefan Monnier
@ 2021-01-29 16:56                       ` Óscar Fuentes
  2021-01-29 19:12                       ` Drew Adams
  2021-01-30 14:13                       ` Gregory Heytings
  2 siblings, 0 replies; 74+ messages in thread
From: Óscar Fuentes @ 2021-01-29 16:56 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It is to bind C-= to the existing "repeat" command, which is already in
>
> FWIW, I agree that `repeat` deserves a single-key bindings.
> But I don't think `C-=` can be it, and I don't have a counter-offer.
>
> This said, I expect that all modal layers (viper, evil, god-mode, ...)
> satisfy this desire.  That's one of the benefits of a modal structure:
> it gives you more keys to bind ;-)

I comment this in passing, just in case it is useful to someone:
key-chord.el opens lots of possibilities. For instance, I've just bound
,w to other-window:

(key-chord-define-global ",w" 'other-window)

With a bit of tinkering it could be expanded to use just one character
for repeating the command: ,w , , , ... or reversing: ,w w w w ... but
on this specific case ,w is good enough for my usage.

key-chord.el is great for avoiding RSI and for invoking commands really
fast.




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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-29  2:43                   ` chad
@ 2021-01-29 19:11                     ` Drew Adams
  2021-01-30  5:58                     ` Richard Stallman
  1 sibling, 0 replies; 74+ messages in thread
From: Drew Adams @ 2021-01-29 19:11 UTC (permalink / raw)
  To: chad; +Cc: Alan Mackenzie, Philip K., Gregory Heytings, emacs-devel

> > > So I think I would be against using C-= for this command.
> >
> > Please do NOT sacrifice ANY new key for what's proposed.
>
> I think there's a miscommunication here; the suggestion
> to bind C-= wasn't (as I understand it) to bind it at
> the top level, but in the transient keymap, as an addition
> (or perhaps alternative?) to "whatever key was hit last",
> ala Juri's prototype.
>
> Hope that helps

My bad in that case.  Sorry for the noise.


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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-29 13:45                     ` Stefan Monnier
  2021-01-29 16:56                       ` Óscar Fuentes
@ 2021-01-29 19:12                       ` Drew Adams
  2021-01-30 14:13                         ` Gregory Heytings
  2021-01-30 14:13                       ` Gregory Heytings
  2 siblings, 1 reply; 74+ messages in thread
From: Drew Adams @ 2021-01-29 19:12 UTC (permalink / raw)
  To: Stefan Monnier, Gregory Heytings; +Cc: emacs-devel

> > It is to bind C-= to the existing "repeat" command, 
> 
> FWIW, I agree that `repeat` deserves a single-key bindings.
> But I don't think `C-=` can be it, and I don't have a counter-offer.

I'm probably going to be an outlier on this,
as well.

1. Why is it important to save one keystroke,
just to initiate repetition?

What's important is to be able to repeat
using a simple, single keystroke.  But to
initiate repetition it's not important to
use a single keystroke (IMO).

I don't like to see keys get appropriated
by Emacs as defaults.  I think that `C-x z'
is a fine way to initiate repetition.  I
don't want to see any new key, `C-=' or
another, "wasted" this way.

2. That said, for _specific commands_,
which are already bound to keys, I think
it's very helpful for some such commands
to themselves be repeatable.

That's different from a general key to
repeat the last command (now `C-x z').


A priori therefore, my vote is for:

1. Keeping the general repeat-last-whatever
   on a prefix key.  IOW, stick with `C-x z'
   or similar.

2. Make more single-use commands, themselves,
   repeatable.  That is, commands that are
   already bound by default.

   I gave, as one example, repeatable `C-a'
   and `C-e'.

Doing that wastes/dedicates no additional
keys by default.



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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-29  2:43                   ` chad
  2021-01-29 19:11                     ` Drew Adams
@ 2021-01-30  5:58                     ` Richard Stallman
  2021-02-01 19:50                       ` chad
  1 sibling, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-01-30  5:58 UTC (permalink / raw)
  To: chad; +Cc: acm, philipk, gregory, drew.adams, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I think there's a miscommunication here; the suggestion to bind C-= wasn't
  > (as I understand it) to bind it at the top level, but in the transient
  > keymap, as an addition (or perhaps alternative?) to "whatever key was hit
  > last", ala Juri's prototype.

What is the benefit of that?

The purpose of these "easy repeat" commands is so that you can repeat the
command without moving your fingers.  If you need to move your fingers to C-=,
why bother?

BTW, c-= does not exists on ttys.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-01-29 13:45                     ` Stefan Monnier
  2021-01-29 16:56                       ` Óscar Fuentes
  2021-01-29 19:12                       ` Drew Adams
@ 2021-01-30 14:13                       ` Gregory Heytings
  2 siblings, 0 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-01-30 14:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel


>> It is to bind C-= to the existing "repeat" command, which is already in 
>> Emacs
>
> FWIW, I agree that `repeat` deserves a single-key bindings. But I don't 
> think `C-=` can be it, and I don't have a counter-offer.
>

What are the available options?  If it is required to use a key binding 
that works both in GUI and TUI interfaces (as RMS mentioned), I fear it's 
an impossible problem.

Unless of course there is an agreement to remap one of the existing keys, 
for example C-z (also available on C-x C-z), C-o or C-t (which are perhaps 
less useful than a "repeat" command, and less useful than other commands 
(I at least never use them)).  But such an agreement is highly unlikely.

Without the requirement of compatibility with TUI interfaces, the 
available key bindings are the non-letters C-! C-# C-$ C-% C-^ C-& C-* C-( 
C-) C-= C-+ C-| C-; C-: C-' C-" C-, C-< C-. and C->.  Among them it seems 
to me that C-= is a reasonable choice.

>
> This said, I expect that all modal layers (viper, evil, god-mode, ...) 
> satisfy this desire.  That's one of the benefits of a modal structure: 
> it gives you more keys to bind ;-)
>

Indeed, but the majority of Emacs users don't want a modal structure, 
otherwise they would not use Emacs ;-)  And a single-key "repeat" would 
give Emacs a minimal modal-like structure.



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

* Re: POLL: make C-x o transient
  2021-01-29 19:12                       ` Drew Adams
@ 2021-01-30 14:13                         ` Gregory Heytings
  2021-01-30 20:47                           ` [External] : " Drew Adams
  0 siblings, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-01-30 14:13 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel


>>> It is to bind C-= to the existing "repeat" command,
>>
>> FWIW, I agree that `repeat` deserves a single-key bindings.
>> But I don't think `C-=` can be it, and I don't have a counter-offer.
>
> 1. Why is it important to save one keystroke, just to initiate 
> repetition?
>
> What's important is to be able to repeat using a simple, single 
> keystroke.  But to initiate repetition it's not important to use a 
> single keystroke (IMO).
>

As I already said twice, it is important because otherwise you cannot 
change the prefix argument between two repetitions, which is a very useful 
(it not necessary) feature for a repeat command.  Suppose you have repeat 
bound on C-=.  Say you have ten frames, you want to switch to another one, 
you type C-x 5 o C-= C-= C-= C-= C-= C-=, and you realize that you pressed 
'=' once too much: you just have to type C-- C-=, without even releasing 
the control modifier, and you're in the frame you wanted.

Another reason (mentioned by Sean Whitton) is that repeating with the last 
key of a keystroke leads to commands being called when what you want to do 
is to type the character.  With what you suggest, say you have two windows 
side-by-side, you want to shrink the current window a bit, you type C-u 
C-x {, and you now want to type '{': you have to remind that you need to 
quit the transient keymap with C-g before typing '{'.

>
> 2. That said, for _specific commands_, which are already bound to keys, 
> I think it's very helpful for some such commands to themselves be 
> repeatable.
>

That requires a lot more changes: it is necessary to adapt each individual 
command, including user-defined commands, to make it repeatable.



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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-30 14:13                         ` Gregory Heytings
@ 2021-01-30 20:47                           ` Drew Adams
  2021-01-31  1:06                             ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Drew Adams @ 2021-01-30 20:47 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

> >>> It is to bind C-= to the existing "repeat" command,
> >>
> >> FWIW, I agree that `repeat` deserves a single-key bindings.
> >> But I don't think `C-=` can be it, and I don't have a counter-offer.
> >
> > 1. Why is it important to save one keystroke, just
> >    to initiate repetition?
> >
> > What's important is to be able to repeat using a simple,
> > single keystroke.  But to initiate repetition it's not
> > important to use a single keystroke (IMO).
> 
> As I already said twice, it is important because otherwise you cannot
> change the prefix argument between two repetitions, which is a very
> useful (i[f] not necessary) feature for a repeat command.

Indeed, as you admit, that's _not_ a necessary feature
for a repeatable command.  And that use case is certainly
(IMO) no justification for dedicating a new default key
binding.  I don't consider it an "important" reason for
sacrificing a repeatable key by default.

Anyone, or any library, that _really_ needs, in some
particular case, to be able to optionally use a prefix
arg on _only some_ particular repetitions can do what's
needed for that.

This (for me) is about _not wasting keys_: not having
Emacs needlessly appropriate more keys for default
bindings.

If you dedicate a repeatable key such as `C-=' for a
NON-repeatable action such as this -- and INITIATING
repetition of the last command is a NON-repeatable
action -- you're wasting the chance for that key to
be used for a repeatable action.

The _much_ more common use case for a repeatable
command is to be able to use the same prefix arg
for each repetition - i.e., pass the prefix arg
at the beginning.

And that use case is satisfied, I assume, by your
definition using transient.  At least it should be.

It's satisfied currently by `C-x z':
`C-2 M-f C-x z z z...' moves forward two words at
each repetition.

If your definition of repeatable commands using
transient doesn't do that yet (I haven't checked)
it should.

And if for some reason it can't, that functionality
is easily provided for any non-repeatable command
by a repeatable-command-defining function such as this:

(defun my-repeat-command (command)
  "Repeat COMMAND."
  (require 'repeat)
  (let ((repeat-previous-repeated-command  command)
        (repeat-message-function           #'ignore)
        (last-repeatable-command           'repeat))
    (repeat nil)))

(defun foo (arg)
  (interactive "P")
  <whatever>
  ...)

;; Repeat `foo', passing it prefix-arg ARG.
(defun foo-repeatable (arg)
  (interactive "P")
  (my-repeat-command 'foo))

[The msg that started this thread used `set-transient-map'
to do the same kind of thing.  The original proposal, which
I applauded, was just to bind `C-x o' to a repeatable
version of `other-window', so `C-x o o o...'.]

> Another reason (mentioned by Sean Whitton) is that repeating with the
> last key of a keystroke leads to commands being called when what you want to
> do is to type the character.... [Y]ou have to remind that you need to
> quit the transient keymap with C-g before typing '{'.

Nah.
That's just pilot error - not being used to it yet.

That's no different from ending Isearch.  You type
{ thinking you'll insert { in the buffer.  But since
you're still isearching it's instead added to the
search string.

That's a minor gotcha that's easily, unconsciously,
learned and overcome.

> > 2. That said, for _specific commands_, which are
> >    already bound to keys, I think it's very helpful
> >    for some such commands to themselves be repeatable.
> 
> That requires a lot more changes: it is necessary to adapt each
> individual command, including user-defined commands, to make it repeatable.

I think I was clear that it's NOT either/or:

 * EITHER (1) provide a general key to repeat any action
   (which we already have with `C-x z', and which you
   want to put on a new single keystroke, e.g. `C-=')

 * OR (2) replace some non-repeatable commands currently
   bound to keys by repeatable versions of them.

You're trying to change my statement that, (1) when
useful for some particular commands, they can be made
repeatable and kept on their existing keys, into (2)
a supposed need to do that for all commands.

I'm not in favor of needlessly sacrificing more keys,
by default.  Not even one - for this.  `C-x z' is fine.
It's superior to `C-=' because it's not a repeatable
key (and `C-=' is).  And any particular repeatable
command that needs/merits a single keystroke can be
bound by anyone.

My point there was about non-repeatable commands
_already_ bound to repeatable keys.  It's a waste for
a key such as `C-e' to be bound to a non-repeatable
command - it could just as easily be bound to a
repeatable version of the same action.  That's all.

I'd much sooner just hold down Control and repeat `e'
(i.e., `C-e C-e...'), or even use `C-e C-x z z...',
than use either `C-e C-= C-= C-=...' (which I think
you proposed?) or `C-e C-= e e...'.

Replacing `C-x z' by `C-=' -- or by any other single
key -- gains nothing (AFAICS).  The act of initiating
repetition of the preceding action is NOT itself
a repeatable action.  That just wastes a repeatable
key, `C-=', for a non-repeatable action.



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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-30 20:47                           ` [External] : " Drew Adams
@ 2021-01-31  1:06                             ` Gregory Heytings
  2021-01-31 17:39                               ` Drew Adams
  0 siblings, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-01-31  1:06 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel


>>> Why is it important to save one keystroke, just to initiate 
>>> repetition?
>>>
>>> What's important is to be able to repeat using a simple, single 
>>> keystroke.  But to initiate repetition it's not important to use a 
>>> single keystroke (IMO).
>>
>> As I already said twice, it is important because otherwise you cannot 
>> change the prefix argument between two repetitions, which is a very 
>> useful (i[f] not necessary) feature for a repeat command.
>
> Indeed, as you admit, that's _not_ a necessary feature for a repeatable 
> command.
>

That's not what I said.  Of course it's not a logical necessity, but not 
having that feature stops users from using the "repeat" command at its 
full power.

>
> The _much_ more common use case for a repeatable command is to be able 
> to use the same prefix arg for each repetition - i.e., pass the prefix 
> arg at the beginning.
>
> [...]
>
> Replacing `C-x z' by `C-=' -- or by any other single key -- gains 
> nothing (AFAICS).
>

I understand that you believe that having the possibility to change the 
argument between two repetitions is useless.  But it is in essence what 
the OP asked: he wanted both other-window _and_ other-window-backward, not 
just a repeatable other-window.  Other examples given in this thread were 
similar, and IMO show that it would be a very useful feature.



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
                   ` (4 preceding siblings ...)
  2021-01-27 21:46 ` Gregory Heytings
@ 2021-01-31  7:06 ` Teemu Likonen
  2021-01-31 17:32   ` [External] : " Drew Adams
                     ` (2 more replies)
  2021-02-08  7:13 ` Jefferson Carpenter
  6 siblings, 3 replies; 74+ messages in thread
From: Teemu Likonen @ 2021-01-31  7:06 UTC (permalink / raw)
  To: Zhiwei Chen, emacs-devel; +Cc: condy, emacs-devel

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

* 2021-01-24 06:12:09+0000, Zhiwei Chen wrote:

> Which will make `C-x o` invoke a transient version of `other-window'
> like `text-scale-adjust’ does.

I would really like to have "C-x o o o o" feature to cycle through
frame's windows. I think one cycling direction is enough because frames
don't usually have large number of windows. On the other hand even "C-x
o o" is much nicer than "C-x o C-x o".

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-31  7:06 ` Teemu Likonen
@ 2021-01-31 17:32   ` Drew Adams
  2021-01-31 17:49     ` Alan Mackenzie
  2021-01-31 18:10   ` Howard Melman
  2021-02-01 17:21   ` Juri Linkov
  2 siblings, 1 reply; 74+ messages in thread
From: Drew Adams @ 2021-01-31 17:32 UTC (permalink / raw)
  To: Teemu Likonen, Zhiwei Chen, emacs-devel@gnu.org
  Cc: condy, emacs-devel@gnu.org

> > Which will make `C-x o` invoke a transient version of
> > `other-window' like `text-scale-adjust’ does.
> 
> I would really like to have "C-x o o o o" feature to cycle through
> frame's windows. I think one cycling direction is enough because frames
> don't usually have large number of windows. On the other hand even "C-x
> o o" is much nicer than "C-x o C-x o".

Agreed.  We should bind a _repeatable_ version
of `other-window' to `C-x o'.

And we should consider doing likewise for
other non-repeatable commands where it makes
sense: give their existing bindings to
repeatable versions.

(You can of course already, today, use
`C-x o C-x z z z z...'.  Not a big difference
from `C-x o o o o o': Just add a `C-x' and
repeat `z' instead of `o'.)


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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-31  1:06                             ` Gregory Heytings
@ 2021-01-31 17:39                               ` Drew Adams
  2021-01-31 23:12                                 ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Drew Adams @ 2021-01-31 17:39 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

> > > a very useful (i[f] not necessary) feature...
                     ^^^^^^^^^^^^^^^^^^

> > Indeed, as you admit, that's _not_ a necessary
> > feature for a repeatable command.
> 
> That's not what I said. 

Sure seems to be what you said: your claim was that
it's "very useful", but "not necessary".

> > The _much_ more common use case for a repeatable
> > command is to be able to use the same prefix arg
> > for each repetition - i.e., pass the prefix arg
> > at the beginning. ...
>
> > Replacing `C-x z' by `C-=' -- or by any other
> > single key -- gains nothing (AFAICS).
> 
> I understand that you believe that having the
> possibility to change the argument between two
> repetitions is useless.

You may understand that, but that's not what I said,
at all.

I said it's not a common use case.  I said the much
more common case is providing a prefix arg once (e.g.
to the key that initiates repetition of some other
command), and having it apply to _each_ repetition.

More importantly, I pointed out that nothing is
gained by replacing `C-x z' by `C-='.  Whatever key
sequence is bound to a command that _initiates_
repetition, is _NOT_ bound to a repeatable command.

A single, repeatable key such as `C-=' is better
saved (for users or for Emacs someday) to bind to a
repeatable command.

> But it is in essence what the OP asked: he wanted
> both other-window _and_ other-window-backward,
> not just a repeatable other-window.

The typical case is that Emacs already has a command
for doing something forward, and another command for
doing it backward.  Making each of those repeatable
solves the same "problem".  I mentioned the case of
`C-a' and `C-e' - just switch to the other key to
switch direction.

The case that initiated this, `other-window', does
not have any reverse-direction partner.  Instead, a
negative prefix arg reverses direction.  (But there
are ways to accommodate that, if it's important.)

Even without changing anything it's not _difficult_
to reverse direction:

`C-x o C-x z z... C-- C-x o C-x z z...

Or define `other-window-back` and bind repeatable
versions of `other-window' and `other-window-back'
to different repeatable keys (like the case of
`C-a' and `C-e').  But as Teemu pointed out, the
use case for cycling backward isn't very strong
(for the reason he gave).

Lots of things are possible.

But again, my _main point_ was about not wasting a
repeatable key (e.g. `C-=') for a NON-repeatable
command (`repeat').

It may not have been obvious to some (and so far,
you haven't acknowledged this deficiency in your
argument in favor of `C-=' as a replacement for
`C-x z') that command `repeat' (now`C-x z') is
NOT a repeatable command.

One doesn't bind that command to a key that you
can just hold down to repeat some action.  Its
action is only to _initiate_ the use of some
other command in a repeatable way.



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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-31 17:32   ` [External] : " Drew Adams
@ 2021-01-31 17:49     ` Alan Mackenzie
  2021-01-31 18:37       ` Drew Adams
  0 siblings, 1 reply; 74+ messages in thread
From: Alan Mackenzie @ 2021-01-31 17:49 UTC (permalink / raw)
  To: Drew Adams; +Cc: condy, Zhiwei Chen, emacs-devel@gnu.org

Hello, Drew.

On Sun, Jan 31, 2021 at 17:32:48 +0000, Drew Adams wrote:
> > > Which will make `C-x o` invoke a transient version of
> > > `other-window' like `text-scale-adjust’ does.

> > I would really like to have "C-x o o o o" feature to cycle through
> > frame's windows. I think one cycling direction is enough because frames
> > don't usually have large number of windows. On the other hand even "C-x
> > o o" is much nicer than "C-x o C-x o".

> Agreed.  We should bind a _repeatable_ version
> of `other-window' to `C-x o'.

I personally find even one C-x o to be an annoyance.  So I've bound
other-window to F12.  (My other Fn keys are for switching to frame Fn.)

> And we should consider doing likewise for
> other non-repeatable commands where it makes
> sense: give their existing bindings to
> repeatable versions.

> (You can of course already, today, use
> `C-x o C-x z z z z...'.  Not a big difference
> from `C-x o o o o o': Just add a `C-x' and
> repeat `z' instead of `o'.)

That's not a small difference, either.  I think most repeated commands
are going to be repeated a small number of times, like once, or possibly
twice.  C-x o C-x z isn't saving anything over C-x o C-x o.  By the time
you're up to C-x o C-x z z z z, you've probably already reached for the
mouse and clicked in the target window.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: POLL: make C-x o transient
  2021-01-31  7:06 ` Teemu Likonen
  2021-01-31 17:32   ` [External] : " Drew Adams
@ 2021-01-31 18:10   ` Howard Melman
  2021-02-01 17:21   ` Juri Linkov
  2 siblings, 0 replies; 74+ messages in thread
From: Howard Melman @ 2021-01-31 18:10 UTC (permalink / raw)
  To: emacs-devel

Teemu Likonen <tlikonen@iki.fi> writes:

>> Which will make `C-x o` invoke a transient version of `other-window'
>> like `text-scale-adjust’ does.
>
> I would really like to have "C-x o o o o" feature to cycle through
> frame's windows. I think one cycling direction is enough because frames
> don't usually have large number of windows. On the other hand even "C-x
> o o" is much nicer than "C-x o C-x o".

For those that don't know about it, I use ace-window to
solve this problem.  You can configure it to work like
other-window with a small number of windows but when there
are more, it puts a label in each window with a unique key
that allows O(1) direct access to select that window.  It can
work within a frame or across all frames.  There are more
advanced features to allow deletion and other window
changes. 

-- 

Howard




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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-31 17:49     ` Alan Mackenzie
@ 2021-01-31 18:37       ` Drew Adams
  0 siblings, 0 replies; 74+ messages in thread
From: Drew Adams @ 2021-01-31 18:37 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: condy, Zhiwei Chen, emacs-devel@gnu.org

> > Agreed.  We should bind a _repeatable_ version
> > of `other-window' to `C-x o'.
> 
> I personally find even one C-x o to be an annoyance.  So I've bound
> other-window to F12.  (My other Fn keys are for switching to frame Fn.)

Exactly.  Easy to do, for anyone.

But does Emacs itself need to sacrifice a
repeatable key for that?  We already have `C-x o'.

> I think most repeated commands are going to be
> repeated a small number of times, like once, or
> possibly twice.

That's a different topic (though I realize you
were thinking of it in this context).  For that
general topic, I think no, not so.  Repetition
of a command by holding a key is variable -
depends on the command.  There are some commands
for which multiple, even many, repetitions are
not uncommon.

Those are "incremental" commands, such as cursor
motion or moving something other than the cursor.
Think of repeated `C-n', `C-s', or even `C-x C--',
for example.

(And yes, in such cases, at least for text, there
are often other, coarser-grained or structural
commands, which can be used instead.  But many
users nevertheless persist in leaning on a key.)

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

* Re: POLL: make C-x o transient
  2021-01-31 17:39                               ` Drew Adams
@ 2021-01-31 23:12                                 ` Gregory Heytings
  2021-01-31 23:53                                   ` [External] : " Drew Adams
  2021-02-01  6:11                                   ` Richard Stallman
  0 siblings, 2 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-01-31 23:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel


>
> I pointed out that nothing is gained by replacing `C-x z' by `C-='.
>

Once again: what is gained is the possibility to change the command 
argument between two repetitions of a command, without typing the command 
again and without even releasing the control key.  This is not "nothing". 
Remember that the OP wanted to "reduce the probability of RSI", by 
minimizing key presses and releases.

To be more explicit, what is gained is something of the simplicity of a 
modal structure: for example, you type C-x ` for next-error once, after 
which you navigate forwards and backwards through the errors without 
releasing the control key.  And likewise for C-x o, C-x 5 o, C-x ], C-x {, 
C-x ^, and so forth.

>
> But again, my _main point_ was about not wasting a repeatable key (e.g. 
> `C-=') for a NON-repeatable command (`repeat').
>
> It may not have been obvious to some (and so far, you haven't 
> acknowledged this deficiency in your argument in favor of `C-=' as a 
> replacement for `C-x z') that command `repeat' (now`C-x z') is NOT a 
> repeatable command.
>

I did not comment that point indeed, because IMO you are reasoning with a 
false postulate: "the command repeat is not a repeatable command".  I 
don't know how you define "repeatable command", but for me a "repeatable 
command" is a command that has a new effect each time it is executed, and 
a "non-repeatable command" is a command that has the same effect 
regardless of the number of times it is executed (a mathematician would 
perhaps say that it is an idempotent command).  An example of a repeatable 
command is "next-line", an example of a non-repeatable command is 
"move-end-of-line".  Therefore it seems to me that "repeat" is a 
repeatable command: each time it is executed, it executes the previous 
command once more.



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

* RE: [External] : Re: POLL: make C-x o transient
  2021-01-31 23:12                                 ` Gregory Heytings
@ 2021-01-31 23:53                                   ` Drew Adams
  2021-02-01  6:11                                   ` Richard Stallman
  1 sibling, 0 replies; 74+ messages in thread
From: Drew Adams @ 2021-01-31 23:53 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel

> what is gained is the possibility to change the command
> argument between two repetitions of a command, without
> typing the command again and without even releasing the
> control key.
...
> you are reasoning with a false postulate: "the command
> `repeat' is not a repeatable command".

Yes, sorry, you are correct in both cases.
My bad.  I mistakenly expected `repeat' to
behave the same way it does when bound to
`C-x z'.







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

* Re: POLL: make C-x o transient
  2021-01-31 23:12                                 ` Gregory Heytings
  2021-01-31 23:53                                   ` [External] : " Drew Adams
@ 2021-02-01  6:11                                   ` Richard Stallman
  1 sibling, 0 replies; 74+ messages in thread
From: Richard Stallman @ 2021-02-01  6:11 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: drew.adams, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I have not been following the details of this, but I have a general
point to make.

The reason one-key repeat features are worth their weight in
complexity is because repeating some commands is very common,
so the savings of reducing it to one key is much appreciated.

Invoking the command again with different arguments is not so common,
and the reduction in keystrokes is not so much.  I think it is not
worth its weight.  At least, not for the default command bindings.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-01-28 21:58             ` Alan Mackenzie
  2021-01-28 23:19               ` Philip K.
@ 2021-02-01 17:09               ` Yuan Fu
  1 sibling, 0 replies; 74+ messages in thread
From: Yuan Fu @ 2021-02-01 17:09 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Gregory Heytings, emacs-devel


> 在 2021年1月28日,下午4:59,Alan Mackenzie <acm@muc.de> 写道:
> 
> Hello, Gregory.
> 
> On Thu, Jan 28, 2021 at 19:13:22 +0000, Gregory Heytings wrote:
> 
> 
>>> Just switch the direction by the prefix arg '-'.  Its handling could be 
>>> easily implemented.  It seems better to extend repeat.el to allow using 
>>> the last key of the last command, add handling of universal arguments, 
>>> and all this without using add-advice and hooks.
> 
>> IMO it is would be much better to map the existing repeat command to a 
>> single keystroke, it would make any command repeatable without changing 
>> anything else, and it already handles universal arguments.  I think C-= 
>> would be the best key for this: not only is "=" a good mnemonic for "same 
>> command", but it is also next to the "-" key to change the direction.
> 
> It depends entirely on your keyboard layout.  On a standard German
> keyboard, for example, = is <shift>0, so C-= would mean pressing three
> keys at the same time.  Also on the same keyboard, - and = are nowhere
> near eachother.
> 
> Also, does C-= even exist on a typical tty layout?

No, you need special handling to recognize C-= on tty.

Yuan


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

* Re: POLL: make C-x o transient
  2021-01-31  7:06 ` Teemu Likonen
  2021-01-31 17:32   ` [External] : " Drew Adams
  2021-01-31 18:10   ` Howard Melman
@ 2021-02-01 17:21   ` Juri Linkov
  2021-02-02 19:44     ` Sean Whitton
  2 siblings, 1 reply; 74+ messages in thread
From: Juri Linkov @ 2021-02-01 17:21 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: condy, Zhiwei Chen, emacs-devel

> I would really like to have "C-x o o o o" feature to cycle through
> frame's windows. I think one cycling direction is enough because frames
> don't usually have large number of windows. On the other hand even "C-x
> o o" is much nicer than "C-x o C-x o".

Repeating the last character is the most convenient way to repeat the command,
indeed.  No other key combination would be equally easy to type.  For example,
when there is a need to navigate next-error locations with 'M-g n M-g n ...'
changing the modifier key in 'M-g n C-=' won't do it better than just
'M-g n n n ...'

But since typing a self-inserting key is ambiguous, and sometimes requires
typing another key to break the key sequence to insert the character,
this means that such feature should be optional.

In this case it's easy to implement it as a minor mode that uses hooks,
e.g. last-char-repeatable-mode added to repeat.el.

This could be like delete-selection-mode that by default
puts a special property on symbols of affected commands.



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

* Re: [External] : Re: POLL: make C-x o transient
  2021-01-30  5:58                     ` Richard Stallman
@ 2021-02-01 19:50                       ` chad
  2021-02-02 21:11                         ` Gregory Heytings
  2021-02-03  5:51                         ` [External] : " Richard Stallman
  0 siblings, 2 replies; 74+ messages in thread
From: chad @ 2021-02-01 19:50 UTC (permalink / raw)
  To: Richard Stallman
  Cc: Alan Mackenzie, Philip K., Gregory Heytings, Drew Adams,
	EMACS development team

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

On Fri, Jan 29, 2021 at 9:58 PM Richard Stallman <rms@gnu.org> wrote:

>   > I think there's a miscommunication here; the suggestion to bind C-=
> wasn't
>   > (as I understand it) to bind it at the top level, but in the transient
>   > keymap, as an addition (or perhaps alternative?) to "whatever key was
> hit
>   > last", ala Juri's prototype.
>
> What is the benefit of that?
>
> The purpose of these "easy repeat" commands is so that you can repeat the
> command without moving your fingers.  If you need to move your fingers to
> C-=,
> why bother?
>

I think the conversation has moved a bit, so I'm attempting to close the
loop here. Apologies if it gets confusing with varying communications
delays.

I'm talking about the idea of adding a small number of extra bindings
inside the transient keymap of certain repeatable commands, as marked by
the user. (There is a parallel proposal to perhaps make #'repeat more
useful by moving it's binding; that's related but not exactly what I'm
talking about here -- This is a big part of what I mean by "closing the
loop".)

The benefit is to increase the options beyond just "I want to do exactly
what I just did, again, a small number of times" to "I just did something
that I'll want to adjust via a probably-small number of repetitions and
(potentially repeated) inversions".

For the case of other-window, the use-case is hunting quickly through a lot
of windows, including allowing for a low-cost overshoot. For the various
enlarge-window functions, it lets people iterate towards the desired size
and evaluate at each step whether they like the current result, or want to
tweak it up or down. (Personal aside: At various points in my life, I have
done this inside Emacs *a lot*, although modern relatively-giant displays
might make it less valuable in practice.)

These bindings would be added to the transient keymap in addition to the
last key hit (ala Juri's prototype or something similar), and would, at a
low opportunity cost enable both "do that very last press again to repeat"
and "standardized - and thus learnable - bindings for iterate-forward and
iterate-backward".

I suggested (and experimented with) adding "."/"," for
#'repeat/#'repeat-inverse, and found it pretty pleasant. I haven't shared
my exact prototype because it was a tiny change to Juri's except for
#'repeat-inverse, which I didn't get entirely functional before I shifted
my attention to other projects. Gregory suggested "C-=" as a potential
binding with the benefit that it falls right next to "C--" for inverting,
on US/UK keyboard layouts. (There is a parallel discussion about binding
"C-=" to #'repeat at the top level, which is interesting but has some
logistical issues, and is a separate proproal.)

I hope this helps,
~Chad

[-- Attachment #2: Type: text/html, Size: 3479 bytes --]

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

* Re: POLL: make C-x o transient
  2021-02-01 17:21   ` Juri Linkov
@ 2021-02-02 19:44     ` Sean Whitton
  2021-02-03 17:20       ` Juri Linkov
  0 siblings, 1 reply; 74+ messages in thread
From: Sean Whitton @ 2021-02-02 19:44 UTC (permalink / raw)
  To: Juri Linkov, Teemu Likonen; +Cc: condy, Zhiwei Chen, emacs-devel

Hello,

On Mon 01 Feb 2021 at 07:21PM +02, Juri Linkov wrote:

>> I would really like to have "C-x o o o o" feature to cycle through
>> frame's windows. I think one cycling direction is enough because frames
>> don't usually have large number of windows. On the other hand even "C-x
>> o o" is much nicer than "C-x o C-x o".
>
> Repeating the last character is the most convenient way to repeat the command,
> indeed.  No other key combination would be equally easy to type.  For example,
> when there is a need to navigate next-error locations with 'M-g n M-g n ...'
> changing the modifier key in 'M-g n C-=' won't do it better than just
> 'M-g n n n ...'
>
> But since typing a self-inserting key is ambiguous, and sometimes requires
> typing another key to break the key sequence to insert the character,
> this means that such feature should be optional.
>
> In this case it's easy to implement it as a minor mode that uses hooks,
> e.g. last-char-repeatable-mode added to repeat.el.
>
> This could be like delete-selection-mode that by default
> puts a special property on symbols of affected commands.

I think this is the best way to implement this.  People who don't want
to accept getting into transient states where not every self-insert key
is self-inserting can turn the mode off entirely (and maybe bind 'repeat
to C-z or something, which is what I do), and people who haven't had
problems with that can turn it on once and have it work all over.

-- 
Sean Whitton



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

* Re: POLL: make C-x o transient
  2021-02-01 19:50                       ` chad
@ 2021-02-02 21:11                         ` Gregory Heytings
  2021-02-05  5:48                           ` Richard Stallman
  2021-02-03  5:51                         ` [External] : " Richard Stallman
  1 sibling, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-02-02 21:11 UTC (permalink / raw)
  To: chad; +Cc: emacs-devel

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


> 
> Gregory suggested "C-=" as a potential binding with the benefit that it 
> falls right next to "C--" for inverting, on US/UK keyboard layouts.
>

My C-= suggestion was not for transient keymaps, it was for the global 
map.  Using C-= in transient keymaps does not make sense, as RMS said.

>
> (There is a parallel discussion about binding "C-=" to #'repeat at the 
> top level, which is interesting but has some logistical issues, and is a 
> separate proproal.)
>

It is not a parallel discussion, it is an attempt to solve the OP's 
problem in a different, more general, and IMO simpler, way.  In short, the 
two competing approaches to solve the OP's problem are:

1. For each command that should become repeatable, define a transient 
keymap that is activated when the command has completed, with keys to 
repeat that command or its "opposite".  Which keys should be used for that 
purpose is not clear: the last key and its shifted version (for example 
"o" and "O"), or "." and ",", or the last key its corresponding opposite 
command key (for example "n" and "p" after "M-g"), or...

2. Create a unified way to repeat the last command with its argument (à la 
"." command in Vi), by binding the existing "repeat" command to a single 
key binding, for example "C-=".  With this it also becomes possible to 
change the argument between two repetitions, possibly to something 
different than "opposite".  No command must be changed.

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

* Re: [External] : Re: POLL: make C-x o transient
  2021-02-01 19:50                       ` chad
  2021-02-02 21:11                         ` Gregory Heytings
@ 2021-02-03  5:51                         ` Richard Stallman
  2021-02-03 20:38                           ` chad
  1 sibling, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-02-03  5:51 UTC (permalink / raw)
  To: chad; +Cc: acm, philipk, gregory, drew.adams, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

The more different keys have a special meaning after a repeating
command, the more they will get in the way.  The more things there
will be to worry about.

What would I want to do after switching windows?  Insert a period or a
comma, perhaps.  Why wouldn't it be that?

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-02-02 19:44     ` Sean Whitton
@ 2021-02-03 17:20       ` Juri Linkov
  0 siblings, 0 replies; 74+ messages in thread
From: Juri Linkov @ 2021-02-03 17:20 UTC (permalink / raw)
  To: Sean Whitton; +Cc: condy, Zhiwei Chen, emacs-devel

>> In this case it's easy to implement it as a minor mode that uses hooks,
>> e.g. last-char-repeatable-mode added to repeat.el.
>>
>> This could be like delete-selection-mode that by default
>> puts a special property on symbols of affected commands.
>
> I think this is the best way to implement this.  People who don't want
> to accept getting into transient states where not every self-insert key
> is self-inserting can turn the mode off entirely (and maybe bind 'repeat
> to C-z or something, which is what I do), and people who haven't had
> problems with that can turn it on once and have it work all over.

As Gregory noted, it's not clear which keys to use in every case:
for 'C-x o' it makes sense to use the shifted version "O" too,
for 'M-g n' also to use the opposite key "p".

It's possible to solve this by attaching own transient map
to each repeatable command like:

(put 'other-window 'repeat-map 'other-window-repeat-map)

(defvar other-window-repeat-map
  (let ((map (make-sparse-keymap)))
    (define-key map "o" 'other-window)
    (define-key map "O" (lambda () (interactive) (other-window -1)))
    map)
  "Keymap to navigate windows.")

(put 'next-error 'repeat-map 'next-error-repeat-map)
(put 'previous-error 'repeat-map 'next-error-repeat-map)

(defvar next-error-repeat-map
  (let ((map (make-sparse-keymap)))
    (define-key map "n" 'next-error)
    (define-key map "p" 'previous-error)
    map)
  "Keymap to navigate errors.")



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

* Re: [External] : Re: POLL: make C-x o transient
  2021-02-03  5:51                         ` [External] : " Richard Stallman
@ 2021-02-03 20:38                           ` chad
  2021-02-04  5:44                             ` Richard Stallman
  0 siblings, 1 reply; 74+ messages in thread
From: chad @ 2021-02-03 20:38 UTC (permalink / raw)
  To: Richard Stallman
  Cc: Alan Mackenzie, Philip K., Gregory Heytings, Drew Adams,
	EMACS development team

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

On Tue, Feb 2, 2021 at 9:51 PM Richard Stallman <rms@gnu.org> wrote:

>
> The more different keys have a special meaning after a repeating
> command, the more they will get in the way.  The more things there
> will be to worry about.
>

This sounds like a potential case of a general impression conflicting with
specific experience.

What would I want to do after switching windows?  Insert a period or a
> comma, perhaps.  Why wouldn't it be that?
>

You can look at your own usage after C-x o (even more telling for people
who aren't using the mouse or mostly dedicated frames) with view-lossage or
via  dribble file, but for me, the answer is "because the cursor is hardly
ever in the right spot", even though I do use save-place. I would hazard a
guess that wanting to immediately insert a period or comma is roughly the
same order of commonality as wanting to insert an 'o' (or 'O').

For me, the more interesting transient-repeat opportunity is C-x ^ for
enlarge-window, which I nearly always followed with cursor movement,
recentering, or scrolling commands (and never with period, comma, or
caret), but that's from a relatively small sample, because I've been using
a custom function to adjust window sizes for the past 20 years or so.

Hope that helps,
~Chad

[-- Attachment #2: Type: text/html, Size: 1877 bytes --]

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

* Re: [External] : Re: POLL: make C-x o transient
  2021-02-03 20:38                           ` chad
@ 2021-02-04  5:44                             ` Richard Stallman
  2021-02-04 19:24                               ` chad
  0 siblings, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-02-04  5:44 UTC (permalink / raw)
  To: chad; +Cc: acm, philipk, gregory, drew.adams, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > You can look at your own usage after C-x o (even more telling for people
  > who aren't using the mouse or mostly dedicated frames) with view-lossage or
  > via  dribble file, but for me, the answer is "because the cursor is hardly
  > ever in the right spot", even though I do use save-place. I would hazard a
  > guess that wanting to immediately insert a period or comma is roughly the
  > same order of commonality as wanting to insert an 'o' (or 'O').

That seems plausible to me, and that supports my point: each
self-inserting key that we give a special meaning to after C-x o is
one additional nuisance.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: [External] : Re: POLL: make C-x o transient
  2021-02-04  5:44                             ` Richard Stallman
@ 2021-02-04 19:24                               ` chad
  0 siblings, 0 replies; 74+ messages in thread
From: chad @ 2021-02-04 19:24 UTC (permalink / raw)
  To: Richard Stallman
  Cc: Alan Mackenzie, Philip K., Gregory Heytings, Drew Adams,
	EMACS development team

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

On Wed, Feb 3, 2021 at 9:44 PM Richard Stallman <rms@gnu.org> wrote:

>   > You can look at your own usage after C-x o (even more telling for
> people
>   > who aren't using the mouse or mostly dedicated frames) with
> view-lossage or
>   > via  dribble file, but for me, the answer is "because the cursor is
> hardly
>   > ever in the right spot", even though I do use save-place. I would
> hazard a
>   > guess that wanting to immediately insert a period or comma is roughly
> the
>   > same order of commonality as wanting to insert an 'o' (or 'O').
>
> That seems plausible to me, and that supports my point: each
> self-inserting key that we give a special meaning to after C-x o is
> one additional nuisance.
>

MY own read on it, which continues to be true as my dribble file grows, is
that I almost never want self-inserting keys after C-x o; I'm doing cursor
movement or window manipulation (including isearch and recenter) the _vast_
majority of the time.

I guess that some people want to quickly check something in another buffer
before switching back and inserting characters where they left, which gives
it a potential of up to half of the time, but from what I can tell, more
people these days are doing that sort of pop-out/pop-back via methods that
create and then close the outside reference (via tool categories like grep,
xref, and eldoc), and most people used to newer tools instead use a
completion framework or LSP.

All in all, something like Juri's prototype where users can opt commands
into using a standardized (and thus learnable) repeatable framework would
be an improvement for the vast majority of users who became aware of it, in
large part because it's easily opt-in at a granular level. (For example,
easily enabled for changing window sizes without impacting C-x o.)

~Chad

[-- Attachment #2: Type: text/html, Size: 2288 bytes --]

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

* Re: POLL: make C-x o transient
  2021-02-02 21:11                         ` Gregory Heytings
@ 2021-02-05  5:48                           ` Richard Stallman
  2021-02-05  8:37                             ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Richard Stallman @ 2021-02-05  5:48 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: yandros, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > 2. Create a unified way to repeat the last command with its argument (à la 
  > "." command in Vi), by binding the existing "repeat" command to a single 
  > key binding, for example "C-=".  With this it also becomes possible to 
  > change the argument between two repetitions, possibly to something 
  > different than "opposite".  No command must be changed.

Is that different from C-x z?

It could be another binding for C-x z.  Perhaps C-= is moreconvenient.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

* Re: POLL: make C-x o transient
  2021-02-05  5:48                           ` Richard Stallman
@ 2021-02-05  8:37                             ` Gregory Heytings
  2021-02-05  8:58                               ` Juri Linkov
  0 siblings, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-02-05  8:37 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

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


>> 2. Create a unified way to repeat the last command with its argument (à 
>> la "." command in Vi), by binding the existing "repeat" command to a 
>> single key binding, for example "C-=".  With this it also becomes 
>> possible to change the argument between two repetitions, possibly to 
>> something different than "opposite".  No command must be changed.
>
> Is that different from C-x z?
>
> It could be another binding for C-x z.  Perhaps C-= is moreconvenient.
>

It is different indeed.  The OP's problem was to minimize key presses and 
releases to "reduce the probability of RSI".  With C-= bound to repeat, 
you can change the command argument between two repetitions of a command, 
without typing the command again and without even releasing the control 
key.  You cannot do that with C-x z.

An example: calling (other-window 1) four times followed by (other-window 
-1) one time requires:

C-x o C-x z z z C-- C-x z : nine keys pressed, control key pressed and 
released three times

C-x o C-= C-= C-= C-- C-= : seven keys pressed, control key pressed twice 
and released pressed only once

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

* Re: POLL: make C-x o transient
  2021-02-05  8:37                             ` Gregory Heytings
@ 2021-02-05  8:58                               ` Juri Linkov
  2021-02-05  9:34                                 ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Juri Linkov @ 2021-02-05  8:58 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Richard Stallman, emacs-devel

> An example: calling (other-window 1) four times followed by
> (other-window -1) one time requires:
>
> C-x o C-x z z z C-- C-x z : nine keys pressed, control key pressed and
> released three times
>
> C-x o C-= C-= C-= C-- C-= : seven keys pressed, control key pressed twice
> and released pressed only once

This needs to be compared also with the last letter typed:

C-x o o o o O : six keys pressed, control key pressed once
and released pressed once



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

* Re: POLL: make C-x o transient
  2021-02-05  8:58                               ` Juri Linkov
@ 2021-02-05  9:34                                 ` Gregory Heytings
  2021-02-06 19:25                                   ` Juri Linkov
  0 siblings, 1 reply; 74+ messages in thread
From: Gregory Heytings @ 2021-02-05  9:34 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Richard Stallman, emacs-devel


>> An example: calling (other-window 1) four times followed by 
>> (other-window -1) one time requires:
>>
>> C-x o C-x z z z C-- C-x z : nine keys pressed, control key pressed and 
>> released three times
>>
>> C-x o C-= C-= C-= C-- C-= : seven keys pressed, control key pressed 
>> twice and released pressed only once
>
> This needs to be compared also with the last letter typed:
>
> C-x o o o o O : six keys pressed, control key pressed once and released 
> pressed once
>

... and shift key pressed and released once.

... and possibly pressing C-g to exit the transient keymap.

That solution has a number of limits:

1. it is not general, you have to define specific keys for each case

2. the keys that are bound are not self-inserting anymore, you may have to 
exit the transient keymap manually with C-g

3. there are even cases where this is not possible to use it, for example, 
how would you repeat C-x C-t?

4. you cannot freely change the argument between two repetitions



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

* Re: POLL: make C-x o transient
  2021-02-05  9:34                                 ` Gregory Heytings
@ 2021-02-06 19:25                                   ` Juri Linkov
  2021-02-06 20:27                                     ` Gregory Heytings
  0 siblings, 1 reply; 74+ messages in thread
From: Juri Linkov @ 2021-02-06 19:25 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Richard Stallman, emacs-devel

>>> C-x o C-x z z z C-- C-x z : nine keys pressed, control key pressed and
>>> released three times
>>>
>>> C-x o C-= C-= C-= C-- C-= : seven keys pressed, control key pressed
>>> twice and released pressed only once
>>
>> This needs to be compared also with the last letter typed:
>>
>> C-x o o o o O : six keys pressed, control key pressed once and released
>> pressed once
>
> ... and shift key pressed and released once.

True (unless an unshifted key is bound for going to the previous window).

> ... and possibly pressing C-g to exit the transient keymap.

True (no way to avoid this design flaw).

> That solution has a number of limits:
>
> 1. it is not general, you have to define specific keys for each case
>
> 2. the keys that are bound are not self-inserting anymore, you may have to
> exit the transient keymap manually with C-g
>
> 3. there are even cases where this is not possible to use it, for example,
> how would you repeat C-x C-t?

Either by repeating the last char 'C-t', or using a custom transient keymap
with more keys.

> 4. you cannot freely change the argument between two repetitions

Why not?  C-x o O should be equivalent to C-x o C-- o.



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

* Re: POLL: make C-x o transient
  2021-02-06 19:25                                   ` Juri Linkov
@ 2021-02-06 20:27                                     ` Gregory Heytings
  2021-02-06 21:30                                       ` Stefan Monnier
  2021-02-07 18:54                                       ` Juri Linkov
  0 siblings, 2 replies; 74+ messages in thread
From: Gregory Heytings @ 2021-02-06 20:27 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Richard Stallman, emacs-devel


>> 3. there are even cases where this is not possible to use it, for 
>> example, how would you repeat C-x C-t?
>
> Either by repeating the last char 'C-t', or using a custom transient 
> keymap with more keys.
>

Don't you agree that both solutions feel just wrong?

>> 4. you cannot freely change the argument between two repetitions
>
> Why not?  C-x o O should be equivalent to C-x o C-- o.
>

It isn't, when you type C-- between two repetitions you have to type the 
command again.  With "C-- o" you get an error "Negative repetition 
argument -1".



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

* Re: POLL: make C-x o transient
  2021-02-06 20:27                                     ` Gregory Heytings
@ 2021-02-06 21:30                                       ` Stefan Monnier
  2021-02-06 23:22                                         ` Ergus via Emacs development discussions.
  2021-02-07 18:54                                       ` Juri Linkov
  1 sibling, 1 reply; 74+ messages in thread
From: Stefan Monnier @ 2021-02-06 21:30 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: emacs-devel, Richard Stallman, Juri Linkov

[ I'm mostly staying out of this conversion, but I'd just like to
  clarify a detail: ]

> It isn't, when you type C-- between two repetitions you have to type the
> command again.

That doesn't have to be the case: you can add the universal prefix keys
(like C-u, etc...) to the transient map or tweak the `keep-pred`
argument so as not to exit the transient map just because of
a prefix command.


        Stefan




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

* Re: POLL: make C-x o transient
  2021-02-06 21:30                                       ` Stefan Monnier
@ 2021-02-06 23:22                                         ` Ergus via Emacs development discussions.
  0 siblings, 0 replies; 74+ messages in thread
From: Ergus via Emacs development discussions. @ 2021-02-06 23:22 UTC (permalink / raw)
  To: emacs-devel, Stefan Monnier, Gregory Heytings
  Cc: Richard Stallman, Juri Linkov

There is a package Compostable.el that brings a similar experience for editing commands.

https://github.com/paldepind/composable.el

The experience is much better and interesting. I have it since long time ago.

Also the readme explains the concepts and corner cases very clearly. so that could be extrapolated to other commands without reinventing the wheel.

On February 6, 2021 10:30:52 PM GMT+01:00, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>[ I'm mostly staying out of this conversion, but I'd just like to
>  clarify a detail: ]
>
>> It isn't, when you type C-- between two repetitions you have to type
>the
>> command again.
>
>That doesn't have to be the case: you can add the universal prefix keys
>(like C-u, etc...) to the transient map or tweak the `keep-pred`
>argument so as not to exit the transient map just because of
>a prefix command.
>
>
>        Stefan

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



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

* Re: POLL: make C-x o transient
  2021-02-06 20:27                                     ` Gregory Heytings
  2021-02-06 21:30                                       ` Stefan Monnier
@ 2021-02-07 18:54                                       ` Juri Linkov
  1 sibling, 0 replies; 74+ messages in thread
From: Juri Linkov @ 2021-02-07 18:54 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Richard Stallman, emacs-devel

>>> 3. there are even cases where this is not possible to use it, for
>>> example, how would you repeat C-x C-t?
>>
>> Either by repeating the last char 'C-t', or using a custom transient
>> keymap with more keys.
>
> Don't you agree that both solutions feel just wrong?

Repeating the last char of every command would be very wrong indeed.

Using a custom transient keymap for the limited number of commands
(at least, for C-x o o and M-g n n) would be a nice opt-in feature.



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

* Re: POLL: make C-x o transient
  2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
                   ` (5 preceding siblings ...)
  2021-01-31  7:06 ` Teemu Likonen
@ 2021-02-08  7:13 ` Jefferson Carpenter
  2021-02-09  6:05   ` Richard Stallman
  6 siblings, 1 reply; 74+ messages in thread
From: Jefferson Carpenter @ 2021-02-08  7:13 UTC (permalink / raw)
  To: emacs-devel

On 1/24/2021 6:12 AM, Zhiwei Chen wrote:
> Which will make `C-x o` invoke a transient version of `other-window' like `text-scale-adjust’ does.
> 
> What benefits from this change:
> 1. Fewer keystrokes for multi windows navigation
> 2. Reduce the probability of RSI
> 3. Able to navigate windows backwards
> 

I'm using a completely different solution.  Using switch-window 
(https://github.com/dimitri/switch-window) with switch-window-threshold 
2 (reverts to other-window if only 1 or 2 windows are open)

The way it ends up working for more than 2 windows open is

+------+-------+
| [1]  |   2   |
|      |       |
+------+-------+
| 3    |   4   |
|      |       |
+------+-------+

C-x o
+------+-------+
| 1111 | 2222  |
| 1111 | 2222  |
+------+-------+
| 3333 | 4444  |
| 3333 | 4444  |
+------+-------+

3

+------+-------+
| 1    |   2   |
|      |       |
+------+-------+
| [3]  |   4   |
|      |       |
+------+-------+


So if more than 2 windows are open, C-x o replaces the window text with 
a large number and I press the number of the window I want to go to.

thanks,
Jefferson



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

* Re: POLL: make C-x o transient
  2021-02-08  7:13 ` Jefferson Carpenter
@ 2021-02-09  6:05   ` Richard Stallman
  0 siblings, 0 replies; 74+ messages in thread
From: Richard Stallman @ 2021-02-09  6:05 UTC (permalink / raw)
  To: Jefferson Carpenter; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I'm using a completely different solution.  Using switch-window 
  > (https://github.com/dimitri/switch-window) with switch-window-threshold 
  > 2 (reverts to other-window if only 1 or 2 windows are open)

It looks good to me.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





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

end of thread, other threads:[~2021-02-09  6:05 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24  6:12 POLL: make C-x o transient Zhiwei Chen
2021-01-24 11:32 ` Kévin Le Gouguec
2021-01-24 14:40   ` andrés ramírez
2021-01-25  5:52 ` Richard Stallman
2021-01-25 12:21   ` Zhiwei Chen
2021-01-26  6:02     ` Richard Stallman
2021-01-25 14:39 ` Stefan Monnier
2021-01-25 15:30   ` aitor
2021-01-25 16:38     ` Philip K.
2021-01-25 17:23     ` Colin Baxter
2021-01-26  5:59     ` Richard Stallman
2021-01-26 10:44       ` Olivier Certner
2021-01-26 23:38         ` Sean Whitton
2021-01-27  6:51           ` Colin Baxter
2021-01-25 15:47   ` [External] : " Drew Adams
2021-01-25 17:01   ` Juri Linkov
2021-01-25 17:21     ` Omar Polo
2021-01-27 17:55     ` Juri Linkov
2021-01-28  7:46       ` Philip K.
2021-01-28  8:50         ` Juri Linkov
2021-01-28  9:40       ` martin rudalics
2021-01-28 18:43         ` Juri Linkov
2021-01-28 19:13           ` Gregory Heytings
2021-01-28 20:34             ` Kévin Le Gouguec
2021-01-28 21:27               ` Gregory Heytings
2021-01-28 21:58             ` Alan Mackenzie
2021-01-28 23:19               ` Philip K.
2021-01-29  0:03                 ` [External] : " Drew Adams
2021-01-29  2:43                   ` chad
2021-01-29 19:11                     ` Drew Adams
2021-01-30  5:58                     ` Richard Stallman
2021-02-01 19:50                       ` chad
2021-02-02 21:11                         ` Gregory Heytings
2021-02-05  5:48                           ` Richard Stallman
2021-02-05  8:37                             ` Gregory Heytings
2021-02-05  8:58                               ` Juri Linkov
2021-02-05  9:34                                 ` Gregory Heytings
2021-02-06 19:25                                   ` Juri Linkov
2021-02-06 20:27                                     ` Gregory Heytings
2021-02-06 21:30                                       ` Stefan Monnier
2021-02-06 23:22                                         ` Ergus via Emacs development discussions.
2021-02-07 18:54                                       ` Juri Linkov
2021-02-03  5:51                         ` [External] : " Richard Stallman
2021-02-03 20:38                           ` chad
2021-02-04  5:44                             ` Richard Stallman
2021-02-04 19:24                               ` chad
2021-01-29  7:54                   ` Gregory Heytings
2021-01-29 13:45                     ` Stefan Monnier
2021-01-29 16:56                       ` Óscar Fuentes
2021-01-29 19:12                       ` Drew Adams
2021-01-30 14:13                         ` Gregory Heytings
2021-01-30 20:47                           ` [External] : " Drew Adams
2021-01-31  1:06                             ` Gregory Heytings
2021-01-31 17:39                               ` Drew Adams
2021-01-31 23:12                                 ` Gregory Heytings
2021-01-31 23:53                                   ` [External] : " Drew Adams
2021-02-01  6:11                                   ` Richard Stallman
2021-01-30 14:13                       ` Gregory Heytings
2021-02-01 17:09               ` Yuan Fu
2021-01-29  2:38             ` chad
2021-01-29  8:44               ` Juri Linkov
2021-01-25 17:27   ` Jose E. Marchesi
2021-01-25 21:12 ` Sean Whitton
2021-01-27 21:46 ` Gregory Heytings
2021-01-31  7:06 ` Teemu Likonen
2021-01-31 17:32   ` [External] : " Drew Adams
2021-01-31 17:49     ` Alan Mackenzie
2021-01-31 18:37       ` Drew Adams
2021-01-31 18:10   ` Howard Melman
2021-02-01 17:21   ` Juri Linkov
2021-02-02 19:44     ` Sean Whitton
2021-02-03 17:20       ` Juri Linkov
2021-02-08  7:13 ` Jefferson Carpenter
2021-02-09  6:05   ` Richard Stallman

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