all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pillule <pillule@riseup.net>
To: 48367@debbugs.gnu.org
Subject: bug#48367: 28.0.50; quit-restore-buffer may jam
Date: Tue, 11 May 2021 20:26:08 +0000	[thread overview]
Message-ID: <87h7j9xbj3.fsf@host.localdomain> (raw)

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


Hello there,

I think there is a small bug with quit-window / 
quit-restore-window :

with emacs -Q

;; set some rules
(setq display-buffer-alist
      '(("\\*\\(Backtrace\\|Messages\\)\\*"
        (display-buffer-in-side-window)
        (window-height . 0.2)
        (side . bottom))))

;; trigger a logical error to display the *Backtrace* buffer
(> vim emacs)

;; display the *Messages* buffer
(view-echo-area-messages)

;; mess the `quit-restore' window parameter
(kill-buffer (get-buffer "*Backtrace*"))

;; which looks now like that in the *Messages* window :
;; ((quit-restore) (window-slot . 0) (window-side . bottom))

;; try to quit the *Messages* window
(progn (select-window (view-echo-area-messages))
       (quit-window))

;; nothing happens :

The first `cond' of quit-restore-window end up to 't,
it calls (switch-to-prev-buffer window bury-or-kill)
but there is no previous-window available.

The first patch adress this, and a similar one : when there is a previous-buffer available, but it referes to the 
same buffer. (eg: try the recipe again but exchange the role of 
*Messages* and *Backtrace*, you will finish with a blank buffer for backtrace, that you can quit again to end up to the same point)

The second patch is a proposition to clarify a little the code.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: quit-restore-window-patch1 --]
[-- Type: text/x-diff, Size: 690 bytes --]

diff -u --label /usr/share/emacs/28.0.50/lisp/window.el.gz --label /home/user/src/patches/window.el /tmp/jka-comHlW7wF /home/user/src/patches/window.el
--- /usr/share/emacs/28.0.50/lisp/window.el.gz
+++ /home/user/src/patches/window.el
@@ -5151,7 +5151,9 @@
       (set-window-parameter window 'quit-restore nil)
       ;; Make sure that WINDOW is no more dedicated.
       (set-window-dedicated-p window nil)
-      (switch-to-prev-buffer window bury-or-kill)))
+      (if prev-buffer
+          (switch-to-prev-buffer window bury-or-kill)
+        (window--delete window nil (eq bury-or-kill 'kill)))))
 
     ;; Deal with the buffer.
     (cond

Diff finished.  Tue May 11 21:26:38 2021

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: quit-restore-window-patch2 --]
[-- Type: text/x-diff, Size: 952 bytes --]

diff -u --label /usr/share/emacs/28.0.50/lisp/window.el.gz --label /home/user/src/patches/window.el /tmp/jka-comAXCNZa /home/user/src/patches/window.el
--- /usr/share/emacs/28.0.50/lisp/window.el.gz
+++ /home/user/src/patches/window.el
@@ -5073,14 +5073,9 @@
   (setq window (window-normalize-window window t))
   (let* ((buffer (window-buffer window))
 	 (quit-restore (window-parameter window 'quit-restore))
-	 (prev-buffer
-	  (let* ((prev-buffers (window-prev-buffers window))
-		 (prev-buffer (caar prev-buffers)))
-	    (and (or (not (eq prev-buffer buffer))
-		     (and (cdr prev-buffers)
-			  (not (eq (setq prev-buffer (cadr prev-buffers))
-				   buffer))))
-		 prev-buffer)))
+	 (prev-buffer (car (cl-find-if-not
+                            (lambda (buf) (eq (car buf) buffer))
+                            (window-prev-buffers window))))
 	 quad entry)
     (cond
      ((and (not prev-buffer)

Diff finished.  Tue May 11 22:00:30 2021

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


--

             reply	other threads:[~2021-05-11 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 20:26 pillule [this message]
2021-05-12  8:47 ` bug#48367: 28.0.50; quit-restore-buffer may jam martin rudalics
2021-05-12 11:25   ` bug#48367: 28.0.50; quit-restore-window " pillule
2021-05-12 12:32     ` martin rudalics
2021-05-12 14:10       ` pillule
2021-05-12 16:40         ` martin rudalics
2021-05-15  8:56         ` martin rudalics
2021-05-15 10:34           ` pillule

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7j9xbj3.fsf@host.localdomain \
    --to=pillule@riseup.net \
    --cc=48367@debbugs.gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.