[slime-devel] Re: defclass form indentation

Bill Clementson billclem at gmail.com
Sat Feb 24 23:21:13 UTC 2007


Hi Marco,

On 2/23/07, Marco Baringer <mb at bese.it> wrote:
> "Bill Clementson" <billclem at gmail.com> writes:
>
> > --- cl-indent-orig.el 2007-02-16 13:49:06.000000000 -0800
> > +++ cl-indent-mods.el 2007-02-16 13:51:39.000000000 -0800
> > @@ -214,15 +214,17 @@
> >                   ((null method)
> >                    (when (null (cdr path))
> >                    ;; (package prefix was stripped off above)
> > -                  (cond ((string-match "\\`def"
> > -                                       function)
> > +                  (cond ((and (string-match "\\`def"
> > +                                            function)
> > +                              (not (string-match "\\`default-"
> > +                                                 function)))
> >                           (setq tentative-defun t))
> >                          ((string-match
>
> wouldn't (not (string-match "\\[^:]def" function)) be better?

I don't think that works for Zach's specific example. Here is his code
(indented with the standard cl-indent):

 (defclass field ()
   ((name
     :initarg :name
     :accessor name)
    (default-value
        :initarg :default-value
      :accessor default-value))
   (:default-initargs
       :name nil
     :default-value nil))


Using my modification to cl-indent, the indentation becomes:

(defclass field ()
  ((name
    :initarg :name
    :accessor name)
   (default-value
    :initarg :default-value
    :accessor default-value))
  (:default-initargs
   :name nil
   :default-value nil))

So, the indentation of both the default-value form and the
:default-initargs form is adjusted (which is what Zach was after, I
think).

I said it was a "yucky patch" because it just fixes the indentation
for this particular scenario. Often, indentation of "def..." forms is
handled oddly by cl-indent because of the in-built supposition that
(unless otherwise defined) anything that begins with "def" is a
definition form. A better patch might be to provide a defcustom emacs
variable that could be used for any "def..." forms that aren't to be
indented as definition forms and to check that variable before
indenting code as a definition form.

--
Bill Clementson



More information about the slime-devel mailing list