unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
@ 2019-09-25 21:24 Jefferson Carpenter
  2019-09-26  7:12 ` Eli Zaretskii
  2019-09-26  7:20 ` martin rudalics
  0 siblings, 2 replies; 28+ messages in thread
From: Jefferson Carpenter @ 2019-09-25 21:24 UTC (permalink / raw)
  To: 37514


[-- Attachment #1.1: Type: text/plain, Size: 634 bytes --]

A not-uncommon workflow of mine is to have more than one window looking at the same buffer in several different places.  Often in one of these windows I switch to some other buffer (perhaps a shell) and then want to switch directly back to the same place I was just looking at in main buffer.  However since my main buffer is already visible in another window, C-x b (switch-to-buffer) does not default to that buffer, but prefers a buffer that is not already visible.  This customization setting allows users to override that behavior so that switch-to-buffer does not prefer buffers that are not already visible.



Jefferson

[-- Attachment #1.2: Type: text/html, Size: 2399 bytes --]

[-- Attachment #2: 0001-Add-setting-to-allow-switching-to-an-already-visible.patch --]
[-- Type: application/octet-stream, Size: 1613 bytes --]

From 65ad2d664f6667200d7edadaba3a9acdec60c7ff Mon Sep 17 00:00:00 2001
From: Jefferson Carpenter <jefferson.carpenter@transunion.com>
Date: Wed, 25 Sep 2019 16:03:49 -0500
Subject: [PATCH] Add setting to allow switching to an already-visible buffer
 by default

---
 lisp/window.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/window.el b/lisp/window.el
index 620eacdd29..13009ee5ee 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8158,6 +8158,13 @@ currently selected window; otherwise it will be displayed in
 another window."
   (pop-to-buffer buffer display-buffer--same-window-action norecord))
 
+(defcustom switch-to-buffer-visible-ok nil
+  "If non-nil, switch-to-buffer interactive prompt does not
+  prefer non-visible buffers."
+  :type 'boolean
+  :initialize 'custom-initialize-default
+  :group 'windows)
+
 (defun read-buffer-to-switch (prompt)
   "Read the name of a buffer to switch to, prompting with PROMPT.
 Return the name of the buffer as a string.
@@ -8178,7 +8185,8 @@ from the list of completions and default values."
               (set (make-local-variable 'icomplete-with-completion-tables)
                    (cons rbts-completion-table
                          icomplete-with-completion-tables))))
-      (read-buffer prompt (other-buffer (current-buffer))
+      (read-buffer prompt (other-buffer (current-buffer)
+                                        switch-to-buffer-visible-ok)
                    (confirm-nonexistent-file-or-buffer)))))
 
 (defun window-normalize-buffer-to-switch-to (buffer-or-name)
-- 
2.20.1 (Apple Git-117)


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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-25 21:24 bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default Jefferson Carpenter
@ 2019-09-26  7:12 ` Eli Zaretskii
  2019-09-26 19:13   ` Jefferson Carpenter
  2019-09-26  7:20 ` martin rudalics
  1 sibling, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2019-09-26  7:12 UTC (permalink / raw)
  To: Jefferson Carpenter; +Cc: 37514

> Date: Wed, 25 Sep 2019 21:24:45 +0000
> From: Jefferson Carpenter <jefferson@aoeu2code.com>
> 
> A not-uncommon workflow of mine is to have more than one window looking at the same buffer in several
> different places.  Often in one of these windows I switch to some other buffer (perhaps a shell) and then want
> to switch directly back to the same place I was just looking at in main buffer.  However since my main buffer is
> already visible in another window, C-x b (switch-to-buffer) does not default to that buffer, but prefers a buffer
> that is not already visible.  This customization setting allows users to override that behavior so that
> switch-to-buffer does not prefer buffers that are not already visible.

Why is it important what "C-x b" offers as the default?  You can still
type the name of the buffer you want and switch to it.

FWIW, I use the workflow you mention from time to time, and I never
felt the need for such an option, because its effect will be global on
the entire session, and I don't want it everywhere.  I'd need to reset
such an option when I go back to the other workflows, which would be a
nuisance.

And if the above is somehow still not satisfactory, you can always
write a trivial wrapper around switch-to-buffer, which behaves the way
you like.  Why do we need to canonicalize this in Emacs?

Thanks.





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-25 21:24 bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default Jefferson Carpenter
  2019-09-26  7:12 ` Eli Zaretskii
@ 2019-09-26  7:20 ` martin rudalics
  1 sibling, 0 replies; 28+ messages in thread
From: martin rudalics @ 2019-09-26  7:20 UTC (permalink / raw)
  To: Jefferson Carpenter, 37514

 > A not-uncommon workflow of mine is to have more than one window
 > looking at the same buffer in several different places.  Often in
 > one of these windows I switch to some other buffer (perhaps a shell)
 > and then want to switch directly back to the same place I was just
 > looking at in main buffer.  However since my main buffer is already
 > visible in another window, C-x b (switch-to-buffer) does not default
 > to that buffer, but prefers a buffer that is not already visible.
 > This customization setting allows users to override that behavior so
 > that switch-to-buffer does not prefer buffers that are not already
 > visible.

Wouldn't 'quit-window' accomplish that without any prompting?  Or
'switch-to-prev-buffer'?

Thanks, martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-26  7:12 ` Eli Zaretskii
@ 2019-09-26 19:13   ` Jefferson Carpenter
  2019-09-26 19:14     ` Jefferson Carpenter
  2019-09-27  8:16     ` martin rudalics
  0 siblings, 2 replies; 28+ messages in thread
From: Jefferson Carpenter @ 2019-09-26 19:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37514

---- On Thu, 26 Sep 2019 07:12:23 +0000 Eli Zaretskii <eliz@gnu.org> wrote ----

 >  
 > Why is it important what "C-x b" offers as the default?  You can still 
 > type the name of the buffer you want and switch to it. 

Because it requires fewer key strokes.

 >  
 > FWIW, I use the workflow you mention from time to time, and I never 
 > felt the need for such an option, because its effect will be global on 
 > the entire session, and I don't want it everywhere.  I'd need to reset 
 > such an option when I go back to the other workflows, which would be a 
 > nuisance. 

 >  
 > And if the above is somehow still not satisfactory, you can always 
 > write a trivial wrapper around switch-to-buffer, which behaves the way 
 > you like.  Why do we need to canonicalize this in Emacs? 

Because IMHO, emacs (and any software) should do as little as possible by default, or at least easily allow itself to be configured to do as little as possible.  I think it makes the most sense that switch-to-buffer takes you back to the last buffer you were visiting by default, without doing the extra work of preferring buffers that are not currently visible.


---- On Thu, 26 Sep 2019 07:20:53 +0000 martin rudalics <rudalics@gmx.at> wrote ----

 >  
 > Wouldn't 'quit-window' accomplish that without any prompting?  Or 
 > 'switch-to-prev-buffer'? 
 >  
 > Thanks, martin 
 > 

No, quit-window buries the buffer that you leave, even though it switches directly to the previous buffer on the top of the buffer list, and so it cannot be used to alternate back and fourth.  Switch-to-prev-buffer seems to do the same thing - executing it twice does not return you to the buffer you started at.  Besides, using these functions would require adding an extra key in addition to 'C-x b', and keys are at a premium.






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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-26 19:13   ` Jefferson Carpenter
@ 2019-09-26 19:14     ` Jefferson Carpenter
  2019-09-27  8:16     ` martin rudalics
  1 sibling, 0 replies; 28+ messages in thread
From: Jefferson Carpenter @ 2019-09-26 19:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37514

+bug-gnu-emacs

---- On Thu, 26 Sep 2019 19:13:08 +0000 Jefferson Carpenter <jefferson@aoeu2code.com> wrote ----

 > ---- On Thu, 26 Sep 2019 07:12:23 +0000 Eli Zaretskii <eliz@gnu.org> wrote ---- 
 >  
 >  > 
 >  > Why is it important what "C-x b" offers as the default?  You can still 
 >  > type the name of the buffer you want and switch to it. 
 >  
 > Because it requires fewer key strokes. 
 >  
 >  > 
 >  > FWIW, I use the workflow you mention from time to time, and I never 
 >  > felt the need for such an option, because its effect will be global on 
 >  > the entire session, and I don't want it everywhere.  I'd need to reset 
 >  > such an option when I go back to the other workflows, which would be a 
 >  > nuisance. 
 >  
 >  > 
 >  > And if the above is somehow still not satisfactory, you can always 
 >  > write a trivial wrapper around switch-to-buffer, which behaves the way 
 >  > you like.  Why do we need to canonicalize this in Emacs? 
 >  
 > Because IMHO, emacs (and any software) should do as little as possible by default, or at least easily allow itself to be configured to do as little as possible.  I think it makes the most sense that switch-to-buffer takes you back to the last buffer you were visiting by default, without doing the extra work of preferring buffers that are not currently visible. 
 >  
 >  
 > ---- On Thu, 26 Sep 2019 07:20:53 +0000 martin rudalics <rudalics@gmx.at> wrote ---- 
 >  
 >  > 
 >  > Wouldn't 'quit-window' accomplish that without any prompting?  Or 
 >  > 'switch-to-prev-buffer'? 
 >  > 
 >  > Thanks, martin 
 >  > 
 >  
 > No, quit-window buries the buffer that you leave, even though it switches directly to the previous buffer on the top of the buffer list, and so it cannot be used to alternate back and fourth.  Switch-to-prev-buffer seems to do the same thing - executing it twice does not return you to the buffer you started at.  Besides, using these functions would require adding an extra key in addition to 'C-x b', and keys are at a premium. 
 > 







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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-26 19:13   ` Jefferson Carpenter
  2019-09-26 19:14     ` Jefferson Carpenter
@ 2019-09-27  8:16     ` martin rudalics
  2019-09-28 21:00       ` Jefferson Carpenter
  2019-10-07  4:25       ` Lars Ingebrigtsen
  1 sibling, 2 replies; 28+ messages in thread
From: martin rudalics @ 2019-09-27  8:16 UTC (permalink / raw)
  To: Jefferson Carpenter, Eli Zaretskii; +Cc: 37514

 > No, quit-window buries the buffer that you leave, even though it
 > switches directly to the previous buffer on the top of the buffer
 > list, and so it cannot be used to alternate back and fourth.

In your initial post you did not mention that you wanted "to alternate
back and fourth".  'quit-window' gets you out of nested invocations of
'display-buffer', so it's indeed not suitable.

 > Switch-to-prev-buffer seems to do the same thing - executing it
 > twice does not return you to the buffer you started at.

'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
commands for navigating a specific window's buffer list (here these
are bound to <M-left> and <M-right> because I don't care for word-like
movement).

So if we want to convince people that C-x b is at least as convenient
for this purpose - and we have to do that when we add such an option,
mention it in NEWS, add manual entries for it and ask people to notice
all that - you should tell why the above commands are so inconvenient
for navigating the buffer list.

 > Besides,
 > using these functions would require adding an extra key in addition
 > to 'C-x b', and keys are at a premium.

This could be an argument.  Then we probably should find a few users
here (I never use C-x b because I find that prompt far too annoying)
supporting it.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-27  8:16     ` martin rudalics
@ 2019-09-28 21:00       ` Jefferson Carpenter
  2019-10-02  3:36         ` Jefferson Carpenter
  2019-10-07  4:25       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 28+ messages in thread
From: Jefferson Carpenter @ 2019-09-28 21:00 UTC (permalink / raw)
  To: martin rudalics, Eli Zaretskii; +Cc: 37514

On 9/27/2019 8:16 AM, martin rudalics wrote:

>  > Switch-to-prev-buffer seems to do the same thing - executing it
>  > twice does not return you to the buffer you started at.
> 
> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
> commands for navigating a specific window's buffer list (here these
> are bound to <M-left> and <M-right> because I don't care for word-like
> movement).

Those are not suitable either because they would require a multiplicity 
of key bindings.






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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-28 21:00       ` Jefferson Carpenter
@ 2019-10-02  3:36         ` Jefferson Carpenter
  2019-10-02  8:54           ` martin rudalics
  0 siblings, 1 reply; 28+ messages in thread
From: Jefferson Carpenter @ 2019-10-02  3:36 UTC (permalink / raw)
  To: martin rudalics, Eli Zaretskii; +Cc: 37514

> On 9/27/2019 8:16 AM, martin rudalics wrote:
> 
>>  > Switch-to-prev-buffer seems to do the same thing - executing it
>>  > twice does not return you to the buffer you started at.
>>
>> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
>> commands for navigating a specific window's buffer list (here these
>> are bound to <M-left> and <M-right> because I don't care for word-like
>> movement).
> 

Adding a single additional key might sound reasonable, but here you're 
asking me to add two additional keys to my global bindings when a 
two-character code change would make it unneeded (+" t").  The patch I 
attached to the original email just adds a customization setting to make 
that a more general option.







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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-02  3:36         ` Jefferson Carpenter
@ 2019-10-02  8:54           ` martin rudalics
  2019-10-04  0:45             ` Jefferson Carpenter
  2020-01-20 19:35             ` Stefan Kangas
  0 siblings, 2 replies; 28+ messages in thread
From: martin rudalics @ 2019-10-02  8:54 UTC (permalink / raw)
  To: Jefferson Carpenter, Eli Zaretskii; +Cc: 37514

 > Adding a single additional key might sound reasonable, but here
 > you're asking me to add two additional keys to my global bindings

As a rule, Emacs uses two keys to implement back & forth navigation
(scroll-up/-down, forward-/backward-word, next-/previous-line).

 > when a two-character code change would make it unneeded (+" t").

Sorry.  I'm missing you here.

 > The patch I attached to the original email just adds a customization
 > setting to make that a more general option.

I don't oppose your patch.  But as Eli's reaction shows we probably
need some additional motivation for installing it.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-02  8:54           ` martin rudalics
@ 2019-10-04  0:45             ` Jefferson Carpenter
  2019-10-05  8:42               ` martin rudalics
  2020-01-20 19:35             ` Stefan Kangas
  1 sibling, 1 reply; 28+ messages in thread
From: Jefferson Carpenter @ 2019-10-04  0:45 UTC (permalink / raw)
  To: martin rudalics, Eli Zaretskii; +Cc: 37514

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

On 10/2/2019 8:54 AM, martin rudalics wrote:
>  > Adding a single additional key might sound reasonable, but here
>  > you're asking me to add two additional keys to my global bindings
> 
> As a rule, Emacs uses two keys to implement back & forth navigation
> (scroll-up/-down, forward-/backward-word, next-/previous-line).
> 
>  > when a two-character code change would make it unneeded (+" t").
> 
> Sorry.  I'm missing you here.

Here, I've attached the patch I'm thinking of.

[-- Attachment #2: 0001-smaller-patch.patch --]
[-- Type: text/plain, Size: 921 bytes --]

From 4c215b42a7651bc15570a4c182a913ed1c01600b Mon Sep 17 00:00:00 2001
From: jeffersoncarpenter <jeffersoncarpenter2@gmail.com>
Date: Fri, 4 Oct 2019 00:43:57 +0000
Subject: [PATCH] smaller patch

---
 lisp/window.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/window.el b/lisp/window.el
index d93ec0add6..768bd68706 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8181,7 +8181,7 @@ from the list of completions and default values."
               (set (make-local-variable 'icomplete-with-completion-tables)
                    (cons rbts-completion-table
                          icomplete-with-completion-tables))))
-      (read-buffer prompt (other-buffer (current-buffer))
+      (read-buffer prompt (other-buffer (current-buffer) t)
                    (confirm-nonexistent-file-or-buffer)))))
 
 (defun window-normalize-buffer-to-switch-to (buffer-or-name)
-- 
2.16.1.windows.4


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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-04  0:45             ` Jefferson Carpenter
@ 2019-10-05  8:42               ` martin rudalics
  2019-10-05  9:30                 ` Eli Zaretskii
  0 siblings, 1 reply; 28+ messages in thread
From: martin rudalics @ 2019-10-05  8:42 UTC (permalink / raw)
  To: Jefferson Carpenter, Eli Zaretskii; +Cc: 37514

 > Here, I've attached the patch I'm thinking of.

I'm afraid there are no chances to get this approved ever.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-05  8:42               ` martin rudalics
@ 2019-10-05  9:30                 ` Eli Zaretskii
  0 siblings, 0 replies; 28+ messages in thread
From: Eli Zaretskii @ 2019-10-05  9:30 UTC (permalink / raw)
  To: martin rudalics; +Cc: jefferson, 37514

> Cc: 37514 <37514@debbugs.gnu.org>, bug-gnu-emacs@gnu.org
> From: martin rudalics <rudalics@gmx.at>
> Date: Sat, 5 Oct 2019 10:42:22 +0200
> 
>  > Here, I've attached the patch I'm thinking of.
> 
> I'm afraid there are no chances to get this approved ever.

Agreed, FWIW.





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-09-27  8:16     ` martin rudalics
  2019-09-28 21:00       ` Jefferson Carpenter
@ 2019-10-07  4:25       ` Lars Ingebrigtsen
  2019-10-07  9:26         ` martin rudalics
  2019-10-07 12:04         ` Robert Pluim
  1 sibling, 2 replies; 28+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-07  4:25 UTC (permalink / raw)
  To: martin rudalics; +Cc: Jefferson Carpenter, 37514

martin rudalics <rudalics@gmx.at> writes:

> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
> commands for navigating a specific window's buffer list (here these
> are bound to <M-left> and <M-right> because I don't care for word-like
> movement).

