emacs-devel
[Top][All Lists]
Advanced

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

Re: display-buffer-alist simplifications


From: Chong Yidong
Subject: Re: display-buffer-alist simplifications
Date: Fri, 05 Aug 2011 13:48:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

martin rudalics <address@hidden> writes:

>> We can specify that these old variables override the new behavior,
>> i.e. `display-buffer-fallback-alist' only applies to buffers not
>> matching `special-display-buffer-names'.
>
> In Emacs 23 a user can specify that a buffer shall be displayed in the
> selected window by adding its name to `same-window-buffer-names'.  An
> application can override the user by binding `same-window-buffer-names'
> temporarily to nil.  We have to offer a similar feature in Emacs 24.
>
> Currently this can be done by setting `display-buffer-alist' from
> `same-window-buffer-names' via `display-buffer-alist-set'.  But how
> would we do that with `display-buffer-fallback-alist'?

IIUC, the intention of same-window-buffer-names is to specify that such
buffers should appear in the "same" window.  But if the argument to
display-buffer specifies some other method for displaying the buffer,
Emacs should obey that argument rather than same-window-buffer-names.

So, this can be handled by

  (setq display-buffer-fallback-alist
    '("\\*\\(shell\\|unsent mail\\|mail\\|inferior-lisp\\|ielm\\)\\*"
      (display-buffer-method reuse-window same-frame)
      (reuse-window-window same)))

Just to be sure we are one the same page, here is how I imagine the
system would work:

 - "Display specifiers" are cons cells (VAR . VALUE).  For example,
   (reuse-window-window other) means that when Emacs is trying to reuse
   a window, it must use a window other than the selected one.

 - `display-buffer-method' is a special display specifier.  Its VALUE is
   a list of "display-methods", one of `reuse-window', `pop-up-window',
   etc., or a "macro specifier" (any symbol except the reserved symbols
   `reuse-window' etc).

   (I'll use the word "macro" for now, but we might want to pick another
   word since "macro" can be confused with keyboard macros.)

 - `display-buffer-alist' is an alist that maps a matcher (regexp,
   label, or matcher function) to an alist of display specifiers.

 - `display-buffer-fallback-alist' is an alist of display specifiers.

 - `display-buffer-macro-specifiers' is an alist that maps a "macro
   specifier" to an alist of display specifiers.  It must include a
   `display-buffer-method' specifier.

 - The action of `display-buffer' can be conceptually described this
   way:

   1. Construct an alist of display specifiers by appending (in order)
      (a) the first matching display specifier alist found in
      `display-buffer-alist', if any
      (b) the SPECIFIERS argument
      (c) `display-buffer-fallback-alist'

   2. Get the value of the `display-buffer-macro-specifiers' specifier
      from this alist.

   3. Iterate through the list of specified methods, trying to display
      with each method, obeying specifiers such as `reuse-window-window'
      drawn from the constructed alist.  If the method fails, try the
      next method in the list.  If it succeeds, stop.

   4. If one of the methods is a macro specifier, add that macro's
      specifier alist "temporarily" to the front of the constructed
      alist.  Then look up `display-buffer-macro-specifiers' again, and
      iterate again through that list, as in step 3.  The "macro" fails
      iff all of its `display-buffer-macro-specifiers' fail.



reply via email to

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