* Should delete-window switch to next buffer when there is only one window?
@ 2014-01-14 22:30 Ernest Adrogué
2014-01-14 23:57 ` Drew Adams
2014-01-15 13:31 ` Stefan Monnier
0 siblings, 2 replies; 13+ messages in thread
From: Ernest Adrogué @ 2014-01-14 22:30 UTC (permalink / raw)
To: help-gnu-emacs
Hi.
Currently if you attempt to delete an only window, the following message
shows up
Attempt to delete minibuffer or sole ordinary window
I think that perhaps it would be better if it switched buffers instead.
What do you think?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
[not found] <mailman.11954.1389738686.10748.help-gnu-emacs@gnu.org>
@ 2014-01-14 22:40 ` Emanuel Berg
2014-01-14 22:43 ` Emanuel Berg
2014-01-14 23:16 ` Peter
1 sibling, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2014-01-14 22:40 UTC (permalink / raw)
To: help-gnu-emacs
Ernest Adrogué <nfdisco@gmail.com> writes:
> Currently if you attempt to delete an only window,
> the following message shows up
>
> Attempt to delete minibuffer or sole ordinary window
>
> I think that perhaps it would be better if it
> switched buffers instead. What do you think?
I haven't thought about that, but this is the kind of
hacking I like, when Emacs figures out what you mean,
based on something that isn't part of the command
itself.
Try this:
(defun delete-window-or-switch ()
(interactive)
(if (= 1 (count-windows)) (switch-buffer)
(delete-window) ))
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 22:40 ` Should delete-window switch to next buffer when there is only one window? Emanuel Berg
@ 2014-01-14 22:43 ` Emanuel Berg
0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-14 22:43 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> Try this:
>
> (defun delete-window-or-switch () (interactive) (if (=
> 1 (count-windows)) (switch-buffer) (delete-window) ))
Oh, "switch-buffer" is mine: try (switch-to-buffer nil)
instead.
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
[not found] <mailman.11954.1389738686.10748.help-gnu-emacs@gnu.org>
2014-01-14 22:40 ` Should delete-window switch to next buffer when there is only one window? Emanuel Berg
@ 2014-01-14 23:16 ` Peter
2014-01-14 23:32 ` Emanuel Berg
` (2 more replies)
1 sibling, 3 replies; 13+ messages in thread
From: Peter @ 2014-01-14 23:16 UTC (permalink / raw)
To: help-gnu-emacs
On Wednesday, January 15, 2014 9:30:57 AM UTC+11, Ernest Adrogué wrote:
> Hi.
>
>
>
> Currently if you attempt to delete an only window, the following message
>
> shows up
>
>
>
> Attempt to delete minibuffer or sole ordinary window
>
>
>
> I think that perhaps it would be better if it switched buffers instead.
>
> What do you think?
No, I think it is doing the right thing. It doesn't make any sense for YOUR code to delete the only window that exists. If it just switched buffers (to what? what rule should apply in this case? A random buffer selection?) then it isn't doing what you requested - which is to delete the window.
I think a bit more thought on your side should be applied rather than suggesting that Emacs behaviour change to suit you.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 23:16 ` Peter
@ 2014-01-14 23:32 ` Emanuel Berg
2014-01-15 8:39 ` Marcin Borkowski
2014-01-14 23:33 ` Drew Adams
2014-01-15 1:19 ` Ernest Adrogué
2 siblings, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2014-01-14 23:32 UTC (permalink / raw)
To: help-gnu-emacs
Peter <peter.milliken@gmail.com> writes:
> No, I think it is doing the right thing. It doesn't
> make any sense for YOUR code to delete the only
> window that exists. If it just switched buffers (to
> what? what rule should apply in this case? A random
> buffer selection?) then it isn't doing what you
> requested - which is to delete the window.
That's true in a schoolbook sense, but: whenever there
is an association that something should do something,
and then that something doesn't happen, this
association is often sane, at least if it appears time
and again. You should trust your mind and instinct more
than Emacs!
The least you can do is pause and think about it.
> I think a bit more thought on your side should be
> applied rather than suggesting that Emacs behaviour
> change to suit you.
Ha ha ha, is this in the Lisp manual as well?! On the
contrary, it is much better to change Emacs than to
change your gut feeling, at least if the gut feeling
makes sense, in what case, why on earth change it?
But remember the other side of the story. If the gut
feeling doesn't make sense, you can use Emacs to get
rid of it by *not* configuring Emacs. That way, you
force yourself to form a new pattern in you
brain/body/wherever.
There are so many things you can't change in life but
as for your brain, body, and editor, you at least have
a fair shot. Don't waste it.
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Should delete-window switch to next buffer when there is only one window?
2014-01-14 23:16 ` Peter
2014-01-14 23:32 ` Emanuel Berg
@ 2014-01-14 23:33 ` Drew Adams
2014-01-15 1:19 ` Ernest Adrogué
2 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2014-01-14 23:33 UTC (permalink / raw)
To: Peter, help-gnu-emacs
> No, I think it is doing the right thing. It doesn't make any sense
> for YOUR code to delete the only window that exists. If it just
> switched buffers (to what? what rule should apply in this case? A
> random buffer selection?) then it isn't doing what you requested -
> which is to delete the window.
>
> I think a bit more thought on your side should be applied rather
> than suggesting that Emacs behaviour change to suit you.
Put it another way, perhaps: Define your own command (i.e., with a
different name), and remap `delete-window' to your command, for
(your own) interactive use.
Two points are important here:
1. `delete-window' is an Emacs function used in many places. It
is not just a command, and it is not invoked only interactively
(e.g., via `C-x 0').
2. Try it out on yourself before suggesting that Emacs adopt it.
Use it for a while (months? years?).
These are two things to keep in mind whenever you have an idea
about changing the default behavior of some command.
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Should delete-window switch to next buffer when there is only one window?
2014-01-14 22:30 Ernest Adrogué
@ 2014-01-14 23:57 ` Drew Adams
2014-01-15 8:45 ` Marcin Borkowski
2014-01-15 13:31 ` Stefan Monnier
1 sibling, 1 reply; 13+ messages in thread
From: Drew Adams @ 2014-01-14 23:57 UTC (permalink / raw)
To: Ernest Adrogué, help-gnu-emacs
> Currently if you attempt to delete an only window, the following
> message shows up: "Attempt to delete minibuffer or sole ordinary
> window"
>
> I think that perhaps it would be better if it switched buffers
> instead. What do you think?
No. A user who hits `C-x 0' is asking to delete the window.
S?he is not asking to switch to another buffer or buy a beer.
These are very different actions, with different purposes.
Sure, you could combine them, but they don't seem like a useful
combination to me. You either want to switch to a different
buffer or you do not. If you do, then you want to do that in
any case, not just when the window is alone in its frame.
A user who wants to delete the selected window wants to do just
that. So the error message is appropriate, to let the user know
that it is the sole window in its frame.
Now you might indeed look for something much closer to deleting
the window, when it is alone in its frame. If you want to get
rid of it in that case too, it's likely that you really want to
get rid of the frame altogether, including its window.
That is likely to be the case if you, like me, use lots of frames,
including for things like pop-up windows that you do want to just
remove. Whereas it does not make sense to try to remove the only
window shown in a frame (hence the error message), it does make
sense to remove a frame.
For that, library `frame-cmds.el' (note the name - it is
especially for people who like to use frames) redefines command
`delete-window' to invoke `delete-frame' when the window is the
only one in its frame.
(Yes, this behavior is maybe not for everyone. Using the
library is of course optional. But IMO, this is the behavior
that `delete-window' should have, which is why I redefined it
instead of just remapping its keys for interactive use.)
And I in fact suggest that users of `frame-cmds.el' remap any
keys bound to `delete-window' to command `delete-windows-for'
instead (also defined in `frame-cmds.el'). That command is
just like the redefined `delete-window', except that with a
prefix arg it deletes all windows showing the buffer (anywhere).
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 23:16 ` Peter
2014-01-14 23:32 ` Emanuel Berg
2014-01-14 23:33 ` Drew Adams
@ 2014-01-15 1:19 ` Ernest Adrogué
2014-01-15 5:12 ` Thien-Thi Nguyen
[not found] ` <mailman.11970.1389762517.10748.help-gnu-emacs@gnu.org>
2 siblings, 2 replies; 13+ messages in thread
From: Ernest Adrogué @ 2014-01-15 1:19 UTC (permalink / raw)
To: help-gnu-emacs
2014-01-14, 15:16 (-0800); Peter escriu:
> No, I think it is doing the right thing. It doesn't make any sense for
> YOUR code to delete the only window that exists. If it just switched
> buffers (to what? what rule should apply in this case? A random buffer
> selection?) then it isn't doing what you requested - which is to delete
> the window.
I was thinking from the user point of view. In my mental model (which maybe
doesn't reflect how Emacs really works, but nonetheless) I think of windows
as being stacked, and when I do C-x 0 to me is like saying send the top
window to the bottom of the stack. In this context, it would make sense
for C-x 0 to switch to a different buffer when there is only one window in
the frame.
> I think a bit more thought on your side should be applied rather than
> suggesting that Emacs behaviour change to suit you.
Ok, I will try to think harder before I make another suggestion. Sorry for
wasting your time!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-15 1:19 ` Ernest Adrogué
@ 2014-01-15 5:12 ` Thien-Thi Nguyen
[not found] ` <mailman.11970.1389762517.10748.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 13+ messages in thread
From: Thien-Thi Nguyen @ 2014-01-15 5:12 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]
() Ernest Adrogué <nfdisco@gmail.com>
() Wed, 15 Jan 2014 02:19:42 +0100
I was thinking from the user point of view.
It's good that you say this!
In my mental model (which maybe doesn't reflect how Emacs really
works, but nonetheless) I think of windows as being stacked, and when
I do C-x 0 to me is like saying send the top window to the bottom of
the stack. In this context, it would make sense for C-x 0 to switch
to a different buffer when there is only one window in the frame.
(defun begone! ()
(interactive)
(condition-case nil
(delete-window)
(error (bury-buffer))))
(global-set-key "\C-x0" 'begone!)
Ok, I will try to think harder before I make another suggestion.
Sorry for wasting your time!
No worries. I think from the original post we would have arrived more
easily at the above code (or something like it) if there had been:
s/instead/in that case/
Insert appropriate Gandalf quote, here. :-D
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 23:32 ` Emanuel Berg
@ 2014-01-15 8:39 ` Marcin Borkowski
0 siblings, 0 replies; 13+ messages in thread
From: Marcin Borkowski @ 2014-01-15 8:39 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-01-15, o godz. 00:32:03
Emanuel Berg <embe8573@student.uu.se> napisał(a):
> There are so many things you can't change in life but
> as for your brain, body, and editor, you at least have
> a fair shot.
I'm stealing this for a signature quote.
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 23:57 ` Drew Adams
@ 2014-01-15 8:45 ` Marcin Borkowski
0 siblings, 0 replies; 13+ messages in thread
From: Marcin Borkowski @ 2014-01-15 8:45 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-01-14, o godz. 15:57:45
Drew Adams <drew.adams@oracle.com> napisał(a):
> > Currently if you attempt to delete an only window, the following
> > message shows up: "Attempt to delete minibuffer or sole ordinary
> > window"
> >
> > I think that perhaps it would be better if it switched buffers
> > instead. What do you think?
>
> No. A user who hits `C-x 0' is asking to delete the window.
> S?he is not asking to switch to another buffer or buy a beer.
>
> These are very different actions, with different purposes.
> Sure, you could combine them, but they don't seem like a useful
> combination to me. You either want to switch to a different
> buffer or you do not. If you do, then you want to do that in
> any case, not just when the window is alone in its frame.
>
> A user who wants to delete the selected window wants to do just
> that. So the error message is appropriate, to let the user know
> that it is the sole window in its frame.
>
> Now you might indeed look for something much closer to deleting
> the window, when it is alone in its frame. If you want to get
> rid of it in that case too, it's likely that you really want to
> get rid of the frame altogether, including its window.
>
> That is likely to be the case if you, like me, use lots of frames,
> including for things like pop-up windows that you do want to just
> remove. Whereas it does not make sense to try to remove the only
> window shown in a frame (hence the error message), it does make
> sense to remove a frame.
>
> For that, library `frame-cmds.el' (note the name - it is
> especially for people who like to use frames) redefines command
> `delete-window' to invoke `delete-frame' when the window is the
> only one in its frame.
And when it's the *only* window in the *only* frame? ;)
(BTW: I agree that defining *another* command and remapping C-x 0 to it
is the best option here.)
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
2014-01-14 22:30 Ernest Adrogué
2014-01-14 23:57 ` Drew Adams
@ 2014-01-15 13:31 ` Stefan Monnier
1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-01-15 13:31 UTC (permalink / raw)
To: help-gnu-emacs
> Currently if you attempt to delete an only window, the following message
> shows up
> Attempt to delete minibuffer or sole ordinary window
> I think that perhaps it would be better if it switched buffers instead.
> What do you think?
While it might make a lot of sense in the way you use delete-window, it
does not make sense in general (e.g. it makes no sense in the way I use
delete-window, for example).
For me, when there's only one window left, delete-window should delete
the window's frame, and if it's the last frame, then it should
kill Emacs. But I'm not sure this behavior would make sense for all
users either.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Should delete-window switch to next buffer when there is only one window?
[not found] ` <mailman.11970.1389762517.10748.help-gnu-emacs@gnu.org>
@ 2014-01-15 21:13 ` Emanuel Berg
0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-15 21:13 UTC (permalink / raw)
To: help-gnu-emacs
Thien-Thi Nguyen <ttn@gnu.org> writes:
> (defun begone! () (interactive) (condition-case nil
> (delete-window) (error (bury-buffer))))
> (global-set-key "\C-x0" 'begone!)
That's better Elisp than mine, so let me be a sour
loser by saying that newcomers should note the
"unmodular" one-namespace nature of Emacs, which
explains the elaborate use of prefixes and descriptive
function names... ;)
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-01-15 21:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.11954.1389738686.10748.help-gnu-emacs@gnu.org>
2014-01-14 22:40 ` Should delete-window switch to next buffer when there is only one window? Emanuel Berg
2014-01-14 22:43 ` Emanuel Berg
2014-01-14 23:16 ` Peter
2014-01-14 23:32 ` Emanuel Berg
2014-01-15 8:39 ` Marcin Borkowski
2014-01-14 23:33 ` Drew Adams
2014-01-15 1:19 ` Ernest Adrogué
2014-01-15 5:12 ` Thien-Thi Nguyen
[not found] ` <mailman.11970.1389762517.10748.help-gnu-emacs@gnu.org>
2014-01-15 21:13 ` Emanuel Berg
2014-01-14 22:30 Ernest Adrogué
2014-01-14 23:57 ` Drew Adams
2014-01-15 8:45 ` Marcin Borkowski
2014-01-15 13:31 ` Stefan Monnier
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.