From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Volkan YAZICI Newsgroups: gmane.emacs.help Subject: Common Lisp DEF Macro Indentation Date: Mon, 14 Jul 2008 06:03:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216042987 17998 80.91.229.12 (14 Jul 2008 13:43:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Jul 2008 13:43:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 14 15:43:55 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KIOLA-00014f-HI for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jul 2008 15:43:45 +0200 Original-Received: from localhost ([127.0.0.1]:37695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIOKH-0003aK-FA for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jul 2008 09:42:49 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!m73g2000hsh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 92 Original-NNTP-Posting-Host: 213.139.194.86 Original-X-Trace: posting.google.com 1216040604 28735 127.0.0.1 (14 Jul 2008 13:03:24 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 14 Jul 2008 13:03:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000hsh.googlegroups.com; posting-host=213.139.194.86; posting-account=xozGQQoAAAD99EQH9srmwM1ajggyokYW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.14) Gecko/20080404 Iceweasel/2.0.0.14 (Debian-2.0.0.14-0etch1), gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:160202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55550 Archived-At: Hi, I'm trying to write indentation routines for DEF macro of Common Lisp -- specifically designed for demacs[1]. Below is the code I use at the moment. (defmacro concatenate-symbols-for-regexp (&rest symbols) (with-output-to-string (let (not-first) (while symbols (if not-first (princ "\\|") (setq not-first t)) (princ (pop symbols)))))) (setq lisp-indent-def-function-regexp (concatenate-symbols-for-regexp function macro compiler-macro method generic type print-object class condition)) (defcustom lisp-indent-def-function-regexp (concatenate-symbols-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-symbols-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-symbols-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 1) (forward-sexp 2) (backward-sexp) (when (looking-at "(") (forward-char 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 (error "No available indentation for definer of type `%s'." (current-word))))) path state indent-point sexp-column normal-indent)) (put 'def 'common-lisp-indent-function 'lisp-indent-def) The problem is if I'd start the &body part of the related s- expressions with a list, emacs complains that ``forward-sexp: Scan error: "Unbalanced parentheses", 201, 361''. For instance, consider below case: ;; Indents without a problem. (def function foo (bar) "baz" moo) ;; Using `(moo)' instead of `moo' messes up the indentation routine. (def function foo (bar) "baz" (moo ... 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. Regards. [1] http://cliki.net/demacs