Hey, those are really useful commands that I didn't know about.

Would it make sense to give them a default key binding?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07  4:25       ` Lars Ingebrigtsen
@ 2019-10-07  9:26         ` martin rudalics
  2019-10-07 18:09           ` Juri Linkov
  2019-10-07 12:04         ` Robert Pluim
  1 sibling, 1 reply; 28+ messages in thread
From: martin rudalics @ 2019-10-07  9:26 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jefferson Carpenter, 37514

 >> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
 >> commands for navigating a specific window's buffer list (here these
 >> are bound to <M-left> and <M-right> because I don't care for word-like
 >> movement).
 >
 > Hey, those are really useful commands that I didn't know about.
 >
 > Would it make sense to give them a default key binding?

Maybe Juri has an idea ...

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07  4:25       ` Lars Ingebrigtsen
  2019-10-07  9:26         ` martin rudalics
@ 2019-10-07 12:04         ` Robert Pluim
  2019-10-08  8:42           ` martin rudalics
  1 sibling, 1 reply; 28+ messages in thread
From: Robert Pluim @ 2019-10-07 12:04 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jefferson Carpenter, 37514

>>>>> On Mon, 07 Oct 2019 06:25:56 +0200, Lars Ingebrigtsen <larsi@gnus.org> said:

    Lars> martin rudalics <rudalics@gmx.at> writes:
    >> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
    >> commands for navigating a specific window's buffer list (here these
    >> are bound to <M-left> and <M-right> because I don't care for word-like
    >> movement).

    Lars> Hey, those are really useful commands that I didn't know about.

    Lars> Would it make sense to give them a default key binding?

