help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Help with display-buffer-alist


From: Philip Kaludercic
Subject: Re: Help with display-buffer-alist
Date: Fri, 15 Apr 2022 14:33:18 +0000

Ergus <spacibba@aol.com> writes:

> Hi:
>
> I am trying to mimic somehow the swiper behavior with occur. The first
> step for that is to put the occur window always at bottom which was
> pretty simple with this:
>
> (add-to-list 'display-buffer-alist ("*Occur*" display-buffer-at-bottom))
                                       ^ watch out, this is a regular
                                       expression matching a buffer
                                       name, so the * has to be escaped
                                       [0].


> But now I want somehow to limit the window height to 10 lines.
>
> With the documentation of display-buffer and display-buffer-alist It
> says that there should be (CONDITION . ACTION) where:
>
> ACTION is a cons cell (FUNCTIONS . ALIST), where FUNCTIONS is an
>   action function or a list of action functions and ALIST is an
>   action alist.  Each such action function should accept two
>   arguments: a buffer to display and an alist of the same form as
>   ALIST.  See `display-buffer' for details.
>
>
> So I tried substituting display-buffer-at-bottom with:
>
> (display-buffer-at-bottom . (window-height . 10))

Note that (window-height . 10) is not an alist, but an element of an
alist.  The alist you want to pass is

        ((window-height . 10))

which means (FUNCTION . ALIST) is

        (display-buffer-at-bottom . ((window-height . 10)))

or simply

        (display-buffer-at-bottom (window-height . 10))

making the `add-to-list' call

        (add-to-list 'display-buffer-alist
                     '("*Occur*"
                       display-buffer-at-bottom
                       (window-height . 10)))

Or alternatively if you are tracking the master brach

        (add-to-list 'display-buffer-alist
                     '((major-mode occur-mode)
                       display-buffer-at-bottom
                       (window-height . 10)))

which uses the new buffer-match-p system.

> But I am obviously doing something wrong because this just doesn't
> work... so the question is: how do I use correctly the
> (FUNCTIONS . ALIST) in the extended way?
>
> Thanks in advance,
> Ergus...
>
> PD: Maybe another example with this answer may be added to the docstring.
>
>

-- 
        Philip Kaludercic



reply via email to

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