how to get font-lock to work in swank repl buffer

461 views
Skip to first unread message

Ben Smith-Mannschott

unread,
Jan 19, 2012, 4:52:44 PM1/19/12
to clo...@googlegroups.com
I'm trying to get syntax highlighting (font-lock) to work in the
repl buffer provided by slime as described here:
https://github.com/technomancy/swank-clojure

(add-hook 'slime-repl-mode-hook
(defun clojure-mode-slime-font-lock ()
(let (font-lock-mode)
(clojure-mode-font-lock-setup))))

The results are not visibly different from having not added this
slime-repl-mode-hook.

Once the repl buffer is open, I can get font-lock to work by
doing this manually:

M-x clojure-mode-font-lock-setup
M-x font-lock-mode (turning it off)
M-x font-lock-mode (turning it back on)

What am I misunderstanding?

I'm running:

- Emacs 24.0.91.1
- clojure-mode 1.11.5
- slime 20100404.1
- slime-repl 20100404
- clojure 1.3.0
- clojure-maven-plugin 1.3.8
- swank-clojure 1.3.4

Incidentally, what's with this strange form of let?

(let (font-lock-mode) ;; <- shouldn't this bind variables?
(clojure-mode-font-lock-setup))

// Ben

Max Penet

unread,
Jan 19, 2012, 6:08:09 PM1/19/12
to Clojure
Hello,

This should do it:

(add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)

On Jan 19, 10:52 pm, Ben Smith-Mannschott <bsmith.o...@gmail.com>
wrote:

Max Penet

unread,
Jan 19, 2012, 6:14:06 PM1/19/12
to Clojure
Well it *should*, now that I think of it, I am not using clojure-jack-
in so it might be different.

Jack Moffitt

unread,
Jan 19, 2012, 6:45:17 PM1/19/12
to clo...@googlegroups.com
The instructions in the git repo don't work for me either, but

> M-x clojure-mode-font-lock-setup
> M-x font-lock-mode (turning it off)
> M-x font-lock-mode (turning it back on)

does. The suggested (add-hook 'slime-repl-mode-hook
'clojure-mode-font-lock-setup) does not work either.

You can automate the manual workaround with this:

(add-hook 'slime-repl-mode-hook
(lambda ()
(clojure-mode-font-lock-setup)
(font-lock-mode)
(font-lock-mode)))

jack.

Daniel Janus

unread,
Jan 20, 2012, 5:53:13 AM1/20/12
to clo...@googlegroups.com
On Thursday, January 19, 2012 9:52:44 PM UTC, bsmith.occs wrote:
 

Incidentally, what's with this strange form of let?

  (let (font-lock-mode) ;; <- shouldn't this bind variables?
    (clojure-mode-font-lock-setup))

In Common Lisp (and presumably in Emacs Lisp as well), 'let' takes an additional pair of parens around each name/value pair. This allows for a shortcut: (let (a) body) is equivalent to (let ((a nil)) body).

Sorry for the offtopic,
- Daniel 

Ben Smith-Mannschott

unread,
Jan 20, 2012, 3:03:06 PM1/20/12
to clo...@googlegroups.com
On Fri, Jan 20, 2012 at 00:45, Jack Moffitt <ja...@metajack.im> wrote:
> (add-hook 'slime-repl-mode-hook
>               (lambda ()
>                 (clojure-mode-font-lock-setup)
>                 (font-lock-mode)
>                 (font-lock-mode)))

Excellent! This worked for me.

Many thanks for the tip.

// ben

Reply all
Reply to author
Forward
0 new messages