Well, word movement is bound to both M-left and C-left, so you'd have
to decide which half of Emacs users you annoy (personally I use
<C-left> for buffer switching, but thatʼs mainly because I donʼt use
M- much).

Other options off the top of my head:

C-, / C-.
C-< / C->
M-[ / M-]
M-{ / M-}

How do those interact with non-US keyboard layouts?

Robert





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07  9:26         ` martin rudalics
@ 2019-10-07 18:09           ` Juri Linkov
  2019-10-08  8:45             ` martin rudalics
  2019-10-08 16:32             ` Lars Ingebrigtsen
  0 siblings, 2 replies; 28+ messages in thread
From: Juri Linkov @ 2019-10-07 18:09 UTC (permalink / raw)
  To: martin rudalics; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

>>> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
>>> commands for navigating a specific window's buffer list (here these
>>> are bound to <M-left> and <M-right> because I don't care for word-like
>>> movement).
>>
>> Hey, those are really useful commands that I didn't know about.
>>
>> Would it make sense to give them a default key binding?
>
> Maybe Juri has an idea ...

Fortunately we already have several default key bindings for this:

C-x <C-left>, C-x <left>, <XF86Back>
C-x <C-right>, C-x <right>, <XF86Forward>

But nevertheless customizability of buffers for the C-x b prompt
could be improved.  The current gratuitous removing visible buffers from
C-x b prompt sometimes makes more harm than good.  One example case:

