How can I get syntax highlighting for common lisp in SLIME's REPL?
Asked Answered
L

1

7

I want to learn Common Lisp and have installed emacs (24.3) and slime via the emacs package manager.

In the slime REPL syntax highlighting doesn't work. When I start Lisp-Mode (while in the slime REPL) on the other hand, the values of the expressions don't get printed anymore (when I type, say "Hello World" and hit enter I get a new line instead of the value of the expression.

(If I open lisp files syntax highlighting works)

Lodicule answered 12/9, 2014 at 13:29 Comment(4)
Where exactly is syntax highlighting not working? Are you talking about *.lisp buffers or the REPL or both? You also might want to add the common lisp tag to your question to increase visibility.Aid
I'm talking about the REPL.Lodicule
Added the tag and edited the question, hope it is more clear now.Lodicule
I get syntax highlighting for the buffer, although I don't get the differentiated syntax highlighting as in a CL code buffer. Instead the entire *slime-repl*buffer gets syntax-highlighting which allows to quickly distinguish between code you typed, warnings or messages from your CL system and return values.Aid
B
3

this works for me (https://comp.emacs.narkive.com/AWoywbFs/tweaking-slime):

(defvar slime-repl-font-lock-keywords lisp-font-lock-keywords-2)
(defun slime-repl-font-lock-setup ()
  (setq font-lock-defaults
        '(slime-repl-font-lock-keywords
         ;; From lisp-mode.el
         nil nil (("+-*/.<>=!?$%_&~^:@" . "w")) nil
         (font-lock-syntactic-face-function
         . lisp-font-lock-syntactic-face-function))))
      
(add-hook 'slime-repl-mode-hook 'slime-repl-font-lock-setup)
      
(defadvice slime-repl-insert-prompt (after font-lock-face activate)
  (let ((inhibit-read-only t))
    (add-text-properties
     slime-repl-prompt-start-mark (point)
     '(font-lock-face
      slime-repl-prompt-face
      rear-nonsticky
      (slime-repl-prompt read-only font-lock-face intangible))))))
Behling answered 26/9, 2014 at 1:43 Comment(1)
I use evil for vi bindings, and this config was preventing me from scrolling through my REPL history while in Normal mode. The solution was to change (point) to (1- (point)), which essentially has the effect of only applying read-only and other properties to the prompt itself and not the space character immediately after it.Revareval

© 2022 - 2024 — McMap. All rights reserved.