[Top][All Lists]

[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: Mon, 01 Aug 2011 13:13:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Juri Linkov <address@hidden> writes:

>> (setq
>>  display-buffer-alist
>>  '((((regexp . ".*")) (pop-up-window (largest) (lru)))
>>    (((regexp . "^\\*Help\\*$")) (pop-up-window-set-height . 
>> fit-window-to-buffer))
>>    (((regexp . "^\\*.+\\*$")) (pop-up-window-set-height . 20))
>>    (((regexp . ".*")) (pop-up-window-min-height . 15))))
> This is a kind of inheritance by regexps, i.e. a set of buffer names
> matched by a stricter regexp is a subset of buffer names matched by a
> more loose regexp.  ("Inheritance" is not the right term here, but
> acceptable in a sense that a set of objects instantiated by a subclass
> is a subset of the set of all objects instantiated by its parent.)
>> Now the questions are whether (1) writing such specifications is useful
>> in the first place, and (2) whether such implicit inheritance is useful.
>> If they are, I don't see a way to _explicitly_ specify that *Help*
>> buffers should inherit the minimum window height from the specifier for
>> all buffers.
> Yes, writing such specifications is useful and "inheritance by regexps"
> is useful.  But actually I meant inheritance for named specifications
> like macro specifiers (and they are not required to use regexps).

The problem is that the design is trying to do BOTH "inheritance by
regexps" and "inheritance by specifiers" at the same time---there are
too many moving parts.

At this point, I think we really need to figure out a way to make the
system simple.  Even expressiveness must take a back seat---we can
always add expressiveness later by providing an overriding hook!

Here is one suggestion.

1) Expose all the internal "variables" currently living inside
   display-buffer-alist as Lisp variables, e.g. reuse-window-even-sizes
   and pop-up-window-min-height.

2) Make the "display methods" specifier just another one of these
   variables, e.g. call it `display-buffer-method'.

3) Change display-buffer-alist so that it is just a method of overriding
   Lisp variables during display-buffer.  That is to say, it is an alist
   where each element has the form (MATCHER . OVERRIDES).  The first
   entry with matching MATCHER takes effect; its OVERRIDES is an alist
   where each element has the form (VAR . VALUE), which says to bind VAR
   to VALUE.

   MATCHER will include matching the buffer name to a regexp, but we can
   add more complex conditionals later, e.g. a way to specify that a
   variable must have a certain value.

In this scheme, there is no interaction between elements of
display-buffer-alist, and no interaction between specifiers apart from
the familiar behavior of rebinding Lisp variables.  Martin's example
would be implemented like the following:

 (setq pop-up-window-min-height 15)

 (setq pop-up-window-choice '((largest) (lru)))

 (setq display-buffer-method '(pop-up-window))

  '((((regexp . "\\`\\*Help\\*\\'"))
     (pop-up-window-set-height . fit-window-to-buffer))
    (((regexp . "\\`\\*.+\\*\\'"))
     (pop-up-window-set-height . 20))))


reply via email to

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