Emacs clojure mode

62 views
Skip to first unread message

Jeffrey Chu

unread,
Mar 7, 2008, 9:35:37 PM3/7/08
to Clojure
Hi

I'm starting a new thread just because it didn't make sense to
continue talking about clojure-mode for emacs in the Var metadata
thread.

The old thread can be found at:

http://groups.google.com/group/clojure/browse_thread/thread/fa84dc8f785a9c32/d6dee9c1a79f953d


For those who haven't been following that thread, I've started a
branch of clojure mode and paredit with updates to indentation and
syntax highlighting. They are available at:

http://clojure.codestuffs.com/git/?p=clojure-emacs.git;a=summary
git clone http://clojure.codestuffs.com/pub/clojure-emacs.git

- Jeff

Jeffrey Chu

unread,
Mar 7, 2008, 9:38:23 PM3/7/08
to Clojure
In reply to:
http://groups.google.com/group/clojure/msg/8fe7fb412e56b70a
http://groups.google.com/group/clojure/msg/86018ea3640abbdb

> but is it the intended/cleanest way of utilizing them?

Yeah, I more or less have the same lines in my .emacs

> also, is it possible to get (comment .........) forms highlighted

It's in the repository. But it has some caveats: font-lock doesn't
appreciate open parens at the very beginning of lines, so those open
paren will have a warning face (typically red). To avoid this problem,
you're just going to have to make sure you indent the contents of
(comment ... ).

Because of this issue I've left it as a customizable feature that's
defaulted to off.

> lisp-eval-region-and-go

Ah, thanks! I would have never caught that (I run emacs with
menu-bar-mode off). It's been fixed and can be found in the latest
repository.

Thanks for the feedback,
- Jeff

jon

unread,
Mar 8, 2008, 5:32:46 AM3/8/08
to Clojure
> > also, is it possible to get (comment .........) forms highlighted
>
> It's in the repository. But it has some caveats: font-lock doesn't ...

Excellent, thanks for that!

> Because of this issue I've left it as a customizable feature that's
> defaulted to off.

Just a minor query..
- is it expected that if you have some open buffers already in clojure-
mode, then toggle the clojure-mode-font-lock-comment-sexp variable,
that you should have to restart clojure-mode in each one of them (eg.
M-x clojure-mode) in order for the highlighting changes to come into
effect?

Thanks, Jon

a r

unread,
Mar 8, 2008, 6:25:57 PM3/8/08
to clo...@googlegroups.com
Hi,

There is probably something wrong with my setup. When I start
clojure-mode (GNU Emacs 21.3.1, Linux) I get an error:

Debugger entered--Lisp error: (wrong-number-of-arguments
#[(lisp-syntax) "<BINARYDATA>" [lisp-syntax lisp-mode-syntax-table
lisp-mode-abbrev-table local-abbrev-table page-delimiter
paragraph-start set-syntax-table make-local-variable "\\|$"
paragraph-separate paragraph-ignore-fill-prefix t
fill-paragraph-function lisp-fill-paragraph adaptive-fill-mode nil
normal-auto-fill-function lisp-mode-auto-fill indent-line-function
lisp-indent-line indent-region-function lisp-indent-region
parse-sexp-ignore-comments outline-regexp ";;;;* \\|(" outline-level
lisp-outline-level comment-start ";" comment-start-skip
"\\(\\(^\\|[^\\\\
]\\)\\(\\\\\\\\\\)*\\);+ *" comment-add 1 comment-column 40
comment-indent-function lisp-comment-indent imenu-generic-expression
multibyte-syntax-as-symbol ((lisp-font-lock-keywords
lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) nil nil
(("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
(font-lock-mark-block-function . mark-defun))
lisp-imenu-generic-expression font-lock-defaults] 2] 0)
lisp-mode-variables()
clojure-mode()
* call-interactively(clojure-mode)
execute-extended-command(nil)
* call-interactively(execute-extended-command)

There is also something wrong with the inferior-lisp-program. I've
checked that the command is set properly to:
"/usr/bin/java -cp ~/clojure/clojure.jar clojure.lang.Repl ~/clojure/boot.clj"

This command when run in a shell gives me the clojure's REPL.

However, selecting "Run Lisp" from Clojure menu in Emacs fails with a message:

Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Repl
Process inferior-lisp exited abnormally with code 1

Cheers,
-r.

jon

unread,
Mar 8, 2008, 9:12:38 PM3/8/08
to Clojure
Hi,

> There is probably something wrong with my setup. When I start
> clojure-mode (GNU Emacs 21.3.1, Linux) I get an error:

Don't know about that error.. it works for me using GNU Emacs 22.1.50.

> There is also something wrong with the inferior-lisp-program. I've
> checked that the command is set properly to:
> "/usr/bin/java -cp ~/clojure/clojure.jar clojure.lang.Repl ~/clojure/boot.clj"
> This command when run in a shell gives me the clojure's REPL.
> However, selecting "Run Lisp" from Clojure menu in Emacs fails with a message:
> Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Repl
> Process inferior-lisp exited abnormally with code 1

