[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit and Close Emacs Special Windows

From: Yuan Fu
Subject: Re: Quit and Close Emacs Special Windows
Date: Mon, 29 Jun 2020 12:13:41 -0400

I use a similar “smart” quit function. When a special buffer pops up creating a 
new window, I want that window disappear when quit; but if the special buffer 
reused a window, I want Emacs to keep the window and restore the original 
buffer. Here is what I use:

(defun ghelp-close ()
  "Close ghelp buffer/window."
  (cl-loop for buffer1 in (window-prev-buffers)
           for buffer = (car buffer1)
           for is-ghelp = (eq 'ghelp-page-mode
                               'major-mode buffer))
           if (not is-ghelp)
           do (switch-to-buffer buffer)
           and return nil
           finally (delete-window)))

Here, instead of looking for special-mode, I look for ghelp-page-mode, but the 
idea is the same. I look at the buffer history of the window and restore 
previous buffer if I can find one, if not, I delete the window.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]