31 Aug 20:45 2014
Removing mode-specific window restore code
Christoph <cschol2112 <at> gmail.com>
2014-08-31 18:45:04 GMT
2014-08-31 18:45:04 GMT
Some modes have their own quit function, which buries/kill buffer and often times also restores the window configuration from its own internally stored variables or runs specific cleanup code.
Previous discussion here:
First, I would like to try to remove the mode-specific window restore code and let `quit-window' handle this.
One low-hanging example (unless I am missing anything) is in ibuffer.el.
Using `quit-window' also allows to kill the buffer with `C-u q', which is new behavior for `ibuffer', but align with other modes.
Next, I would like to look at modes that do "other stuff" in their respective `quit' function. This goes back to the `quit-window-hook' discussion in the above mentioned thread. This also includes modes that just plainly call `bury-buffer' without restoring window configuration instead of `quit-window' upon quitting the mode.
Should I open bug reports for each instance to track the review or post patches here?
ibuffer patch, comments welcome:
=== modified file 'lisp/ibuffer.el'
--- lisp/ibuffer.el 2014-08-08 14:35:40 +0000
+++ lisp/ibuffer.el 2014-08-31 17:26:11 +0000
<at> <at> -540,7 +540,7 <at> <at>
(define-key map (kbd "/ X") 'ibuffer-delete-saved-filter-groups)
(define-key map (kbd "/ \\") 'ibuffer-clear-filter-groups)
- (define-key map (kbd "q") 'ibuffer-quit)
+ (define-key map (kbd "q") 'quit-window)
(define-key map (kbd "h") 'describe-mode)
(define-key map (kbd "?") 'describe-mode)
<at> <at> -878,12 +878,6 <at> <at>
(define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu)
-(defvar ibuffer-restore-window-config-on-quit nil
- "If non-nil, restore previous window configuration upon exiting `ibuffer'.")
-(defvar ibuffer-prev-window-config nil
- "Window configuration before starting Ibuffer.")
(defvar ibuffer-did-modification nil)
(defvar ibuffer-compiled-formats nil)
<at> <at> -2298,18 +2292,6 <at> <at>
-(defun ibuffer-quit ()
- "Quit this `ibuffer' session.
-Try to restore the previous window configuration if
-`ibuffer-restore-window-config-on-quit' is non-nil."
- (if ibuffer-restore-window-config-on-quit
- (unless (= (count-windows) 1)
- (set-window-configuration ibuffer-prev-window-config)))
(defun ibuffer-list-buffers (&optional files-only)
"Display a list of buffers, in another window.
<at> <at> -2350,7 +2332,6 <at> <at>
(setq other-window-p t))
- (setq ibuffer-prev-window-config (current-window-configuration))
(let ((buf (get-buffer-create (or name "*Ibuffer*"))))
(funcall (if noselect (lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf)
<at> <at> -2362,8 +2343,7 <at> <at>
(select-window (get-buffer-window buf 0))
(or (derived-mode-p 'ibuffer-mode)
- (setq ibuffer-restore-window-config-on-quit other-window-p)
- (when shrink
+ (when shrink
(setq ibuffer-shrink-to-minimum-size shrink))
<at> <at> -2501,7 +2481,6 <at> <at>
'\\[ibuffer-switch-format]' - Change the current display format.
'\\[forward-line]' - Move point to the next line.
'\\[previous-line]' - Move point to the previous line.
- '\\[ibuffer-quit]' - Bury the Ibuffer buffer.
'\\[describe-mode]' - This help.
'\\[ibuffer-diff-with-file]' - View the differences between this buffer
and its associated file.
<at> <at> -2616,7 +2595,6 <at> <at>
(set (make-local-variable 'ibuffer-cached-eliding-string) nil)
(set (make-local-variable 'ibuffer-cached-elide-long-columns) nil)
(set (make-local-variable 'ibuffer-current-format) nil)
- (set (make-local-variable 'ibuffer-restore-window-config-on-quit) nil)
(set (make-local-variable 'ibuffer-did-modification) nil)
(set (make-local-variable 'ibuffer-tmp-hide-regexps) nil)
(set (make-local-variable 'ibuffer-tmp-show-regexps) nil)