I got exactly that too, using both ~/clojure/clojure.jar and $HOME/
clojure/clojure.jar
but works when I use /home/xxxxxx/clojure/clojure.jar
(I'm new to emacs, but I guess it's just not running that command via
a shell or something??
You seem to be able to use ~/... elsewhere in .emacs)

ps. you no longer need to append ~/clojure/boot.clj for the recent
clojure release.. it's auto-loaded.

HTH, Jon

Jeffrey Chu

unread,
Mar 9, 2008, 1:00:37 AM3/9/08
to Clojure
> Excellent, thanks for that!

You're welcome!

> is it expected that if you have some open buffers already in
> clojure- mode, then toggle the clojure-mode-font-lock-comment-sexp
> variable, that you should have to restart clojure-mode in each one
> of them (eg. M-x clojure-mode) in order for the highlighting
> changes to come into effect?

Yeah. It's mostly because these changes affect font-lock, which gets
called fairly frequently and should be reasonably fast; And I figured
that since this is an option that's probably only going to be changed
once, I didn't need to add the extra code to make it have immediate
effect.

- Jeff

Jeffrey Chu

unread,
Mar 9, 2008, 1:01:54 AM3/9/08
to Clojure
> There is probably something wrong with my setup. When I start
> clojure-mode (GNU Emacs 21.3.1, Linux) I get an error:

If I'm reading it right, it looks like lisp-mode-variables' arg wasn't
optional your version of emacs. I made what I believe are the
necessary changes to get it working, but I can't test it (I'm running
emacs cvs). Let me know if it works!


> There is also something wrong with the inferior-lisp-program.
>> but I guess it's just not running that command via a shell or
>> something

I get the same thing. It has to do with how comint doesn't expand ~
for it's args. You can either do as Jon suggests and list the full
path or you can create a script file (one is described in the wiki)
and set the inferior-lisp-program to that.

Let me know if you have anymore problems with clojure-mode.

Thanks,
- Jeff

Jeffrey Chu

unread,
Mar 9, 2008, 1:22:17 AM3/9/08
to Clojure
I've started some work on a more context-sensitive indent. Because
it's still in it's experimental stages and apt to change, I've
defaulted it to off.

But if you don't care about that and the indentation of implement and
proxy are driving you bonkers, it's available in the latest version
and can be flipped on by setting the customizable variable
clojure-mode-use-backtracking-indent to t.

As always, feedback is welcome.

Thanks,
- Jeff

a r

unread,
Mar 9, 2008, 2:43:04 PM3/9/08
to clo...@googlegroups.com
Hi,

The problems from my previous email are now solved but I am getting
another error:

Debugger entered--Lisp error: (void-variable font-lock-extend-region-functions)
add-to-list(font-lock-extend-region-functions
clojure-font-lock-extend-region-def t)
(progn (add-to-list (quote font-lock-extend-region-functions) (quote
clojure-font-lock-extend-region-def) t))
(if clojure-mode-font-lock-multine-def (progn (add-to-list ... ... t)))
(when clojure-mode-font-lock-multine-def (add-to-list (quote
font-lock-extend-region-functions) (quote
clojure-font-lock-extend-region-def) t))


clojure-mode()
* call-interactively(clojure-mode)
execute-extended-command(nil)
* call-interactively(execute-extended-command)

Thanks,
-r.

Jeffrey Chu

unread,
Mar 9, 2008, 6:14:00 PM3/9/08
to Clojure
> Debugger entered--Lisp error: (void-variable font-lock-extend-region-functions)

Unfortunately, it appears that the ability to have custom font lock
region extensions was introduced in emacs 22.

This means in emacs 21 I can't give you reliable highlighting. I added
a check so you may still use clojure mode but (comment ..)
highlighting is completely disabled and multi-line highlighting will
not be completely reliable (but it'll work sometimes).

But that shouldn't be too much of a problem considering the new def
format allows you to keep the name on the same line.

Let me know if you come across any more problems.

Thanks,
- Jeff

a r

unread,
Mar 9, 2008, 6:48:39 PM3/9/08
to clo...@googlegroups.com
Hi,

Two more observations:
1. The error message related to font-lock-extend-region-function has
gone. Unfortunately, all the partial syntax highlighting (comments,
text literals, special forms) I used to have in previous version have
gone as well.

2. I am getting one more error:
Debugger entered--Lisp error: (void-function run-mode-hooks)
(run-mode-hooks (quote clojure-mode-hook))


clojure-mode()
* call-interactively(clojure-mode)
execute-extended-command(nil)
* call-interactively(execute-extended-command)

Thanks,
-r.

Reply all
Reply to author
Forward
0 new messages