Doom-emacs: How can one move a REPL window?

Created on 8 Aug 2017  ·  3Comments  ·  Source: hlissner/doom-emacs

When I open a REPL using C-c C-l, the window it creates seems special (darker background, exits the process when closed, ...).

It also always seems to split my screen horizontally, which is sometimes useful, sometimes annoying. Not knowing enough about emacs, I can't seem to find a way to move this window to the right side.
I have managed to get it in another frame by using the switch-buffer commands, but I can't close the original one because it kills the process and all frames that have the buffer in it.

Could you give me pointers as how to deal with this special buffer and how it is displayed? :(

Thanks!

discussion

Most helpful comment

Hmm, there are a lot of moving parts here. I'm not sure what you've got C-c C-l bound to. If you aren't using the +eval/repl command to start a mode's repl, then Doom will treat the repl buffer like a common special buffer.

In that case, the two relevant variables are shackle-default-alignment and shackle-rules, which tell Emacs how to deal with windows that meet a certain criteria.

At the end of shackle-rules there are two catch-all rules:

(set! :popup 
  '("^\\*"  :regexp t :noselect t :autokill t)
  '("^ \\*" :regexp t :size 12 :noselect t :autokill t :autoclose t))))

The two problems here are :autokill t (which ensures a buffer and its associated processes are killed together) and since there is no :align specified, it resorts to shackle-default-alignment, which defaults to 'below.

So, how do we fix this?

Here are three ways:

  1. Simply specify an overriding rule for your repl in particular:

    (set! :popup "*my-repl-buffer*" :align 'left :noesc t)
    

    See M-x doom/describe-setting RET :popup for details.

  2. Enable the +eval-repl-mode minor mode in your repl:

    (add-hook 'inferior-python-mode-hook #'+eval-repl-mode)

    You'll find this popup rule in modules/feature/eval/config.el:

    (set! :popup
     '(:custom (lambda (b &rest _) (buffer-local-value '+eval-repl-mode b)))
     :size 16 :noesc t)
    
  3. Bind C-c C-l to +eval/repl and use that instead to invoke your repl. Most modes have reasonable defaults. If it's not opening the repl you want, you can change the major-mode->repl association with the :repl setting, e.g.

    (set! :repl 'python-mode #'+python/repl)

    The function :repl wants should return a buffer containing the repl.


Hope that helps!

All 3 comments

Hmm, there are a lot of moving parts here. I'm not sure what you've got C-c C-l bound to. If you aren't using the +eval/repl command to start a mode's repl, then Doom will treat the repl buffer like a common special buffer.

In that case, the two relevant variables are shackle-default-alignment and shackle-rules, which tell Emacs how to deal with windows that meet a certain criteria.

At the end of shackle-rules there are two catch-all rules:

(set! :popup 
  '("^\\*"  :regexp t :noselect t :autokill t)
  '("^ \\*" :regexp t :size 12 :noselect t :autokill t :autoclose t))))

The two problems here are :autokill t (which ensures a buffer and its associated processes are killed together) and since there is no :align specified, it resorts to shackle-default-alignment, which defaults to 'below.

So, how do we fix this?

Here are three ways:

  1. Simply specify an overriding rule for your repl in particular:

    (set! :popup "*my-repl-buffer*" :align 'left :noesc t)
    

    See M-x doom/describe-setting RET :popup for details.

  2. Enable the +eval-repl-mode minor mode in your repl:

    (add-hook 'inferior-python-mode-hook #'+eval-repl-mode)

    You'll find this popup rule in modules/feature/eval/config.el:

    (set! :popup
     '(:custom (lambda (b &rest _) (buffer-local-value '+eval-repl-mode b)))
     :size 16 :noesc t)
    
  3. Bind C-c C-l to +eval/repl and use that instead to invoke your repl. Most modes have reasonable defaults. If it's not opening the repl you want, you can change the major-mode->repl association with the :repl setting, e.g.

    (set! :repl 'python-mode #'+python/repl)

    The function :repl wants should return a buffer containing the repl.


Hope that helps!

Oh, I forgot to mention: there is currently no way to move a live popup window (I've never needed to). That's something I'll try to fix.

That seems like all the help I needed!

To be more specific, I was actually talking about the intero REPL, started by a command called intero-repl-load. I don't know what mechanisms it uses then.

I ended up going with:

(set! :popup "^\\*intero:" :regexp t :align 'right :size 80)

in my modules/private/ptival/init.el, worked like a charm!

Thanks for taking the time to explain all this to me! I don't think I'd have figured this out on my own in any reasonable amount of time! 👍

Was this page helpful?
0 / 5 - 0 ratings