all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#48367: 28.0.50; quit-restore-buffer may jam
@ 2021-05-11 20:26 pillule
  2021-05-12  8:47 ` martin rudalics
  0 siblings, 1 reply; 8+ messages in thread
From: pillule @ 2021-05-11 20:26 UTC (permalink / raw)
  To: 48367

[-- 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 --]


--

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

end of thread, other threads:[~2021-05-15 10:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-11 20:26 bug#48367: 28.0.50; quit-restore-buffer may jam pillule
2021-05-12  8:47 ` 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

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.