[Top][All Lists]

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

Re: Should killing a help or compile buffer also delete the window?

From: David Reitter
Subject: Re: Should killing a help or compile buffer also delete the window?
Date: Mon, 25 Apr 2005 14:41:15 +0100

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

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

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

;; 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)
     (if one-buffer-one-frame
      (switch-to-buffer-other-frame last-command-event)

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

          (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

reply via email to

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