0. emacs -Q
1. C-h e   -- this displays *Messages* in another window

Now try to show the *scratch* buffer in another window,
the most convenient way is:

2. C-x 4 b   -- and select the current buffer *scratch*

but there is no "*scratch*" in completions of C-x 4 b,
because completions doesn't include the current buffer,
so need to type the whole string "*scratch* RET".

I don't know if a new option in the proposed patch
solves this problem as well.

Or maybe we need a more general DWIM-like customizable
preference of buffers for C-x b like dired-dwim-target
that is opposite to the default behavior of C-x b -
it prefers visible Dired buffers.





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07 12:04         ` Robert Pluim
@ 2019-10-08  8:42           ` martin rudalics
  2019-10-08 11:42             ` Robert Pluim
  0 siblings, 1 reply; 28+ messages in thread
From: martin rudalics @ 2019-10-08  8:42 UTC (permalink / raw)
  To: Robert Pluim, Lars Ingebrigtsen; +Cc: Jefferson Carpenter, 37514

 > C-, / C-.
 > C-< / C->
 > M-[ / M-]
 > M-{ / M-}
 >
 > How do those interact with non-US keyboard layouts?

The first two are OK, the others are a pain.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07 18:09           ` Juri Linkov
@ 2019-10-08  8:45             ` martin rudalics
  2019-10-09 18:48               ` Juri Linkov
  2019-10-08 16:32             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 28+ messages in thread
