[emacs-berlin] Open a new window splitting the frame horizontally

Abby Henríquez Tejera paradoja at gmail.com
Mon Nov 18 17:48:43 UTC 2024


Hi,

I'm certainly no expert on this. I tried to replicate your error, but
interestingly it didn't (but the behaviour was the one you wanted).


Reading the description for ~display-buffer-alist, it's "an alist of
elements (CONDITION . ACTION)".

The condition part you already have, the "\\*rg\\*", the action part,
is itself another alist (FUNCTIONS . ALIST) "where FUNCTIONS is an
  action function or a list of action functions". This would make me
think that the correct snippet would be:

(setopt
 display-buffer-alist
 '(("\\*rg\*"
    (display-buffer-below-selected)
    (display-buffer-at-bottom)
    )))

or
(setopt
 display-buffer-alist
 '(("\\*rg\*"
    (display-buffer-below-selected)
    )))
(with just one of the possible functions, as both seem to do different things)

I haven't been able to try it, but maybe trying

Another thing, not one that you have complained about, that I notice
is that you set the variable completely, as in, if it already has a
value it removes it. For variables like this I prefer to add to the
list, instead of setting it completely. Given that I don't usually use
the custom.el functionality, I just use something like

(add-to-list 'display-buffer-alist
             '("\\*rg\\*"
               (display-buffer-below-selected)))

But if you prefer to use set-opt maybe something like:

(setopt display-buffer-alist
        (push display-buffer-alist
             '("\\*rg\\*"
               (display-buffer-below-selected))))


Which would "preserve" any value it already had, instead of overwriting it.

I don't know if this is helpful, but I hope you fix your problem!


El lun, 18 nov 2024 a las 16:12, jman (<emacs-berlin at city17.xyz>) escribió:
>
>
> Hi, I'm trying to modify the `rg.el` package (an interface to ripgrep[0]) when it opens the buffer
> with the search results. I'm vaguely familiar with concepts like "frame", "window" and "buffer" and
> IIUC by default Emacs opens a window horizontally or vertically based on space available (using
> `split-window-sensibly`).
>
> I want to modify this behaviour so that the search results window containing the *rg* buffer always
> splits the frame horizontally.
>
> I've tried asking the rg.el maintainer but I don't understand their suggestion:
> https://github.com/dajva/rg.el/issues/181
>
> I've looked at the Emacs documentation[1]. I think I can accomplish this with the following snippet:
>
> (setopt
>  display-buffer-alist
>  '(("\\*rg\*"
>     (display-buffer-below-selected display-buffer-at-bottom)
>     )))
>
> somehow it works because the frame is split horizontally but I get this error: "error in process
> sentinel: Symbol’s function definition is void: nil". The toggle-debug-on-error is not very helpful:
>
> Debugger entered--Lisp error: (void-function nil)
>   nil(#<buffer *rg*> "finished\n")
>   compilation-handle-exit(exit 0 "finished\n")
>   compilation-sentinel(#<process rg> "finished\n")
>
> Any comment on my approach? Any suggestion?
>
> Thanks!
>
> [0]: https://github.com/dajva/rg.el
> [1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Displaying-Buffers.html
> _______________________________________________
> emacs-berlin mailing list
> emacs-berlin at emacs-berlin.org
> https://mailb.org/mailman/listinfo/emacs-berlin


More information about the emacs-berlin mailing list