emacs-devel
[Top][All Lists]
Advanced

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

Re: display-buffer-alist simplifications


From: Juri Linkov
Subject: Re: display-buffer-alist simplifications
Date: Fri, 05 Aug 2011 19:45:05 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> What problems do you guys (fore)see with such a setup?

Let's see how such a setup serves some specific test-cases:

1. The user should be able to specify whether to display the buffer
in the same window or in another window and which window
to select after displaying the buffer in another window.

Currently these differences are encoded in function names:

  `switch-to-buffer' - display buffer in the selected window
  `pop-to-buffer' - display buffer and select its window
  `display-buffer' - display buffer, but don't select its window

and they are used quite inconsistently in applications.
For instance, to display the "*vc-diff*" buffer,
`vc-diff-internal' calls (pop-to-buffer "*vc-diff*"),
but `vc-annotate-show-diff-revision-at-line-internal'
calls (switch-to-buffer "*vc-diff*").

How the user can override these application defaults?

To display the "*vc-diff*" buffer in the selected window
(like `switch-to-buffer'):

  (setq display-buffer-alist '(
    ("*vc-diff*" display-buffer-same-window)))

To display the "*vc-diff*" buffer and not select its window:

  (setq display-buffer-alist '(
    ("*vc-diff*" display-buffer-other-window)))

To display the "*vc-diff*" buffer and select its window
(like `pop-to-buffer'):

  (setq display-buffer-alist '(
    ("*vc-diff*" display-buffer-pop-to-buffer)))

2. How the user can override the global defaults?

For instance, I want to display the *Help* buffer in the selected window.
But when it's already displayed in another window, then prefer reusing
another window (because otherwise two windows will be displayed with the
same buffer).  And not reuse a window on another frame.

Should I write a new function and use it like:

  (setq display-buffer-alist '(
    ("*Help*" display-buffer-other-window-same-frame-or-same-window)))

Or provide additional arguments to the predefined functions like:

  (setq display-buffer-alist '(
    ("*Help*" display-buffer-same-window reuse-other-window-same-frame)))

Or

  (setq display-buffer-alist '(
    ("*Help*" display-buffer-same-window (reuse-window . same-frame))))

3. How applications can override the global default?

For instance, what to do to fit the command `info-other-window':

  (defun info-other-window (&optional file-or-node)
    "Like `info' but show the Info buffer in another window."
    (interactive (if current-prefix-arg
                     (list (read-file-name "Info file name: " nil nil t))))
    (let (same-window-buffer-names same-window-regexps (pop-up-windows t))
      (info file-or-node)))

info the new setup?  Maybe something like this:

(defalias 'info-other-window 'info)

;;;###autoload (add-hook 'display-buffer-alist
;;;###autoload           '(info-check-command-name 
display-buffer-pop-to-buffer))

(defun info-check-command-name (buffer-name)
  (and (eq this-command 'info-other-window)
       (string-match-p "\\*info\\*\\(\\|<[0-9]+>\\)" buffer-name)))



reply via email to

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