unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Should killing a help or compile buffer also delete the window?
@ 2005-04-24  5:45 Daniel Brockman
  2005-04-24 11:02 ` Robert J. Chassell
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Daniel Brockman @ 2005-04-24  5:45 UTC (permalink / raw)


I've always found it annoying that Emacs seems to have a habit of
leaving junk windows around whenever you invoke something that needs
to display information in a temporary buffer.  I think it just gives a
really sloppy impression, especially when you aren't used to it.
Two of the most common examples might be `M-x compile' and `C-h f'.
It also happens with things like `M-x grep' and `M-x locate'.

I realize that you can't expect Emacs to know when you are done with a
window unless you actually tell when.  The obvious way to tell when is
to type `C-x 1' or `C-x 0', but this leaves the temporary buffer
lingering, which makes me nervous.

When I was new to Emacs, I would always kill a garbage buffer before
deleting its temporary window.  Eventually, I discovered `C-x 4 0' and
started using that.  As time went by (and I got lazier), I gradually
began to accept the fact that you really can't avoid having a bunch of
old garbage buffers unless you spend a lot of time chasing them down,
so I started just doing `C-x 1', though it always made me feel dirty.

Now to the point of this message.  Some time ago I started using
Dictionary Mode[1], which has caused me to once again pick up the
habit of killing temporary buffers.  As you might know, killing a
dictionary buffer automatically kills the window as well, unless the
window was already there when the dictionary buffer was created.
This makes a lot of sense to me --- so much sense that the normal
Emacs behavior has once again started to annoy me.

I believe the Right Thing to do when the user kills a temporary buffer
whose window was created as a side-effect of displaying the buffer in
question is to restore the old window configuration.  At least when
the automatically created window hasn't been used for anything else,
Emacs should take the hint and get the window out of the user's face.

I'm sorry if this is an old argument, or if this is not the right time
to discuss this matter.

-- 
Daniel Brockman <daniel@brockman.se>

[1] http://www.myrkr.in-berlin.de/dictionary/

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: Should killing a help or compile buffer also delete the window?
@ 2005-04-25 13:41 David Reitter
  2005-04-25 14:11 ` Daniel Brockman
  0 siblings, 1 reply; 16+ messages in thread
From: David Reitter @ 2005-04-25 13:41 UTC (permalink / raw)
  Cc: daniel

Daniel Brockman <daniel <at> brockman.se> writes:

 > > I don't want to spend time on thinking about it because I think it
 > > is unlikely to get anywhere.
 >
 > To be honest, I'm growing less and less confident myself that it would
 > be the best default behavior.  While many people would definitely find
 > it convenient, I suspect others would just be confused or annoyed.

I have the same problem, yet I want the behavior that you suggested in 
most cases.

Here's what we do in AquaMacs (an Emacs distro with UI customizations 
for the Mac).
It's quite a hack considered that the solution is not generic, but 
lists specific buffer names that have
their own behavior.

However, we don't only close windows for killed buffers, but we also 
create new frames (and thus a new
window) for many types of newly buffers. But we can only do so 
selectively, because a lot of modes
open new windows with new buffers that are not supposed to go into a 
new frame (consider ispell).

So this is the solution that I've arrived at after playing around a 
bit; but I don't consider it very universal.
It's a difficult problem as it has been said before.

===

(setq one-buffer-one-frame t)

(defun open-in-other-frame-p (buf default)

(set 'bufname (if (eq (type-of buf) 'string)
							 buf
							 (buffer-name buf)))
  ;; i guess we should use ;; with special-display-regexps instead
(if one-buffer-one-frame
(if   (string-match "[ ]*\\*.*\\*[ ]*" bufname)
     (if (or (equal "\*Messages\*" bufname)
	        (equal "\*info\*" bufname)
		(equal  "\*scratch\*" bufname)
		(equal  "\*Help\*" bufname)
		(equal "\*Backtrace\*" bufname)
		 (string-match "[ ]*\*Customize*" bufname)
		)
	t
       nil)
     default)
nil
))

;; only for certain special buffers
(defadvice switch-to-buffer (around sw-force-other-frame (&rest args) 
activate)
       (if (open-in-other-frame-p (car args) nil)
        (apply #'switch-to-buffer-other-frame args)
        ad-do-it)
        )

;; we'd like to open new frames for some stuff
  (defadvice find-file (around force-other-frame (&rest args) activate)

      (if one-buffer-one-frame
       (apply #'find-file-other-frame args)
       ad-do-it)
       )

;; buffer selected from menu bar (but not from popup menu when doing 
C-mouse-1)
(defadvice menu-bar-select-buffer (around 
select-buffer-force-other-frame (&rest args) activate)
(interactive)
      (if one-buffer-one-frame
       (switch-to-buffer-other-frame last-command-event)
       ad-do-it)
       )

;; delete window when buffer is killed
(defadvice kill-buffer (around force-delete-frame (&rest args) activate)
(setq last-sel-window (selected-window))
(if
     (and (open-in-other-frame-p (car args) t)
	 (not (special-display-p (buffer-name)))
	 (eq (window-buffer) (car args)))
     (list
      (condition-case nil
	 (
	  list
	  ad-do-it

	  (delete-window last-sel-window)
	  )
        (error  ;; if this is the last open frame, just make it invisible

	(make-frame-invisible (selected-frame) t)
	)
        ))
   ;; else  ; don't delete
   ad-do-it
   )
)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-04-26 20:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-24  5:45 Should killing a help or compile buffer also delete the window? Daniel Brockman
2005-04-24 11:02 ` Robert J. Chassell
2005-04-24 13:35   ` Alan Mackenzie
2005-04-25 10:32     ` Robert J. Chassell
2005-04-24 21:22 ` Richard Stallman
2005-04-24 22:50   ` Daniel Brockman
2005-04-26 10:04     ` Richard Stallman
2005-04-25 17:20 ` Drew Adams
2005-04-25 21:38   ` Daniel Brockman
2005-04-25 17:22 ` Kevin Rodgers
2005-04-25 19:04 ` Stefan Monnier
2005-04-25 19:37   ` Daniel Brockman
2005-04-26 20:50     ` Stefan Monnier
2005-04-26 14:32   ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-04-25 13:41 David Reitter
2005-04-25 14:11 ` Daniel Brockman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).