GNU bug report logs - #48328
switch-buffer-other-window keep-focus [POC INCLUDED]

Previous Next

Package: emacs;

Reported by: Boruch Baum <boruch_baum <at> gmx.com>

Date: Mon, 10 May 2021 05:38:02 UTC

Severity: normal

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48328 in the body.
You can then email your comments to 48328 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48328; Package emacs. (Mon, 10 May 2021 05:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Boruch Baum <boruch_baum <at> gmx.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 May 2021 05:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Boruch Baum <boruch_baum <at> gmx.com>
To: Emacs Bug Reporting <bug-gnu-emacs <at> gnu.org>
Subject: switch-buffer-other-window keep-focus [POC INCLUDED]
Date: Mon, 10 May 2021 01:37:17 -0400
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48328; Package emacs. (Mon, 10 May 2021 13:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 48328 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Boruch Baum <boruch_baum <at> gmx.com>
Cc: 48328 <at> debbugs.gnu.org
Subject: Re: bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
Date: Mon, 10 May 2021 16:28:50 +0300
> Date: Mon, 10 May 2021 01:37:17 -0400
> From: Boruch Baum <boruch_baum <at> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48328; Package emacs. (Mon, 10 May 2021 15:37:01 GMT) Full text and rfc822 format available.

Message #11 received at 48328 <at> debbugs.gnu.org (full text, mbox):

From: Boruch Baum <boruch_baum <at> gmx.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48328 <at> debbugs.gnu.org
Subject: Re: bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
Date: Mon, 10 May 2021 11:36:45 -0400
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48328; Package emacs. (Tue, 11 May 2021 12:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 48328 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Boruch Baum <boruch_baum <at> gmx.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 48328 <at> debbugs.gnu.org
Subject: Re: bug#48328: switch-buffer-other-window keep-focus [POC INCLUDED]
Date: Tue, 11 May 2021 14:37:41 +0200
Boruch Baum <boruch_baum <at> 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




bug closed, send any further explanations to 48328 <at> debbugs.gnu.org and Boruch Baum <boruch_baum <at> gmx.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 11 May 2021 12:38:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Jun 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 293 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.