unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
@ 2021-05-10  5:37 Boruch Baum
  2021-05-10 13:28 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Boruch Baum @ 2021-05-10  5:37 UTC (permalink / raw)
  To: 48328

I was going through my init file, and realized that something I thought
was part of emacs-core was actually my simple wrapper function. IMO,
it's sensible and I find it very convenient when dealing with buried
buffers being used for reference (eg. occur, grep, help).

All it does is add a prefix-arg control to function
`switch-to-buffer-other-window' (C-x 4 b).

For your consideration:

(defcustom my-switch-to-buffer-other-window-keep-focus nil
  "Controls focus of buffer-switch to other window.
When non-NIL, function `my-switch-to-buffer-other-window' keeps
focus in the current window. This can be over-ridden at run-time
by passing that function a PREFIX-ARG."
  :type 'boolean)

(defun my-switch-to-buffer-other-window (buffer-or-name &optional norecord)
  "Wrapper to allow keeping focus in current window.
Performs action of function `switch-to-buffer-other-window', but
refers to variable `my-switch-to-buffer-other-window-keep-focus'
to determine whether to change focus to the other window. You can
over-ride that setting by calling this function with a
PREFIX-ARG."
  (interactive
   (list (read-buffer-to-switch "Switch to buffer in other window: ")))
  (let ((pop-up-windows t)
        (win (selected-window)))
    (pop-to-buffer buffer-or-name t norecord)
    (when (if current-prefix-arg
            (not my-switch-to-buffer-other-window-keep-focus)
           my-switch-to-buffer-other-window-keep-focus)
      (select-window win 'norecord)))) ; ie. norecord=t

(define-key ctl-x-4-map (kbd "b") 'my-switch-to-buffer-other-window)

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





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

* bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
  2021-05-10  5:37 bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED] Boruch Baum
@ 2021-05-10 13:28 ` Eli Zaretskii
  2021-05-10 15:36   ` Boruch Baum
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2021-05-10 13:28 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 48328

> Date: Mon, 10 May 2021 01:37:17 -0400
> From: Boruch Baum <boruch_baum@gmx.com>
> 
> I was going through my init file, and realized that something I thought
> was part of emacs-core was actually my simple wrapper function. IMO,
> it's sensible and I find it very convenient when dealing with buried
> buffers being used for reference (eg. occur, grep, help).
> 
> All it does is add a prefix-arg control to function
> `switch-to-buffer-other-window' (C-x 4 b).
> 
> For your consideration:
> 
> (defcustom my-switch-to-buffer-other-window-keep-focus nil
>   "Controls focus of buffer-switch to other window.
> When non-NIL, function `my-switch-to-buffer-other-window' keeps
> focus in the current window. This can be over-ridden at run-time
> by passing that function a PREFIX-ARG."
>   :type 'boolean)
> 
> (defun my-switch-to-buffer-other-window (buffer-or-name &optional norecord)
>   "Wrapper to allow keeping focus in current window.
> Performs action of function `switch-to-buffer-other-window', but
> refers to variable `my-switch-to-buffer-other-window-keep-focus'
> to determine whether to change focus to the other window. You can
> over-ride that setting by calling this function with a
> PREFIX-ARG."

I use "C-x 4 C-o", which is built-in, for the same purpose.  Doesn't
it do what you want here?





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

* bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
  2021-05-10 13:28 ` Eli Zaretskii
@ 2021-05-10 15:36   ` Boruch Baum
  2021-05-11 12:37     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Boruch Baum @ 2021-05-10 15:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 48328

On 2021-05-10 16:28, Eli Zaretskii wrote:
> I use "C-x 4 C-o", which is built-in, for the same purpose.  Doesn't
> it do what you want here?

Yes. I didn't know that keybinding.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





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

* bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
  2021-05-10 15:36   ` Boruch Baum
@ 2021-05-11 12:37     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-11 12:37 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 48328

Boruch Baum <boruch_baum@gmx.com> writes:

> On 2021-05-10 16:28, Eli Zaretskii wrote:
>> I use "C-x 4 C-o", which is built-in, for the same purpose.  Doesn't
>> it do what you want here?
>
> Yes. I didn't know that keybinding.

OK; closing this bug report, then.

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





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

end of thread, other threads:[~2021-05-11 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  5:37 bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED] Boruch Baum
2021-05-10 13:28 ` Eli Zaretskii
2021-05-10 15:36   ` Boruch Baum
2021-05-11 12:37     ` Lars Ingebrigtsen

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