From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: A Soare Newsgroups: gmane.emacs.devel Subject: Re: Indentation of constants in LISP Date: Wed, 21 Feb 2007 23:33:53 +0100 (CET) Message-ID: <27680433.78571172097233434.JavaMail.www@wwinf4104> Reply-To: alinsoar@voila.fr NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1172097256 3473 80.91.229.12 (21 Feb 2007 22:34:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Feb 2007 22:34:16 +0000 (UTC) Cc: "Richard Stallman \[rms\]" To: "Emacs Dev [emacs-devel]" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 21 23:34:09 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HK02K-0006BI-Kc for ged-emacs-devel@m.gmane.org; Wed, 21 Feb 2007 23:34:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HK02K-0007GB-31 for ged-emacs-devel@m.gmane.org; Wed, 21 Feb 2007 17:34:08 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HK029-0007G4-2L for emacs-devel@gnu.org; Wed, 21 Feb 2007 17:33:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HK027-0007Fs-If for emacs-devel@gnu.org; Wed, 21 Feb 2007 17:33:55 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HK027-0007Fp-FV for emacs-devel@gnu.org; Wed, 21 Feb 2007 17:33:55 -0500 Original-Received: from smtp2.voila.fr ([193.252.22.175] helo=smtp1.voila.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1HK026-0000DG-2j; Wed, 21 Feb 2007 17:33:54 -0500 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf4112.voila.fr (SMTP Server) with ESMTP id 76ECA1C0036B; Wed, 21 Feb 2007 23:33:53 +0100 (CET) Original-Received: from wwinf4104 (wwinf4104 [172.22.152.31]) by mwinf4112.voila.fr (SMTP Server) with ESMTP id 6DA271C003BD; Wed, 21 Feb 2007 23:33:53 +0100 (CET) X-ME-UUID: 20070221223353449.6DA271C003BD@mwinf4112.voila.fr X-Originating-IP: [86.107.96.49] X-Wum-Nature: EMAIL-NATURE X-WUM-FROM: |~| X-WUM-TO: |~| X-WUM-CC: |~| X-WUM-REPLYTO: |~| X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:66585 Archived-At: Here is the indentation rewriten, and taking into consideration all problems we have just talked about. If there are some other new problems, please report. Alin Soare Index: emacs/lisp/emacs-lisp/lisp-mode.el =================================================================== RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v retrieving revision 1.199 diff -c -r1.199 lisp-mode.el *** emacs/lisp/emacs-lisp/lisp-mode.el 17 Feb 2007 11:34:22 -0000 1.199 --- emacs/lisp/emacs-lisp/lisp-mode.el 21 Feb 2007 22:26:09 -0000 *************** *** 908,942 **** (let ((normal-indent (current-column))) (cond ((elt state 3) ;; Inside a string, don't change indentation. ! nil) ! ((save-excursion ! ;; test whether current line begins with a constant ! (goto-char indent-point) ! (skip-chars-forward " \t") ! (looking-at ":")) ! (let ((desired-indent ! (save-excursion ! (goto-char (1+ containing-sexp)) ! (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) ! (point))) ! (parse-sexp-ignore-comments t)) ! ;; Align a constant symbol under the last constant symbol ! (goto-char calculate-lisp-indent-last-sexp) ! (while (> (point) desired-indent) ! (if (looking-at ":") ! (setq desired-indent (point)) ! (backward-sexp 1)))) ! (current-column)) ((and (integerp lisp-indent-offset) containing-sexp) ;; Indent by constant offset (goto-char containing-sexp) (+ (current-column) lisp-indent-offset)) (desired-indent) - ((and (boundp 'lisp-indent-function) - lisp-indent-function - (not retry)) - (or (funcall lisp-indent-function indent-point state) - normal-indent)) (t normal-indent)))))) --- 908,955 ---- (let ((normal-indent (current-column))) (cond ((elt state 3) ;; Inside a string, don't change indentation. ! nil) ((and (integerp lisp-indent-offset) containing-sexp) ;; Indent by constant offset (goto-char containing-sexp) (+ (current-column) lisp-indent-offset)) + ((save-excursion + ;; the car must be defined on the same line as the inner parenthesis. + ;; in this case calculate-lisp-indent-last-sexp is not nil. + (and containing-sexp + (goto-char (1+ containing-sexp)) + (skip-chars-forward " \t") + (looking-at "\\sw\\|\\s_"))) + (or + ;; try to align the parameters of a known function + (and (boundp 'lisp-indent-function) + lisp-indent-function + (not retry) + (funcall lisp-indent-function indent-point state)) + ;; if not a standard function, try to align a constant-symbol + ;; under the last preceding constant symbol, if there is such one + ;; of the last 2 preceding symbols, in the previous uncommented + ;; line + (and (save-excursion + (goto-char indent-point) + (skip-chars-forward " \t") + (looking-at ":")) + (let ((parse-sexp-ignore-comments t) + indent) + (goto-char calculate-lisp-indent-last-sexp) + (if (looking-at ":") + (setq indent (current-column)) + (when (and (> calculate-lisp-indent-last-sexp containing-sexp) + (< (save-excursion (beginning-of-line) (point)) + (prog2 (backward-sexp) (point)))) + (if (looking-at ":") + (setq indent (current-column))))) + indent)) + ;; another symbols or constants not preceded by a constant + ;; as defined above. + normal-indent)) + ;; in this case calculate-lisp-indent-last-sexp is nil (desired-indent) (t normal-indent))))))