libera/#slime - IRC Chatlog
Search
19:14:51
makomo
a question regarding indentation. it seems that emacs' default lisp-indent-function isn't capable of indenting flet, cl-flet, cl-labels, etc. nicely (i wonder how the maintainers do it?)
19:15:26
makomo
people are suggesting to use common-lisp-indent-function instead, which has much more sophisticated indent specs
19:16:35
makomo
common-lisp-indent-function is defined within cl-indent.el, which is part of the emacs tree. and this code actually makes provisions for having different indentations for a single operator, depending on whether it's elisp or cl
19:17:30
makomo
but looking at the slime-indentation contrib, it seems like it has a custom patched version/fork of cl-indent and completely redefines its functions, so that they no longer make the above provisions for elisp
19:18:31
makomo
does anyone know why this is so? and what's the recommended way to have both elisp and cl (slime) indentation simultaneously?
19:22:22
pjb
makomo: with the standard cl-indent, you need to add lisp-indent-function or common-lisp-indent-function properties to each symbol.
19:23:50
pjb
makomo: and notice how cl-indent only knows how to indent differently two groups of subexpressions. slime indentations is way more sophisticated, eg for macros such as loop that have some syntax inside.
19:30:16
pjb
It's processed to put both the lisp-indent-function and the common-lisp-indent-function properties to the same value.
19:30:47
pjb
Note, normally if has as plist (lisp-indent-function 2 common-lisp-indent-function 1) ; but since I'm a CLispers, I put 1 for both.
19:34:43
makomo
i understand the things you wrote, but why exactly does slime have its own copy of cl-indent, which overwrites the definitions given by the standard cl-indent that's part of emacs
19:35:49
pjb
because slime retrieves this information from the actual definitions in the lisp image. It learns if the operator is a function or a macro, and when it's a macro it processes the structure of its lambda-list to know how to indent it (where are &key arguments, where are &rest or &body arguments, etc).
19:36:58
makomo
i understand all of that, but is this "monkey patching" really required? why couldn't it be a separate set of definitions?
19:37:19
makomo
e.g. why shouldn't there exist a slime-indent-function that you'd set your lisp-indent-function to?
19:37:37
makomo
why do they overwrite common-lisp-indent-function and have this forking business going on, which clashes with the standard cl-indent.el
19:38:55
pjb
But it does: in lisp-mode with slime-mode, lisp-indent-function --> common-lisp-indent-function which is defined in slime-cl-idnent.el
19:39:53
pjb
I don't think there was a common-lisp-indent-function before this definition. Only an indicator for the symbol plist.
19:40:21
pjb
(well there may have been a common-lisp-indent-function in ilisp.el or some other precursor to slime).
19:40:26
makomo
here: https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/cl-indent.el
19:40:53
makomo
and now look at slime's fork, slime-cl-indent.el: https://github.com/slime/slime/blob/master/contrib/slime-cl-indent.el
19:41:05
pjb
Well, in that case, that could justify an issue in slime, to rename it to avoid the overriding.
19:41:59
makomo
because the original cl-indent.el's common-lisp-indent-function actually has provisions for indenting symbols differently depending on whether you're in elisp or common lisp mode
19:42:23
makomo
slime's fork removes this and forces you to use the same indentation rules everywhere. this makes it impossible to indent "if" differently in elisp and in common lisp
19:42:41
makomo
or perhaps it didn't remove it but it just hasn't kept up with the updates. i don't know
19:43:27
makomo
from what i've just been told in #emacs, sly fixed this exact issue by renaming all of the symbols
19:44:54
makomo
it seems that this fork of cl-indent that's part of slime hasn't been touched in about 10 years
19:45:29
makomo
i've never tried sly though. maybe i could give it a go, but i wonder how it compares to slime