From: martin rudalics @ 2019-10-08  8:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

 > Fortunately we already have several default key bindings for this:
 >
 > C-x <C-left>, C-x <left>, <XF86Back>
 > C-x <C-right>, C-x <right>, <XF86Forward>

These are not auto-repeatable, alas.

 > But nevertheless customizability of buffers for the C-x b prompt
 > could be improved.  The current gratuitous removing visible buffers from
 > C-x b prompt sometimes makes more harm than good.  One example case:
 >
 > 0. emacs -Q
 > 1. C-h e   -- this displays *Messages* in another window
 >
 > Now try to show the *scratch* buffer in another window,
 > the most convenient way is:
 >
 > 2. C-x 4 b   -- and select the current buffer *scratch*
 >
 > but there is no "*scratch*" in completions of C-x 4 b,
 > because completions doesn't include the current buffer,
 > so need to type the whole string "*scratch* RET".

To me that's two bugs in the completions mechanism itself.  It does
propose *Messages* first although that buffer is already displayed in
another window and does not propose *scratch* although that buffer
does not show in another window.  For me, a correct interpretation of
C-x 4 b is to propose *scratch* first and _maybe_ propose *Messages*
additionally for people who don't like C-x o.  C-x b in the very same
configuration does it right IMHO.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-08  8:42           ` martin rudalics
@ 2019-10-08 11:42             ` Robert Pluim
  0 siblings, 0 replies; 28+ messages in thread
