unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Reitter <david.reitter@gmail.com>
Cc: daniel@brockman.se
Subject: Re: Should killing a help or compile buffer also delete the window?
Date: Mon, 25 Apr 2005 14:41:15 +0100	[thread overview]
Message-ID: <430878965e82cea502cf4fd802417e4a@gmail.com> (raw)

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
   )
)

             reply	other threads:[~2005-04-25 13:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-25 13:41 David Reitter [this message]
2005-04-25 14:11 ` Should killing a help or compile buffer also delete the window? Daniel Brockman
  -- strict thread matches above, loose matches on Subject: below --
2005-04-24  5:45 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=430878965e82cea502cf4fd802417e4a@gmail.com \
    --to=david.reitter@gmail.com \
    --cc=daniel@brockman.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).