How to automatically get paredit in an emacs nrepl session?

I have the following line in the init emacs file.

(setq auto-mode-alist (cons `("\*nrepl\*" . paredit-mode) auto-mode-alist)) 

I verify that this works by creating a new buffer called * nrepl * Ctrl-xf *nrepl* . Yes, in the * nrepl * Paredit buffer is active, paredit mode is enabled.

I close the * nrepl * buffer without saving it.

I start an nrepl session by typing Mx nrepl-jack-in . The nrepl server starts up and nrepl repl is provided to me. Nrepl repl is also called * nrepl *, however Paredit does not .

What am I doing wrong?

+6
source share
3 answers

You confuse buffers and files: auto-mode-alist matches file names with regular expressions to determine which mode to use when editing these files. But * nrepl * is a buffer that does not contain a file, so auto-mode-alist does not work for it. Instead, you probably want to find out which main mode * nrepl * uses and then use (add-hook '<the-major-mode>-hook 'paredit-mode) .

+6
source

Simply put - you need the following code:

 (add-hook 'nrepl-mode-hook 'paredit-mode) ; for nrepl.el <= 0.1.8 (add-hook 'nrepl-repl-mode-hook 'paredit-mode) ; for nrepl.el > 0.1.8 

Which is equivalent to a longer form:

 (add-hook 'nrepl-mode-hook (lambda () (paredit-mode +1))) 
+5
source
 (add-hook 'nrepl-mode-hook 'paredit-mode) 

is what they offer on the nrepl github page

+2
source

All Articles