Hi,
I'm a happy new user of SLIME (using it with ACL 7.0 beta), but I have one question.
After defining and compiling macro with a &body parameter, like
(defmacro test ((x) &body body) `(progn (list ,x) ,@body))
I would like all use of such a macro to be indented as follows:
(test (1) (do 'a) (do 'b))
but SLIME does it this way:
(test (1) (do 'a) (do 'b))
Is there some way to get the indentation I want? It would be even better if this would also work for macros that weren't defined by me but that I just loaded into the system.
A better indentation for the bodies of flet and labels-functions would also be nice, by the way.
Thanks,
Arthur
Arthur Lemmens alemmens@xs4all.nl writes:
Is there some way to get the indentation I want? It would be even better if this would also work for macros that weren't defined by me but that I just loaded into the system.
A better indentation for the bodies of flet and labels-functions would also be nice, by the way.
SLIME assumes that you use common-lisp-indent-function and not the default indent-function. The default indent-function is for Emacs Lisp. Try to add something like
(make-variable-buffer-local 'lisp-indent-function) (setq lisp-indent-function 'common-lisp-indent-function)
to your lisp-mode-hook. This should give you automatic indentation for macros with &body args and also better indentation for flet and labels.
SLIME does by default nothing special for macros starting with "with-" of "def" because doing so messes up the indentation of defmethod in some implementations. You can change the default by setting slime-conservative-indentation.
See also the "Semantic indentation" section in the manual.
Helmut.
Helmut Eller e9626484@stud3.tuwien.ac.at writes:
SLIME does by default nothing special for macros starting with "with-" of "def" because doing so messes up the indentation of defmethod in some implementations. You can change the default by setting slime-conservative-indentation.
So that variable is set to t and lisp-indent-function's value is common-lisp-indent-function yet I'm still getting "special" indentation of lines following a "def" form. Which is particularly ignoring in cases like this (indented with indent-sexp):
(defclass column () ((name :accessor name :initarg :name) (default-value-fn :accessor default-value-fn ;;; <<---- note extra indentation :initarg :default-value-fn)))
What am I doing wrong?
-Peter
Peter Seibel peter@javamonkey.com writes:
So that variable is set to t and lisp-indent-function's value is common-lisp-indent-function yet I'm still getting "special" indentation of lines following a "def" form. Which is particularly ignoring in cases like this (indented with indent-sexp):
common-lisp-indent-function recognizes "def", "with", and apparently also "do" and "without" forms with some string matching and the associated indentation rules are basically fixed. Most other symbols, e.g. 'when, are indented according to their 'common-lisp-indent-function property.
So what you see is not caused by SLIME, but by the somewhat questionable heuristic used by common-lisp-indent-function.
The simplest workaround is probably something like
(put 'default-value-fn 'common-lisp-indent-function '(&rest))
Helmut.
Helmut Eller e9626484@stud3.tuwien.ac.at writes:
Peter Seibel peter@javamonkey.com writes:
So that variable is set to t and lisp-indent-function's value is common-lisp-indent-function yet I'm still getting "special" indentation of lines following a "def" form. Which is particularly ignoring in cases like this (indented with indent-sexp):
common-lisp-indent-function recognizes "def", "with", and apparently also "do" and "without" forms with some string matching and the associated indentation rules are basically fixed. Most other symbols, e.g. 'when, are indented according to their 'common-lisp-indent-function property.
So what you see is not caused by SLIME, but by the somewhat questionable heuristic used by common-lisp-indent-function.
Yeah. I knew that it was wired into common-lisp-indent-function; Something you said made me think that SLIME somehow prevented those heuristics from coming into play.
Not that I have a lot of free time at the moment to actually do it but how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched. (I've submitted a couple patches to cl-indent.el to the GNU emacs maintainers. One went in; the other disappeared into a black hole.) This would also probably improve the portability of user experience for SLIME users who switch between GNU Emacs and Xemacs. (I have no idea if that's currently a problem.)
-Peter
[Helmut, sorry for the dup. I'm not subscribed so this didn't go to the list.]
Hi, I hope this is the right place for bugreports.
On Emacs running on Win2k using CLisp, my connection to Slime is dropped when I hit slime-space on a file I've loaded, and get this error message on the *Asynch Shell Command* buffer:
;; Connection to Emacs lost. ;; [read from #<input string-input-stream>: #<package swank> has no external symbol with name "BUFFER-FIRST-CHANGE"] ;; Loaded file C:.slime.lisp [1]>
I do have an old version which works properly; the last entry in its changelog is: 2004-07-01. The versions which exhibit this bug are slime-1.0 and the most recent one in CVS.
Thanks, Tayssir
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thursday 07 October 2004 03:16, Peter Seibel wrote: [cut]
Not that I have a lot of free time at the moment to actually do it but how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched. (I've submitted a couple patches to cl-indent.el to the GNU emacs maintainers. One went in; the other disappeared into a black hole.) This would also probably improve the portability of user experience for SLIME users who switch between GNU Emacs and Xemacs. (I have no idea if that's currently a problem.)
-Peter
[Helmut, sorry for the dup. I'm not subscribed so this didn't go to the list.]
I vote for it. I'd like to have some way to tell emacs how to indent the macro from the macro definition. Don't know if this is possible and probably it won't be portable but one can dream, right?
Generally, I think putting meta info in comments is a poor practice, and am sure in Common Lisp there are better ways, but currently I can think of two alternatives:
1. Put the meta info in a property.
2. Use something like: #+slime-indent (slime-set-macro-indentation 'macro 'info)
I don't know the SLIME internals, so I guess I'm missing an easier and better way to do this.
- -- Ivan
Ivan Toshkov writes:
I vote for it. I'd like to have some way to tell emacs how to indent the macro from the macro definition. Don't know if this is possible and probably it won't be portable but one can dream, right?
Generally, I think putting meta info in comments is a poor practice, and am sure in Common Lisp there are better ways, but currently I can think of two alternatives:
Put the meta info in a property.
Use something like:
#+slime-indent (slime-set-macro-indentation 'macro 'info)
I don't know the SLIME internals, so I guess I'm missing an easier and better way to do this.
Normally, in emacs this is done with local variables. Put at the end of your source a comment like:
;; Local Variables: ;; eval: (put 'comment-with-narrowing 'lisp-indent-function 2) ;; End:
(with any number of eval: lines and any emacs lisp expression).
Usually, in my Common-Lisp code I rather use my own cl-indent function that puts the property to both the low-case and the up-case version of the symbol (since emacs is case sensitive and Common-Lisp code can appear in either case):
;; Local Variables: ;; eval: (cl-indent 'while 1) ;; eval: (cl-indent 'until 1) ;; End:
But this is not enought to get a pretty indentation. As you can see from my patch to lisp-indent-function, you need to be slighly more intelligent to heuristically correctly indent sexps.
Peter Seibel peter@javamonkey.com writes:
Not that I have a lot of free time at the moment to actually do it but
Probably not even Marco, who created the `cltl-mode' SourceForge project with a similar goal :)
how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched. (I've submitted a
That would be great. It looks like there is no unified CL indent mode that improves on cl-indent.el, e.g. Every Lisper seems to have his own code snippets for patching or enhancing the existing cl-indent.el.
Paolo
On Wed, 06 Oct 2004 17:16:42 -0700, Peter Seibel peter@javamonkey.com wrote:
Not that I have a lot of free time at the moment to actually do it but how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched. (I've submitted a couple patches to cl-indent.el to the GNU emacs maintainers. One went in; the other disappeared into a black hole.)
They're both in there now:
Edi.
On Wed, 06 Oct 2004 17:16:42 -0700, Peter Seibel peter@javamonkey.com wrote:
Not that I have a lot of free time at the moment to actually do it but how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched.
Er, and yes, I think that's a good idea.
Peter Seibel peter@javamonkey.com writes:
Not that I have a lot of free time at the moment to actually do it but how would folks feel about forking the cl-indent.el from emacs into SLIME so we can hack on it without having to deal with getting the "official" version that comes with Emacs patched. (I've submitted a couple patches to cl-indent.el to the GNU emacs maintainers. One went in; the other disappeared into a black hole.) This would also probably improve the portability of user experience for SLIME users who switch between GNU Emacs and Xemacs. (I have no idea if that's currently a problem.)
I added a patched version of cl-indent.el in to the SLIME CVS version. I think I fixed a bug that particular caused bad indentation for "," and ",@" even if lisp-backquote-indentation was t. The "def.*" heuristic can be disabled with by setting lisp-prefix-match-indentation to nil.
Hacking the indentation code is not particularly easy and it would be nice if to have a test suite for this stuff.
I would like to submit the changes we make to cl-indent to the Emacs maintainers and therefore we should be a bit careful with copyrights. Every Emacs contributor has to sign papers and assign the copyright to the FSF. So everyone who sends a patch for cl-indent which is larger than a page should also willing to do assign copyrights.
Helmut.
Peter Seibel writes:
Helmut Eller e9626484@stud3.tuwien.ac.at writes:
SLIME does by default nothing special for macros starting with "with-" of "def" because doing so messes up the indentation of defmethod in some implementations. You can change the default by setting slime-conservative-indentation.
So that variable is set to t and lisp-indent-function's value is common-lisp-indent-function yet I'm still getting "special" indentation of lines following a "def" form. Which is particularly ignoring in cases like this (indented with indent-sexp):
(defclass column () ((name :accessor name :initarg :name) (default-value-fn :accessor default-value-fn ;;; <<---- note extra indentation :initarg :default-value-fn)))
What am I doing wrong?
You're not using the right lisp-indent-function! The one coming with emacs (and I guess the other one coming with slime) lack a (looking-at ":") disjonction.
diff -c /tmp/b /tmp/a *** /tmp/b 2004-10-07 01:06:07.000000000 +0200 --- /tmp/a 2004-10-07 01:05:46.000000000 +0200 *************** *** 3,9 **** (goto-char (1+ (elt state 1))) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) (if (and (elt state 2) ! (or (looking-at ":") (not (looking-at "\sw\|\s_")))) ;; car of form doesn't seem to be a symbol (progn (if (not (> (save-excursion (forward-line 1) (point)) --- 3,9 ---- (goto-char (1+ (elt state 1))) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) (if (and (elt state 2) ! (not (looking-at "\sw\|\s_"))) ;; car of form doesn't seem to be a symbol (progn (if (not (> (save-excursion (forward-line 1) (point))
;; extracted from ~pascal/.emacs:
(require 'lisp-mode)
(defun lisp-indent-function (indent-point state) (let ((normal-indent (current-column))) (goto-char (1+ (elt state 1))) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) (if (and (elt state 2) (or (looking-at ":") (not (looking-at "\sw\|\s_")))) ;; car of form doesn't seem to be a symbol (progn (if (not (> (save-excursion (forward-line 1) (point)) calculate-lisp-indent-last-sexp)) (progn (goto-char calculate-lisp-indent-last-sexp) (beginning-of-line) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t))) ;; Indent under the list or under the first sexp on the same ;; line as calculate-lisp-indent-last-sexp. Note that first ;; thing on that line has to be complete sexp since we are ;; inside the innermost containing sexp. (backward-prefix-chars) (current-column)) (let ((function (buffer-substring (point) (progn (forward-sexp 1) (point)))) method) (setq method (or (get (intern-soft function) 'lisp-indent-function) (get (intern-soft function) 'lisp-indent-hook))) (cond ((or (eq method 'defun) (and (null method) (> (length function) 3) (string-match "\`def" function))) (lisp-indent-defform state indent-point)) ((integerp method) (lisp-indent-specform method state indent-point normal-indent)) (method (funcall method state indent-point)))))));;lisp-indent-function
Arthur Lemmens alemmens@xs4all.nl writes:
Hi,
I'm a happy new user of SLIME (using it with ACL 7.0 beta), but I have one question.
After defining and compiling macro with a &body parameter, like
(defmacro test ((x) &body body) `(progn (list ,x) ,@body))
I would like all use of such a macro to be indented as follows:
(test (1) (do 'a) (do 'b))
This should work, but there are a few things that can muck it up. Since indentation of flet and labels isn't right for you I'm guessing that Emacs is indenting Common Lisp code as if it were Emacs Lisp. In that case you can fix it by adding this to your ~/.emacs:
(slime-setup)
The key is to have `lisp-indent-function' set to `common-lisp-indent-function' in your lisp-mode buffers.
If that wasn't the problem then the next thing is to see if SLIME is able to discover the arglist of the TEST function correctly, e.g. by typing "(test " and checking if arglist display includes &body.
Cheers, Luke
Luke Gorrie wrote:
Since indentation of flet and labels isn't right for you I'm guessing that Emacs is indenting Common Lisp code as if it were Emacs Lisp. In that case you can fix it by adding this to your ~/.emacs: (slime-setup)
That does the trick, thanks a lot (thanks to Helmut as well).
(incf *nr-beers-for-slime-hackers*)
Arthur