From: martin rudalics <rudalics@gmx.at>
To: Konrad Podczeck <konrad.podczeck@univie.ac.at>
Cc: 37840@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#37840: Missing in the Emacs manuals:
Date: Fri, 22 Nov 2019 18:49:42 +0100 [thread overview]
Message-ID: <47e77731-bb63-f626-c9d1-725227d36c43@gmx.at> (raw)
In-Reply-To: <70BE5DCC-07C6-4A0D-9A5C-1700BBCB1DC5@univie.ac.at>
[-- Attachment #1: Type: text/plain, Size: 706 bytes --]
> With this, start Emacs, open a file, foo.tex say, and in the
> mini-buffer of the frame displaying foo.tex do occur->some text, so
> that the occur-buffer displays in its own frame. Now, in the
> mini-buffer of the frame with foo.tex do bury-buffer. Then also this
> frame displays the occur-buffer, so that I end up with two frames
> displaying the same occur-buffer. How to solve this problem?
You can't and I am to blame for that. 'switch-to-visible-buffer' is
simply too weak to handle your case. Please apply the attached patch
and set 'switch-to-buffer-skip-visible' to 'visible or t.
Eli this was a regression in Emacs 24 that went unnoticed so far. Any
objections to install?
martin
[-- Attachment #2: switch-to-buffer-skip-visible.diffs --]
[-- Type: text/plain, Size: 5810 bytes --]
diff --git a/lisp/window.el b/lisp/window.el
index 7478047939..5e43c73ef3 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4409,6 +4409,35 @@ switch-to-visible-buffer
:version "24.1"
:group 'windows)
+(make-obsolete-variable 'switch-to-visible-buffer
+ 'switch-to-buffer-skip-visible "27.1")
+
+(defcustom switch-to-buffer-skip-visible nil
+ "If nil, allow switching to an already visible buffer.
+If this variable is nil, `switch-to-prev-buffer' and
+`switch-to-next-buffer' allow switching to a buffer that is
+already visible in a window.
+
+If this variable is non-nil, it specifies the frames to skip when
+a window on that frame already shows the buffer. In particular:
+
+- t means all windows on all existing frames.
+
+- `visible' means all windows on all visible frames.
+
+- 0 (the number zero) means all windows on all visible and
+ iconified frames.
+
+- `this' means all windows on the same frame only."
+ :type
+ '(choice (const :tag "Never" nil)
+ (const :tag "Any frame" t)
+ (const :tag "Visible frames" visible)
+ (const :tag "Visible and iconified frames" 0)
+ (const :tag "This frame" this))
+ :version "27.1"
+ :group 'windows)
+
(defun switch-to-prev-buffer (&optional window bury-or-kill)
"In WINDOW switch to previous buffer.
WINDOW must be a live window and defaults to the selected one.
@@ -4424,6 +4453,10 @@ switch-to-prev-buffer
future invocation of `switch-to-prev-buffer' less likely switches
to it.
+The option `switch-to-buffer-skip-visible' controls whether
+switching to a buffer already visible in another window is
+allowed.
+
This function is called by `prev-buffer'."
(interactive)
(let* ((window (window-normalize-window window t))
@@ -4433,7 +4466,14 @@ switch-to-prev-buffer
;; Save this since it's destroyed by `set-window-buffer'.
(next-buffers (window-next-buffers window))
(pred (frame-parameter frame 'buffer-predicate))
- entry new-buffer killed-buffers visible)
+ (skip-visible
+ (cond
+ ((memq switch-to-buffer-skip-visible '(t visible 0))
+ switch-to-buffer-skip-visible)
+ ((or switch-to-buffer-skip-visible
+ (not switch-to-visible-buffer))
+ frame)))
+ entry new-buffer killed-buffers visible)
(when (window-minibuffer-p window)
;; Don't switch in minibuffer window.
(unless (setq window (minibuffer-selected-window))
@@ -4456,8 +4496,7 @@ switch-to-prev-buffer
;; When BURY-OR-KILL is nil, avoid switching to a
;; buffer in WINDOW's next buffers list.
(or bury-or-kill (not (memq new-buffer next-buffers))))
- (if (and (not switch-to-visible-buffer)
- (get-buffer-window new-buffer frame))
+ (if (and skip-visible (get-buffer-window new-buffer skip-visible))
;; Try to avoid showing a buffer visible in some other
;; window.
(setq visible new-buffer)
@@ -4482,8 +4521,7 @@ switch-to-prev-buffer
;; Don't show a buffer shown in a side window before.
(not (buffer-local-value 'window--sides-shown buffer))
(or bury-or-kill (not (memq buffer next-buffers))))
- (if (and (not switch-to-visible-buffer)
- (get-buffer-window buffer frame))
+ (if (and skip-visible (get-buffer-window buffer skip-visible))
;; Try to avoid showing a buffer visible in some other window.
(unless visible
(setq visible buffer))
@@ -4547,7 +4585,13 @@ switch-to-next-buffer
"In WINDOW switch to next buffer.
WINDOW must be a live window and defaults to the selected one.
Return the buffer switched to, nil if no suitable buffer could be
-found. This function is called by `next-buffer'."
+found.
+
+The option `switch-to-buffer-skip-visible' controls whether
+switching to a buffer already visible in another window is
+allowed.
+
+This function is called by `next-buffer'."
(interactive)
(let* ((window (window-normalize-window window t))
(frame (window-frame window))
@@ -4555,6 +4599,13 @@ switch-to-next-buffer
(old-buffer (window-buffer window))
(next-buffers (window-next-buffers window))
(pred (frame-parameter frame 'buffer-predicate))
+ (skip-visible
+ (cond
+ ((memq switch-to-buffer-skip-visible '(t visible 0))
+ switch-to-buffer-skip-visible)
+ ((or switch-to-buffer-skip-visible
+ (not switch-to-visible-buffer))
+ frame)))
new-buffer entry killed-buffers visible)
(when (window-minibuffer-p window)
;; Don't switch in minibuffer window.
@@ -4589,8 +4640,7 @@ switch-to-next-buffer
;; Don't show a buffer shown in a side window before.
(not (buffer-local-value 'window--sides-shown buffer))
(not (assq buffer (window-prev-buffers window))))
- (if (and (not switch-to-visible-buffer)
- (get-buffer-window buffer frame))
+ (if (and skip-visible (get-buffer-window buffer skip-visible))
;; Try to avoid showing a buffer visible in some other window.
(setq visible buffer)
(setq new-buffer buffer)
@@ -4605,8 +4655,7 @@ switch-to-next-buffer
(cons new-buffer killed-buffers))))
(not (eq new-buffer old-buffer))
(or (null pred) (funcall pred new-buffer)))
- (if (and (not switch-to-visible-buffer)
- (get-buffer-window new-buffer frame))
+ (if (and skip-visible (get-buffer-window new-buffer skip-visible))
;; Try to avoid showing a buffer visible in some other window.
(unless visible
(setq visible new-buffer))
next prev parent reply other threads:[~2019-11-22 17:49 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 0:39 bug#37840: Missing in the Emacs manuals: Konrad Podczeck
2019-10-22 8:43 ` martin rudalics
2019-10-23 7:25 ` Konrad Podczeck
2019-10-23 7:46 ` martin rudalics
2019-10-28 17:37 ` Konrad Podczeck
2019-10-28 18:13 ` martin rudalics
2019-10-28 19:04 ` Konrad Podczeck
2019-10-29 9:28 ` martin rudalics
2019-10-30 0:56 ` Konrad Podczeck
2019-10-30 8:14 ` martin rudalics
2019-10-30 20:37 ` Konrad Podczeck
2019-10-31 7:59 ` martin rudalics
2019-11-02 21:47 ` Konrad Podczeck
2019-11-04 9:06 ` martin rudalics
2019-11-04 11:20 ` Konrad Podczeck
2019-11-04 18:27 ` martin rudalics
[not found] ` <A8BBF7A4-BFE0-44BB-BCB3-B26477FFC946@univie.ac.at>
2019-11-04 19:10 ` martin rudalics
2019-11-06 22:41 ` Juri Linkov
2019-11-07 8:39 ` martin rudalics
2019-11-07 21:58 ` Juri Linkov
2019-11-08 9:20 ` martin rudalics
2019-11-08 11:04 ` Konrad Podczeck
2019-11-08 18:27 ` martin rudalics
2019-11-08 21:12 ` Konrad Podczeck
2019-11-09 9:01 ` martin rudalics
2019-11-10 16:44 ` Konrad Podczeck
2019-11-10 18:33 ` martin rudalics
2019-11-14 10:03 ` Eli Zaretskii
2019-11-14 18:18 ` martin rudalics
2019-11-14 18:35 ` Eli Zaretskii
2019-11-15 8:50 ` martin rudalics
2019-11-22 13:09 ` Konrad Podczeck
2019-11-22 17:49 ` martin rudalics [this message]
2019-11-22 19:22 ` Eli Zaretskii
2019-11-23 1:42 ` Konrad Podczeck
2019-11-23 8:16 ` martin rudalics
2019-11-25 23:47 ` Konrad Podczeck
2019-11-26 9:32 ` martin rudalics
2019-12-02 1:35 ` Konrad Podczeck
2019-12-02 9:41 ` martin rudalics
2019-11-23 8:15 ` martin rudalics
2019-11-23 9:49 ` Eli Zaretskii
2019-11-26 9:31 ` martin rudalics
2019-11-26 9:42 ` martin rudalics
2020-09-20 11:12 ` Lars Ingebrigtsen
2019-11-10 20:11 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47e77731-bb63-f626-c9d1-725227d36c43@gmx.at \
--to=rudalics@gmx.at \
--cc=37840@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=konrad.podczeck@univie.ac.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).