Hello,
I have a question for all the Emacs + Lisp gurus out there :)
I am in the process of designing a little DSL. A part of it is a macro
with this signature:
(defmacro define-widget-macro (name arglist constructor &body body))
which I use to define the basic elements of my DSL.
I use mostly Emacs+SLIME to edit Lisp code. A call to my macro gets
indented like this:
(define-widget-macro frame
(&rest args &key layout-manager title visible-p)
(new "javax.swing.JFrame")
`(progn yadda-yadda-yadda))
that is, both the "constructor" part and the "body" part are indented
2 spaces right of the text "(define-widget-macro", while the arglist
is indented by 4 spaces (the name gets indented by 4 spaces too if I
put it in a line by its own).
However, I'd like to indent it like this:
(define-widget-macro frame
(&rest args &key layout-manager title visible-p)
(new "javax.swing.JFrame")
`(progn yadda-yadda-yadda))
that is, the "constructor" part should be indented 2 more spaces right
(exactly how the arglist is indented), while the body should remain
indented by two spaces (like it is by default).
Do you know how can I achieve this kind of indentation? Do I want to?
(i.e. is it overkill?)
I have Googled a bit but only found how to indent the first line of a
form (using 'lisp-indent-function). Apparently custom indentation is
possible (Emacs does it for forms whose operator starts with "def..."
or "with...", for example), but I have no clue of how to do it.
Thanks,
Alessio
Alessio Stalla <·············@gmail.com> writes:
> [...]
> However, I'd like to indent it like this:
>
> (define-widget-macro frame
> (&rest args &key layout-manager title visible-p)
> (new "javax.swing.JFrame")
> `(progn yadda-yadda-yadda))
> [...]
> Do you know how can I achieve this kind of indentation? Do I want to?
The basic feature is:
#+emacs (put 'define-widget-macro 'lisp-indent-function 3)
(define-widget-macro frame
(&rest args &key layout-manager title visible-p)
(new "javax.swing.JFrame")
`(progn yadda-yadda-yadda))
Also, have a look at:
http://groups.google.com/group/comp.lang.lisp/msg/e472df51cf216231?pli=1
--
__Pascal Bourguignon__
http://www.informatimago.com
On Apr 22, 9:37 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> The basic feature is:
>
> #+emacs (put 'define-widget-macro 'lisp-indent-function 3)
>
> (define-widget-macro frame
> (&rest args &key layout-manager title visible-p)
> (new "javax.swing.JFrame")
> `(progn yadda-yadda-yadda))
Thanks, that did the trick!
> Also, have a look at:http://groups.google.com/group/comp.lang.lisp/msg/e472df51cf216231?pli=1
Very interesting, that'll be handy should my DSL really see the light
of day - it would be added value for its users to have a downloadable
elisp script that enables "correct" indentation of the DSL code in
Emacs, and that can be customized at will.
Ale