From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christoph Newsgroups: gmane.emacs.devel Subject: Removing mode-specific window restore code Date: Sun, 31 Aug 2014 12:45:04 -0600 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3bd50dddd8e0501f14844 X-Trace: ger.gmane.org 1409510720 20163 80.91.229.3 (31 Aug 2014 18:45:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Aug 2014 18:45:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 31 20:45:14 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XOA7m-0000oz-FW for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2014 20:45:14 +0200 Original-Received: from localhost ([::1]:50750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOA7m-0007lE-4X for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2014 14:45:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOA7h-0007kG-Dr for emacs-devel@gnu.org; Sun, 31 Aug 2014 14:45:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOA7f-0000U6-Q7 for emacs-devel@gnu.org; Sun, 31 Aug 2014 14:45:09 -0400 Original-Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:39104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOA7f-0000N3-69 for emacs-devel@gnu.org; Sun, 31 Aug 2014 14:45:07 -0400 Original-Received: by mail-lb0-f176.google.com with SMTP id s7so4909117lbd.35 for ; Sun, 31 Aug 2014 11:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=NxmdyOd6ePAQvF2XHbTp4t9InqiqWeQyh+kiuoQlpYI=; b=KXY77Y/zKVOmG3rDyfj2i6OsvscRu0yDX4egx9cbxwIZY+Hk9MIsKWqDVJv4m/RtKN 4zaQdTjXlw2UvUKzQ8XKbxe3Z8v12YPi//ODltdmAS9j9ATiPG7I+/NWzR6OUWmBpBjV uS/ZUZmWuV0vLRI2kmCOPGtiEOJAGLy7GCu3BveVLTI9nvDmrI37Q9kLVZXECSaihIL8 DGsoWKfiX3JjxXmfkcWZbrVCsb3lD/yHvaJSmE9Zs96Rvq5u5THX6hx4Shc7a7aWtKEl CwUBeWOzVOFDcyMu2th1puwizrcVqrFnBkG2xO54YHDn98k78hu156wxuXEU9Szzc7gt 2sRw== X-Received: by 10.112.210.138 with SMTP id mu10mr3541790lbc.81.1409510704797; Sun, 31 Aug 2014 11:45:04 -0700 (PDT) Original-Received: by 10.152.244.2 with HTTP; Sun, 31 Aug 2014 11:45:04 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173928 Archived-At: --001a11c3bd50dddd8e0501f14844 Content-Type: text/plain; charset=UTF-8 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: https://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00915.html 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 @@ -540,7 +540,7 @@ (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) @@ -878,12 +878,6 @@ (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu) map)) -(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) @@ -2298,18 +2292,6 @@ (goto-char (point-min)) (forward-line orig)))) -(defun ibuffer-quit () - "Quit this `ibuffer' session. -Try to restore the previous window configuration if -`ibuffer-restore-window-config-on-quit' is non-nil." - (interactive) - (if ibuffer-restore-window-config-on-quit - (progn - (bury-buffer) - (unless (= (count-windows) 1) - (set-window-configuration ibuffer-prev-window-config))) - (bury-buffer))) - ;;;###autoload (defun ibuffer-list-buffers (&optional files-only) "Display a list of buffers, in another window. @@ -2350,7 +2332,6 @@ (interactive "P") (when ibuffer-use-other-window (setq other-window-p t)) - (setq ibuffer-prev-window-config (current-window-configuration)) (let ((buf (get-buffer-create (or name "*Ibuffer*")))) (if other-window-p (funcall (if noselect (lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf) @@ -2362,8 +2343,7 @@ (select-window (get-buffer-window buf 0)) (or (derived-mode-p 'ibuffer-mode) (ibuffer-mode)) - (setq ibuffer-restore-window-config-on-quit other-window-p) - (when shrink + (when shrink (setq ibuffer-shrink-to-minimum-size shrink)) (when qualifiers (require 'ibuf-ext) @@ -2501,7 +2481,6 @@ '\\[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. @@ -2616,7 +2595,6 @@ (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) --001a11c3bd50dddd8e0501f14844 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Some modes have their own quit function, which buries= /kill buffer and often times also restores the window configuration from it= s own internally stored variables or runs specific cleanup code.

Previous discussion here:

First, I would like to try to remove the mode-specific window re= store 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 o= ther modes.

Next, I would like to look at modes th= at 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' w= ithout restoring window configuration instead of `quit-window' upon qui= tting the mode.

Should I open bug reports for each instance to track th= e review or post patches here?

ibuffer patch, comm= ents welcome:

=3D=3D=3D modified file 'li= sp/ibuffer.el'
--- lisp/ibuffer.el = 2014-08-08 14:35:40 +0000
+++ lisp/ibuffer.el 2014-08-31 17:26:11 +0000
@@ -540,= 7 +540,7 @@
=C2=A0 =C2=A0 =C2=A0(define-key map (kbd "/ X") 'ibuffer= -delete-saved-filter-groups)
=C2=A0 =C2=A0 =C2=A0(define-key map = (kbd "/ \\") 'ibuffer-clear-filter-groups)
=C2=A0
- =C2=A0 =C2=A0(define-key map (kbd "q") 'ibuffer-qu= it)
+ =C2=A0 =C2=A0(define-key map (kbd "q") 'quit-window)
=C2=A0 =C2=A0 =C2=A0(define-key map (kbd "h") 'descr= ibe-mode)
=C2=A0 =C2=A0 =C2=A0(define-key map (kbd "?")= 'describe-mode)
=C2=A0
@@ -878,12 +878,6 @@
=C2=A0 =C2=A0 =C2=A0(define-key map [do= wn-mouse-3] 'ibuffer-mouse-popup-menu)
=C2=A0 =C2=A0 =C2=A0ma= p))
=C2=A0
-(defvar ibuffer-restore-window-config-on-qu= it nil
- =C2=A0"If non-nil, restore previous window configur= ation upon exiting `ibuffer'.")
-
-(defvar ibuffer-prev-window-config nil
- =C2=A0= "Window configuration before starting Ibuffer.")
-
=C2=A0(defvar ibuffer-did-modification nil)
=C2=A0
=C2=A0(defvar ibuffer-compiled-formats nil)
@@ -2298,18 +2292,6 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char= (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-line orig))))
=C2=A0
-(defun ibuffer-quit ()
- =C2=A0"Q= uit this `ibuffer' session.
-Try to restore the previous wind= ow configuration if
-`ibuffer-restore-window-config-on-quit' is non-nil."
- =C2=A0(interactive)
- =C2=A0(if ibuffer-restore-window-confi= g-on-quit
- =C2=A0 =C2=A0 =C2=A0(progn
- (bury-buffer)
- (unless (=3D (coun= t-windows) 1)
- =C2=A0(set-window-configuration ibuffer-prev-window-config)))
-= =C2=A0 =C2=A0(bury-buffer)))
-
=C2=A0;;;###autoload
=C2=A0(defun ibuffer-list-b= uffers (&optional files-only)
=C2=A0 =C2=A0"Display a li= st of buffers, in another window.
@@ -2350,7 +2332,6 @@
=C2=A0 =C2=A0(interactive "P")
=C2=A0 =C2=A0(when ibuffer-use-other-window
=C2=A0 =C2=A0 = =C2=A0(setq other-window-p t))
- =C2=A0(setq ibuffer-prev-window-= config (current-window-configuration))
=C2=A0 =C2=A0(let ((buf (g= et-buffer-create (or name "*Ibuffer*"))))
=C2=A0 =C2=A0 =C2=A0(if other-window-p
=C2=A0 (funcall (if noselect (lambda (buf) (di= splay-buffer buf t)) #'pop-to-buffer) buf)
@@ -2362,8 +2343,7= @@
=C2=A0 (sel= ect-window (get-buffer-window buf 0))
=C2=A0 (or (derived-= mode-p 'ibuffer-mode)
=C2=A0 =C2=A0 =C2=A0(ibuffer-mode))
- (setq ibuffer-restore-window-config-on-q= uit other-window-p)
- (when shrink
=
+ (when shrink
=C2=A0 =C2=A0(setq= ibuffer-shrink-to-minimum-size shrink))
=C2=A0 (when qualifi= ers
=C2=A0 =C2= =A0(require 'ibuf-ext)
@@ -2501,7 +2481,6 @@
=C2=A0= =C2=A0'\\[ibuffer-switch-format]' - Change the current display for= mat.
=C2=A0 =C2=A0'\\[forward-line]' - Move point to the next line.=
=C2=A0 =C2=A0'\\[previous-line]' - Move point to the pre= vious line.
- =C2=A0'\\[ibuffer-quit]' - Bury the Ibuffer= buffer.
=C2=A0 =C2=A0'\\[describe-mode]' - This help.
=C2=A0 =C2=A0'\\[ibuffer-diff-with-file]' - View the differenc= es between this buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0a= nd its associated file.
@@ -2616,7 +2595,6 @@
=C2=A0 = =C2=A0(set (make-local-variable 'ibuffer-cached-eliding-string) nil)
=C2=A0 =C2=A0(set (make-local-variable 'ibuffer-cached-elide-long-= columns) nil)
=C2=A0 =C2=A0(set (make-local-variable 'ibuffer= -current-format) nil)
- =C2=A0(set (make-local-variable 'ibuf= fer-restore-window-config-on-quit) nil)
=C2=A0 =C2=A0(set (make-local-variable 'ibuffer-did-modification) = nil)
=C2=A0 =C2=A0(set (make-local-variable 'ibuffer-tmp-hide= -regexps) nil)
=C2=A0 =C2=A0(set (make-local-variable 'ibuffe= r-tmp-show-regexps) nil)

--001a11c3bd50dddd8e0501f14844--