Closed manueldeljesus closed 1 year ago
julia-repl does not do anything special here, just try the global emacs settings, eg see customizations here, or questions similar to this one. That said, I always found it finicky. See also https://www.emacswiki.org/emacs/ToggleWindowSplit.
I think that display actions are what you need:
(add-to-list 'display-buffer-alist
'("\\*julia\\*" (display-buffer-reuse-window display-buffer-in-direction)
(direction . right)))
I have been checking the references that @tpapp proposed, but I have not been able to make them work. Display actions look promising, but your code does not seem to work for me.
I have been reading a bit the code, and I have understood -may be wrong- that julia-repl forces the REPL window to open in the bottom part of the frame, am I right? Shouldn't I need to change the function that calls the REPL? Or this is what display actions do? Changing the behavior established by default?
I apologize in advance if what I am asking is so basic. I am always having a hard time wrapping my head around Elisp concepts.
After several more tests, I have observed that the code works but only if I load it once I have my julia file opened. It looks like I am not configuring display-buffer-alist
in the correct moment in my initial config file. Am I assuming correctly that I should add the display action after the julia-repl
package has loaded?
julia-repl forces the REPL window to open in the bottom part of the frame, am I right?
I don't think so. We use pop-to-buffer
.
That said, we should be able to specify an action
that is passed to display-buffer
.
You can experiment with this by modifying the line pop-to-buffer
line in julia-repl
--- just add an action you like. If you find one that helps, tell me and I will add a customizable option.
So far I believe that the problem that I am experiencing is that display-buffer-alist
is being modified after my configuration modifies it, and for some reason my modification is being lost somewhere.
I will give an eye to the pop-to-buffer
line as you suggest. I will let you know if I get to make it work somehow.
Thanks for the feedback.
After many tests (it must be said that a noob with respect to Emacs Lisp, so most of the tests may have been absurd to begin with), I can confirm that @wentasah 's code works, so I imagine that the action is well defined and has the intended result.
However, I cannot, for the life of me, pass the action to pop-to-buffer
without it complaining or without it having no effect whatsoever. What format should the action have?
What I have been trying that does not work is this:
(pop-to-buffer inferior-buffer ((display-buffer-reuse-window display-buffer-in-direction) (direction . right)))
and some other variations, quoting some parts of the action and such. What may I be missing?
This works for me:
(pop-to-buffer inferior-buffer '((display-buffer-reuse-window display-buffer-in-direction) (direction . right)))))
Note that actions specified in display-buffer-alist
have higher priority than actions passed to pop-to-buffer
and similar functions. So the above action will be ignored if display-buffer-alist
contains some entry similar to what I posted above.
I believe that I tried that also and it didn't work, BUT it may have been because of the precedence that you refer to about display-buffer-alist
.
The problem may then be with my configuration, that somehow display-buffer-alist
is being redefined after I set the value that I want for it. I have already opened a question in Doom Emacs' Discord. Indeed, when I open a julia file, display-buffer-alist
gets populated with a julia entry that is not the one that I defined and that set the opening position to bottom.
Thank you very much for your help. I will try to see if I can fix this with Doom. I will let you know if I reach any conclusion.
It seems that a critical piece of information about the problem was that I was using Doom Emacs, which uses some packages (within the popup module) to simplify the configuration of popup windows. This makes directly dealing with display-buffer-alist
almost impossible.
The solution to my problem was then to include the following code in my config.el
:
(after! julia-repl
(set-popup-rule! "^\\*julia:*.*\\*$" :quit nil :side 'right :width .5)
)
With this configuration, the display action gets properly added to display-buffer-alist
on top of the default one -that was forcing the appearance on the bottom-, and the REPL opens on the right-hand side of the window, occupying 50% of the width.
Again, thank you very much for your help. I hope that this answer serves to other Doom Emacs users.
Since I provided an explanation for the issue, and since alternatives solutions were provided, I believe that the issue can be closed without any problem.
Again, thank you very much for your help.
Is there any way to make the REPL open in a vertical split? So that one may have the editor on the left-hand side of the screen and the REPL on the right-hand side.