From: Robert Pluim @ 2019-10-08 11:42 UTC (permalink / raw)
  To: martin rudalics; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

>>>>> On Tue, 8 Oct 2019 10:42:55 +0200, martin rudalics <rudalics@gmx.at> said:

    >> C-, / C-.
    >> C-< / C->
    >> M-[ / M-]
    >> M-{ / M-}
    >> 
    >> How do those interact with non-US keyboard layouts?

    martin> The first two are OK, the others are a pain.

Nevermind, as someone pointed out there are already bindings for these
(although for next-buffer and previous-buffer, which are wrappers
around the switch-to- variants).

Robert





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-07 18:09           ` Juri Linkov
  2019-10-08  8:45             ` martin rudalics
@ 2019-10-08 16:32             ` Lars Ingebrigtsen
  2019-10-09 20:50               ` Juri Linkov
  1 sibling, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-08 16:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Jefferson Carpenter, 37514

Juri Linkov <juri@linkov.net> writes:

>>>> 'switch-to-prev-buffer' and 'switch-to-next-buffer' are the canonical
>>>> commands for navigating a specific window's buffer list (here these
>>>> are bound to <M-left> and <M-right> because I don't care for word-like
>>>> movement).
>>>
>>> Hey, those are really useful commands that I didn't know about.
>>>
>>> Would it make sense to give them a default key binding?
>>
>> Maybe Juri has an idea ...
>
> Fortunately we already have several default key bindings for this:
>
> C-x <C-left>, C-x <left>, <XF86Back>
> C-x <C-right>, C-x <right>, <XF86Forward>

I tried `C-h w switch-to-prev-buffer RET', and I got

"switch-to-prev-buffer is not on any key"

Oh!  `previous-buffer' is just a small shim over
`switch-to-prev-buffer'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-08  8:45             ` martin rudalics
@ 2019-10-09 18:48               ` Juri Linkov
  2019-10-12 20:47                 ` Juri Linkov
  0 siblings, 1 reply; 28+ messages in thread
From: Juri Linkov @ 2019-10-09 18:48 UTC (permalink / raw)
  To: martin rudalics; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

>> C-x <C-left>, C-x <left>, <XF86Back>
>> C-x <C-right>, C-x <right>, <XF86Forward>
>
> These are not auto-repeatable, alas.

At least we need to add a numeric arg to make them more repeatable
with e.g. 'C-3 C-x <C-left>' - easy to type key sequence
while holding the Ctrl key.

> To me that's two bugs in the completions mechanism itself.  It does
> propose *Messages* first although that buffer is already displayed in
> another window and does not propose *scratch* although that buffer
> does not show in another window.  For me, a correct interpretation of
> C-x 4 b is to propose *scratch* first and _maybe_ propose *Messages*
> additionally for people who don't like C-x o.  C-x b in the very same
> configuration does it right IMHO.

Since here different preferences make sense, maybe this needs
better customizability.





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-08 16:32             ` Lars Ingebrigtsen
@ 2019-10-09 20:50               ` Juri Linkov
  2019-10-09 20:59                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 28+ messages in thread
From: Juri Linkov @ 2019-10-09 20:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jefferson Carpenter, 37514

> I tried `C-h w switch-to-prev-buffer RET', and I got
>
> "switch-to-prev-buffer is not on any key"
>
> Oh!  `previous-buffer' is just a small shim over
> `switch-to-prev-buffer'.

And the docstring of `switch-to-prev-buffer' has no reference
to `previous-buffer', and neither `previous-buffer' has
a reference back to `switch-to-prev-buffer'.

Should their docstrings be interlinked?





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-09 20:50               ` Juri Linkov
@ 2019-10-09 20:59                 ` Lars Ingebrigtsen
  2019-10-11  8:16                   ` martin rudalics
  0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09 20:59 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Jefferson Carpenter, 37514

