[Top][All Lists]

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

RE: [External] : Custom for quit-window?

From: Drew Adams
Subject: RE: [External] : Custom for quit-window?
Date: Fri, 7 Jan 2022 18:11:49 +0000

> Is it there a "simple method" to make quit-window to kill the buffer
> without needing a prefix?
> When working with 10 files and using dired, help and some other
> special-mode derived buffers it becomes awkward to have 10 working files
> and 15 random noisy buffers that makes "C-x <right>"" navigation
> useless and "C-x b" harder to read.
> Such simple custom option I am pretty sure has been deserved by someone
> before, and a simple approach may be to remap quit-window to something
> like:
> (defun my/quit-window (&optional kill window)
>    (interactive "P")
>    (quit-window t window))
> But I am wondering if it is so simple why isn't there an option for
> that. Is there any very bad side effect on this?
> Another alternative is to hide/filter buffers using a regex or so, but
> IMHO it is like hiding the real issue under the carpet.

I use this:

(defun quit-window-delete (&optional kill window)
  "Quit WINDOW, deleting it, and bury its buffer.
WINDOW must be a live window and defaults to the selected one.
With prefix argument KILL non-nil, kill the buffer instead of
burying it.

This is similar to the version of `quit-window' that Emacs had before
the introduction of `quit-restore-window'.  It ignores the information
stored in WINDOW's `quit-restore' window parameter.

It deletes the WINDOW more often, rather than switching to another
buffer in it.  If WINDOW is alone in its frame then the frame is
deleted or iconified, according to option `frame-auto-hide-function'."
  (interactive "P")
    window 'quit-restore `(frame frame nil ,(current-buffer)))
  (quit-restore-window window (if kill 'kill 'bury)))

And I do this:

(global-set-key [remap quit-window] ' quit-window-delete)

reply via email to

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