help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Common Lisp DEF Macro Indentation


From: Volkan YAZICI
Subject: Re: Common Lisp DEF Macro Indentation
Date: Wed, 16 Jul 2008 12:07:05 -0700 (PDT)
User-agent: G2/1.0

On Jul 14, 4:03 pm, Volkan YAZICI <address@hidden> wrote:
> ...
> What might be causing the problem? Are there any mistakes with forms I
> supplied to LISP-INDENT-259? Any kind of help will be appreciated.

Here goes the fixed version:

(require 'cl)

(defmacro concatenate-def-types-for-regexp (&rest symbols)
  (with-output-to-string
    (princ "(?\\(")
    (let (not-first)
      (while symbols
        (if not-first
            (princ "\\|")
          (setq not-first t))
        (princ (pop symbols))))
    (princ "\\)")))

(defcustom lisp-indent-def-function-regexp
  (concatenate-def-types-for-regexp
   function macro compiler-macro method generic type print-object
class
   condition)
  "Definer types will be indented like a function definition form."
  :type 'string
  :group 'lisp-indent)

(defcustom lisp-indent-def-variable-regexp
  (concatenate-def-types-for-regexp
   variable constant load-time-constant special-variable symbol-macro
struct)
  "Definer types will be indented like a variable definition form."
  :type 'string
  :group 'lisp-indent)

(defcustom lisp-indent-def-setf-regexp
  (concatenate-def-types-for-regexp setf)
  "Definer types will be indented like a setf definition form."
  :type 'string
  :group 'lisp-indent)

(defmacro with-position-at-def-type (position &rest body)
  `(save-excursion
     (goto-char ,position)
     (forward-char)
     (forward-sexp 1)
     (while (forward-comment 1))
     ,@body))

(defun lisp-indent-def (path state indent-point sexp-column normal-
indent)
  (lisp-indent-259
   (with-position-at-def-type (elt state 1)
     (cond ((looking-at lisp-indent-def-function-regexp)
            '(4 4 &lambda &body))
           ((looking-at lisp-indent-def-variable-regexp)
            '(4 4 &body))
           ((looking-at lisp-indent-def-setf-regexp)
            '(4 4 &lambda &body))
           (t
            '(&body))))
   path state indent-point sexp-column normal-indent))

(put 'def 'common-lisp-indent-function 'lisp-indent-def)

Pay attention that, in LISP-INDENT-DEF, if we couldn't find an
appropriate known definer type, we pass '(&body) to LISP-INDENT-259.
(Also fixed indentation routines in demacs too.)


Regards.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]