Juri Linkov <juri@linkov.net> writes:

>> I tried `C-h w switch-to-prev-buffer RET', and I got
>>
>> "switch-to-prev-buffer is not on any key"
>>
>> Oh!  `previous-buffer' is just a small shim over
>> `switch-to-prev-buffer'.
>
> And the docstring of `switch-to-prev-buffer' has no reference
> to `previous-buffer', and neither `previous-buffer' has
> a reference back to `switch-to-prev-buffer'.
>
> Should their docstrings be interlinked?

Yes, that would help, I think.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-09 20:59                 ` Lars Ingebrigtsen
@ 2019-10-11  8:16                   ` martin rudalics
  0 siblings, 0 replies; 28+ messages in thread
From: martin rudalics @ 2019-10-11  8:16 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Juri Linkov; +Cc: Jefferson Carpenter, 37514

 >> And the docstring of `switch-to-prev-buffer' has no reference
 >> to `previous-buffer', and neither `previous-buffer' has
 >> a reference back to `switch-to-prev-buffer'.
 >>
 >> Should their docstrings be interlinked?
 >
 > Yes, that would help, I think.

I added such cross-links now.

martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-09 18:48               ` Juri Linkov
@ 2019-10-12 20:47                 ` Juri Linkov
  2019-10-13  8:17                   ` martin rudalics
  0 siblings, 1 reply; 28+ messages in thread
From: Juri Linkov @ 2019-10-12 20:47 UTC (permalink / raw)
  To: martin rudalics; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

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

>>> C-x <C-left>, C-x <left>, <XF86Back>
>>> C-x <C-right>, C-x <right>, <XF86Forward>
>>
>> These are not auto-repeatable, alas.
>
> At least we need to add a numeric arg to make them more repeatable
> with e.g. 'C-3 C-x <C-left>' - easy to type key sequence
> while holding the Ctrl key.

This patch makes them more repeatable:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-buffer-arg.patch --]
[-- Type: text/x-diff, Size: 1549 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index d7955209cd..9fd00b94c2 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4747,31 +4747,33 @@ unbury-buffer
   (interactive)
   (switch-to-buffer (last-buffer)))
 
