* Custom for quit-window? [not found] <20220107180521.7zgkfxro7c7tkdi7.ref@Ergus> @ 2022-01-07 18:05 ` Ergus 2022-01-07 18:11 ` [External] : " Drew Adams 2022-01-07 18:20 ` John W Higgins 0 siblings, 2 replies; 5+ messages in thread From: Ergus @ 2022-01-07 18:05 UTC (permalink / raw) To: help-gnu-emacs Hi: 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. Thanks in advance, Ergus ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [External] : Custom for quit-window? 2022-01-07 18:05 ` Custom for quit-window? Ergus @ 2022-01-07 18:11 ` Drew Adams 2022-01-08 18:23 ` Ergus 2022-01-07 18:20 ` John W Higgins 1 sibling, 1 reply; 5+ messages in thread From: Drew Adams @ 2022-01-07 18:11 UTC (permalink / raw) To: Ergus, help-gnu-emacs@gnu.org > 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") (set-window-parameter 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) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] : Custom for quit-window? 2022-01-07 18:11 ` [External] : " Drew Adams @ 2022-01-08 18:23 ` Ergus 2022-01-09 0:26 ` Drew Adams 0 siblings, 1 reply; 5+ messages in thread From: Ergus @ 2022-01-08 18:23 UTC (permalink / raw) To: Drew Adams; +Cc: help-gnu-emacs@gnu.org On Fri, Jan 07, 2022 at 06:11:49PM +0000, Drew Adams wrote: >> 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. Hi Drew: > >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") > (set-window-parameter > 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) > I just tried your suggestion and I don't get any difference... I saw that you had a package called window+ that is supposed to do more or less what I want, is it right? So actually kill the buffer like with "C-u q". But I am still not sure why this is not an currently an option and the implementation not simpler, or if there are some "bad" side effects in the implementation suggested in my initial email. I mean, to make it less intrusive and only call kill when called interactively (until I am sure there are not any undesired side effect) is this fine? (defcustom quit-window-kills-interactive nil "Some docstring...") (defun quit-window (&optional kill window) (interactive "P") (with-current-buffer (window-buffer (window-normalize-window window)) (run-hooks 'quit-window-hook)) (quit-restore-window window (if (or kill (and quit-window-kills-interactive (called-interactively-p 'any))) 'kill 'bury))) Thanks in advance, Ergus ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [External] : Custom for quit-window? 2022-01-08 18:23 ` Ergus @ 2022-01-09 0:26 ` Drew Adams 0 siblings, 0 replies; 5+ messages in thread From: Drew Adams @ 2022-01-09 0:26 UTC (permalink / raw) To: Ergus; +Cc: help-gnu-emacs@gnu.org > >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") > > (set-window-parameter > > 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) > > I just tried your suggestion and I don't get any difference... You don't get any difference from what? I didn't try your code. I was just passing along the info that this is what I use. (It's in my little library `misc-cmds.el'.) > I saw that you had a package called window+ that is supposed to do more or > less what I want, is it right? So actually kill the buffer like with > "C-u q". The (re)definition of `quit-window' in `window+.el' is only for Emacs versions prior to 24. That code is conditionalized with: (when (< emacs-major-version 24)...). You don't need it for Emacs 24+. You can, I assume still use it with Emacs 24+, though, if you like. Part of what I was passing along was to say that you can remap all keys that are normally bound to `quit-window' to some other command. > But I am still not sure why this is not an currently an option and the > implementation not simpler, or if there are some "bad" side effects in > the implementation suggested in my initial email. I can't speak to either of those things. The code I use was, IIRC, suggested by Martin Rudalics after I complained about Emacs having changed the behavior of `quit-window'. The code I use, on his suggestion, provides behavior like Emacs did before the change. > I mean, to make it less intrusive and only call kill when called > interactively (until I am sure there are not any undesired side effect) > is this fine? To only do it when interactive, don't redefine any original function that's also used noninteractively. Just define your own command, bind it to keys, and don't invoke it noninteractively. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Custom for quit-window? 2022-01-07 18:05 ` Custom for quit-window? Ergus 2022-01-07 18:11 ` [External] : " Drew Adams @ 2022-01-07 18:20 ` John W Higgins 1 sibling, 0 replies; 5+ messages in thread From: John W Higgins @ 2022-01-07 18:20 UTC (permalink / raw) To: help-gnu-emacs Good Morning, On Fri, Jan 7, 2022 at 10:07 AM Ergus <spacibba@aol.com> wrote: > Hi: > > Is it there a "simple method" to make quit-window to kill the buffer > without needing a prefix? > I'm not sure I fully understand your situation - but I have this (global-set-key (kbd "<f9>") 'kill-current-buffer) in my config - I just hit F9 to kill a buffer and clean up my work area. Obviously you could pick another key. My apologies if I completely misunderstood your need here. John ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-09 0:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20220107180521.7zgkfxro7c7tkdi7.ref@Ergus> 2022-01-07 18:05 ` Custom for quit-window? Ergus 2022-01-07 18:11 ` [External] : " Drew Adams 2022-01-08 18:23 ` Ergus 2022-01-09 0:26 ` Drew Adams 2022-01-07 18:20 ` John W Higgins
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.