all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help with display-buffer-alist
       [not found] <20220415111531.ktoqlbfuusufjjdv.ref@Ergus>
@ 2022-04-15 11:15 ` Ergus
  2022-04-15 11:47   ` Eric S Fraga
  2022-04-15 14:33   ` Philip Kaludercic
  0 siblings, 2 replies; 5+ messages in thread
From: Ergus @ 2022-04-15 11:15 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with display-buffer-alist
  2022-04-15 11:15 ` Help with display-buffer-alist Ergus
@ 2022-04-15 11:47   ` Eric S Fraga
  2022-04-15 14:33   ` Philip Kaludercic
  1 sibling, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2022-04-15 11:47 UTC (permalink / raw)
  To: help-gnu-emacs

On Friday, 15 Apr 2022 at 13:15, Ergus wrote:
> 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:

Maybe my code which displays a variety of popups either to the far left
or at the bottom will help:

#+begin_src emacs-lisp
  (defun esf/display-buffer-in-side-window (buffer alist)
    (let ((fw (/ 80.0 (frame-width))))
      (display-buffer-in-side-window buffer
                                     (if (> (frame-width) 120)
                                         (list (cons 'window-width fw)
                                               '(side . left)
                                               '(slot . 0)) 
                                       '((window-height . 0.25)
                                         (side . bottom)
                                         (slot . 0)))))) 
  (setq display-buffer-alist
        '(("^\\*Async Shell Command*" . (display-buffer-no-window))
          ("^magit-[a-z]+: " . (esf/display-buffer-in-side-window))
          ("\\*\\(Backtrace\\|Compile-Log\\|Dictionary\\|DICT .*\\|Directory\\|grep\\|[Hh]elp.*\\|Messages\\|Occur\\|org-roam\\|tex-shell\\|vc-\\(diff\\|change-log\\)\\|Shortdoc\\|Warnings\\|wclock\\|WoMan .*\\)\\*"
           (esf/display-buffer-in-side-window))))
#+end_src 

-- 
Eric S Fraga with org 9.5.2 in Emacs 29.0.50 on Debian 11.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with display-buffer-alist
  2022-04-15 11:15 ` Help with display-buffer-alist Ergus
  2022-04-15 11:47   ` Eric S Fraga
@ 2022-04-15 14:33   ` Philip Kaludercic
  2022-04-21  6:36     ` Juri Linkov
  1 sibling, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2022-04-15 14:33 UTC (permalink / raw)
  To: Ergus; +Cc: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with display-buffer-alist
  2022-04-15 14:33   ` Philip Kaludercic
@ 2022-04-21  6:36     ` Juri Linkov
  2022-04-21  7:26       ` Philip Kaludercic
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2022-04-21  6:36 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Ergus, help-gnu-emacs

> making the `add-to-list' call
>
>         (add-to-list 'display-buffer-alist
>                      '("*Occur*"
>                        display-buffer-at-bottom
>                        (window-height . 10)))

This works fine.

> 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 this has no effect when using the nice new buffer-match-p system.
Maybe something still needs fixing?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with display-buffer-alist
  2022-04-21  6:36     ` Juri Linkov
@ 2022-04-21  7:26       ` Philip Kaludercic
  0 siblings, 0 replies; 5+ messages in thread
From: Philip Kaludercic @ 2022-04-21  7:26 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Ergus, help-gnu-emacs

Juri Linkov <juri@linkov.net> writes:

>> making the `add-to-list' call
>>
>>         (add-to-list 'display-buffer-alist
>>                      '("*Occur*"
>>                        display-buffer-at-bottom
>>                        (window-height . 10)))
>
> This works fine.
>
>> Or alternatively if you are tracking the master brach
>>
>>         (add-to-list 'display-buffer-alist
>>                      '((major-mode occur-mode)
                                      ^
                                      there is a typo here, it should be

                                      (major-mode . occur-mode)

>>                        display-buffer-at-bottom
>>                        (window-height . 10)))
>>
>> which uses the new buffer-match-p system.
>
> But this has no effect when using the nice new buffer-match-p system.
> Maybe something still needs fixing?

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-21  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20220415111531.ktoqlbfuusufjjdv.ref@Ergus>
2022-04-15 11:15 ` Help with display-buffer-alist Ergus
2022-04-15 11:47   ` Eric S Fraga
2022-04-15 14:33   ` Philip Kaludercic
2022-04-21  6:36     ` Juri Linkov
2022-04-21  7:26       ` Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.