-(defun next-buffer ()
-  "In selected window switch to next buffer.
+(defun next-buffer (&optional arg)
+  "In selected window switch to ARGth next buffer.
 Call `switch-to-next-buffer' unless the selected window is the
 minibuffer window or is dedicated to its buffer."
-  (interactive)
+  (interactive "p")
   (cond
    ((window-minibuffer-p)
     (user-error "Cannot switch buffers in minibuffer window"))
    ((eq (window-dedicated-p) t)
     (user-error "Window is strongly dedicated to its buffer"))
    (t
-    (switch-to-next-buffer))))
+    (dotimes (_ arg)
+      (switch-to-next-buffer)))))
 
-(defun previous-buffer ()
-  "In selected window switch to previous buffer.
+(defun previous-buffer (&optional arg)
+  "In selected window switch to ARGth previous buffer.
 Call `switch-to-prev-buffer' unless the selected window is the
 minibuffer window or is dedicated to its buffer."
-  (interactive)
+  (interactive "p")
   (cond
    ((window-minibuffer-p)
     (user-error "Cannot switch buffers in minibuffer window"))
    ((eq (window-dedicated-p) t)
     (user-error "Window is strongly dedicated to its buffer"))
    (t
-    (switch-to-prev-buffer))))
+    (dotimes (_ arg)
+      (switch-to-prev-buffer)))))
 
 (defun delete-windows-on (&optional buffer-or-name frame)
   "Delete all windows showing BUFFER-OR-NAME.

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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-12 20:47                 ` Juri Linkov
@ 2019-10-13  8:17                   ` martin rudalics
  0 siblings, 0 replies; 28+ messages in thread
From: martin rudalics @ 2019-10-13  8:17 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, Jefferson Carpenter, 37514

> This patch makes them more repeatable:

Since I hardly ever use prefix arguments, it won't help me.
But it couldn't possibly harm either, so please install.

Thanks, martin





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2019-10-02  8:54           ` martin rudalics
  2019-10-04  0:45             ` Jefferson Carpenter
@ 2020-01-20 19:35             ` Stefan Kangas
  2020-03-18  5:36               ` Stefan Kangas
  1 sibling, 1 reply; 28+ messages in thread
From: Stefan Kangas @ 2020-01-20 19:35 UTC (permalink / raw)
  To: martin rudalics; +Cc: Jefferson Carpenter, 37514

Hi Jefferson,

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Wed, 25 Sep 2019 21:24:45 +0000
>> From: Jefferson Carpenter <jefferson@aoeu2code.com>
>> 
>> A not-uncommon workflow of mine is to have more than one window looking at the same buffer in several
>> different places.  Often in one of these windows I switch to some other buffer (perhaps a shell) and then want
>> to switch directly back to the same place I was just looking at in main buffer.  However since my main buffer is
>> already visible in another window, C-x b (switch-to-buffer) does not default to that buffer, but prefers a buffer
>> that is not already visible.  This customization setting allows users to override that behavior so that
>> switch-to-buffer does not prefer buffers that are not already visible.
>
> Why is it important what "C-x b" offers as the default?  You can still
> type the name of the buffer you want and switch to it.
>
> FWIW, I use the workflow you mention from time to time, and I never
> felt the need for such an option, because its effect will be global on
> the entire session, and I don't want it everywhere.  I'd need to reset
> such an option when I go back to the other workflows, which would be a
> nuisance.
>
> And if the above is somehow still not satisfactory, you can always
> write a trivial wrapper around switch-to-buffer, which behaves the way
> you like.  Why do we need to canonicalize this in Emacs?

martin rudalics <rudalics@gmx.at> writes:

>> The patch I attached to the original email just adds a customization
>> setting to make that a more general option.
>
> I don't oppose your patch.  But as Eli's reaction shows we probably
> need some additional motivation for installing it.

It has now been 15 weeks without anyone expressing any support for
your change, unfortunately.

I also don't oppose your patch, but I also don't really see a clear
benefit to including it in Emacs.  Eli, the Emacs maintainer, has
stated above that he thinks it's better if you add local
customizations to make this work the way you want.  I think that is a
good suggestion, and one which is also very much the Emacs way when we
disagree with this or that design choice.

I would suggest that we give this a few more weeks to give more people
a chance to chime in.  If there is no one else expressing support for
your suggestion within that time, or any objections to my suggestion,
I will close this as wontfix.

Thank you for your interest in Emacs, and taking the time to write up
a patch.  That is really the best way to make sure we can concretely
discuss and make progress on any feature request.

Best regards,
Stefan Kangas





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

* bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default
  2020-01-20 19:35             ` Stefan Kangas
@ 2020-03-18  5:36               ` Stefan Kangas
  0 siblings, 0 replies; 28+ messages in thread
From: Stefan Kangas @ 2020-03-18  5:36 UTC (permalink / raw)
  To: martin rudalics; +Cc: Jefferson Carpenter, 37514

tags 37514 + wontfix
close 37514
thanks

Stefan Kangas <stefan@marxist.se> writes:

> I would suggest that we give this a few more weeks to give more people
> a chance to chime in.  If there is no one else expressing support for
> your suggestion within that time, or any objections to my suggestion,
> I will close this as wontfix.

No further comments within 8 weeks; closing this bug now.

Best regards,
Stefan Kangas





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

end of thread, other threads:[~2020-03-18  5:36 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-25 21:24 bug#37514: PATCH: Add setting to allow switching to an already-visible buffer by default Jefferson Carpenter
2019-09-26  7:12 ` Eli Zaretskii
2019-09-26 19:13   ` Jefferson Carpenter
2019-09-26 19:14     ` Jefferson Carpenter
2019-09-27  8:16     ` martin rudalics
2019-09-28 21:00       ` Jefferson Carpenter
2019-10-02  3:36         ` Jefferson Carpenter
2019-10-02  8:54           ` martin rudalics
2019-10-04  0:45             ` Jefferson Carpenter
2019-10-05  8:42               ` martin rudalics
2019-10-05  9:30                 ` Eli Zaretskii
2020-01-20 19:35             ` Stefan Kangas
2020-03-18  5:36               ` Stefan Kangas
2019-10-07  4:25       ` Lars Ingebrigtsen
2019-10-07  9:26         ` martin rudalics
2019-10-07 18:09           ` Juri Linkov
2019-10-08  8:45             ` martin rudalics
2019-10-09 18:48               ` Juri Linkov
2019-10-12 20:47                 ` Juri Linkov
2019-10-13  8:17                   ` martin rudalics
2019-10-08 16:32             ` Lars Ingebrigtsen
2019-10-09 20:50               ` Juri Linkov
2019-10-09 20:59                 ` Lars Ingebrigtsen
2019-10-11  8:16                   ` martin rudalics
2019-10-07 12:04         ` Robert Pluim
2019-10-08  8:42           ` martin rudalics
2019-10-08 11:42             ` Robert Pluim
2019-09-26  7:20 ` martin rudalics

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