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: Thu, 22 Feb 2007 03:24:29 +0100 (CET) Message-ID: <13329186.795071172111069001.JavaMail.www@wwinf4204> Reply-To: alinsoar@voila.fr NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_64988_31914138.1172111069000" X-Trace: sea.gmane.org 1172111099 8654 80.91.229.12 (22 Feb 2007 02:24:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 22 Feb 2007 02:24:59 +0000 (UTC) Cc: "Emacs Dev \[emacs-devel\]" To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 22 03:24:52 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 1HK3dZ-0006yK-Qk for ged-emacs-devel@m.gmane.org; Thu, 22 Feb 2007 03:24:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HK3dZ-0000qI-9w for ged-emacs-devel@m.gmane.org; Wed, 21 Feb 2007 21:24:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HK3dN-0000qD-0A for emacs-devel@gnu.org; Wed, 21 Feb 2007 21:24:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HK3dK-0000q1-Co for emacs-devel@gnu.org; Wed, 21 Feb 2007 21:24:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HK3dK-0000py-6t for emacs-devel@gnu.org; Wed, 21 Feb 2007 21:24:34 -0500 Original-Received: from smtp3.voila.fr ([193.252.22.173]) by monty-python.gnu.org with esmtp (Exim 4.52) id 1HK3dI-0002MX-Dj; Wed, 21 Feb 2007 21:24:33 -0500 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf4204.voila.fr (SMTP Server) with ESMTP id 10C621C00095; Thu, 22 Feb 2007 03:24:29 +0100 (CET) Original-Received: from wwinf4204 (wwinf4204 [10.232.2.31]) by mwinf4204.voila.fr (SMTP Server) with ESMTP id 032591C00092; Thu, 22 Feb 2007 03:24:29 +0100 (CET) X-ME-UUID: 20070222022429129.032591C00092@mwinf4204.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:66594 Archived-At: ------=_Part_64988_31914138.1172111069000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit > If you look closely before trying to atack my code, this always happened . > > Is that a bug in Emacs? C'est pas du tout un bug en Emacs, sinon il s'etait fait faire connaitre sans doute par quelqu'un depuis longtemps. There are simply different definitions. Maybe there was 2 persons: one wrote the indentation for a region, and the other for a line. The indentation for a region uses from time to time the function which calculates the indentation for a line. Still, it does not call this function for every line. Still, indeed, it would have been nice to exist just one definition of indentation. The author of lisp-indent-function is maybe different from the author of indent-sexp, or maybe the same author forgot what he did. If this is consider a bug, then the only one thing to do is to rewrite completely the function indent-sexp. I attach here a new patch, because there were 2 things that I do not like in the patch I have just sent. Now I insert the patch in the text, and I attach it in the same time. Please consider just this latter patch. 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 22 Feb 2007 02:21:08 -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") + calculate-lisp-indent-last-sexp)) + (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) + (or (and (looking-at ":") + (setq indent (current-column))) + (and (> calculate-lisp-indent-last-sexp containing-sexp) + (< (save-excursion (beginning-of-line) (point)) + (prog2 (backward-sexp) (point))) + (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)))))) ------=_Part_64988_31914138.1172111069000 Content-Type: application/octet-stream; name="/patch" content-transfer-encoding: base64 Content-Disposition: attachment; filename="/patch" SW5kZXg6IGVtYWNzL2xpc3AvZW1hY3MtbGlzcC9saXNwLW1vZGUuZWwKPT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1Mg ZmlsZTogL3NvdXJjZXMvZW1hY3MvZW1hY3MvbGlzcC9lbWFjcy1saXNwL2xpc3AtbW9kZS5lbCx2 CnJldHJpZXZpbmcgcmV2aXNpb24gMS4xOTkKZGlmZiAtYyAtcjEuMTk5IGxpc3AtbW9kZS5lbAoq KiogZW1hY3MvbGlzcC9lbWFjcy1saXNwL2xpc3AtbW9kZS5lbAkxNyBGZWIgMjAwNyAxMTozNDoy MiAtMDAwMAkxLjE5OQotLS0gZW1hY3MvbGlzcC9lbWFjcy1saXNwL2xpc3AtbW9kZS5lbAkyMiBG ZWIgMjAwNyAwMjoyMTowOCAtMDAwMAoqKioqKioqKioqKioqKioKKioqIDkwOCw5NDIgKioqKgog ICAgICAgIChsZXQgKChub3JtYWwtaW5kZW50IChjdXJyZW50LWNvbHVtbikpKQogICAgICAgICAg KGNvbmQgKChlbHQgc3RhdGUgMykKICAgICAgICAgICAgICAgICA7OyBJbnNpZGUgYSBzdHJpbmcs IGRvbid0IGNoYW5nZSBpbmRlbnRhdGlvbi4KISAJICAgICAgIG5pbCkKISAgICAgICAgICAgICAg ICgoc2F2ZS1leGN1cnNpb24KISAgICAgICAgICAgICAgICAgIDs7IHRlc3Qgd2hldGhlciBjdXJy ZW50IGxpbmUgYmVnaW5zIHdpdGggYSBjb25zdGFudAohICAgICAgICAgICAgICAgICAgKGdvdG8t Y2hhciBpbmRlbnQtcG9pbnQpCiEgICAgICAgICAgICAgICAgICAoc2tpcC1jaGFycy1mb3J3YXJk ICIgXHQiKQohICAgICAgICAgICAgICAgICAgKGxvb2tpbmctYXQgIjoiKSkKISAgICAgICAgICAg ICAgICAobGV0ICgoZGVzaXJlZC1pbmRlbnQKISAgICAgICAgICAgICAgICAgICAgICAgKHNhdmUt ZXhjdXJzaW9uCiEgICAgICAgICAgICAgICAgICAgICAgICAgKGdvdG8tY2hhciAoMSsgY29udGFp bmluZy1zZXhwKSkKISAgICAgICAgICAgICAgICAgICAgICAgICAocGFyc2UtcGFydGlhbC1zZXhw IChwb2ludCkgY2FsY3VsYXRlLWxpc3AtaW5kZW50LWxhc3Qtc2V4cCAwIHQpCiEgICAgICAgICAg ICAgICAgICAgICAgICAgKHBvaW50KSkpCiEgICAgICAgICAgICAgICAgICAgICAgKHBhcnNlLXNl eHAtaWdub3JlLWNvbW1lbnRzIHQpKQohICAgICAgICAgICAgICAgICAgOzsgQWxpZ24gYSBjb25z dGFudCBzeW1ib2wgdW5kZXIgdGhlIGxhc3QgY29uc3RhbnQgc3ltYm9sCiEgICAgICAgICAgICAg ICAgICAoZ290by1jaGFyIGNhbGN1bGF0ZS1saXNwLWluZGVudC1sYXN0LXNleHApCiEgICAgICAg ICAgICAgICAgICAod2hpbGUgKD4gKHBvaW50KSBkZXNpcmVkLWluZGVudCkKISAgICAgICAgICAg ICAgICAgICAgKGlmIChsb29raW5nLWF0ICI6IikKISAgICAgICAgICAgICAgICAgICAgICAgIChz ZXRxIGRlc2lyZWQtaW5kZW50IChwb2ludCkpCiEgICAgICAgICAgICAgICAgICAgICAgKGJhY2t3 YXJkLXNleHAgMSkpKSkKISAgICAgICAgICAgICAgICAgIChjdXJyZW50LWNvbHVtbikpCiAgICAg ICAgICAgICAgICAoKGFuZCAoaW50ZWdlcnAgbGlzcC1pbmRlbnQtb2Zmc2V0KSBjb250YWluaW5n LXNleHApCiAgICAgICAgICAgICAgICAgOzsgSW5kZW50IGJ5IGNvbnN0YW50IG9mZnNldAogICAg ICAgICAgICAgICAgIChnb3RvLWNoYXIgY29udGFpbmluZy1zZXhwKQogICAgICAgICAgICAgICAg ICgrIChjdXJyZW50LWNvbHVtbikgbGlzcC1pbmRlbnQtb2Zmc2V0KSkKICAgICAgICAgICAgICAg IChkZXNpcmVkLWluZGVudCkKLSAgICAgICAgICAgICAgICgoYW5kIChib3VuZHAgJ2xpc3AtaW5k ZW50LWZ1bmN0aW9uKQotICAgICAgICAgICAgICAgICAgICAgbGlzcC1pbmRlbnQtZnVuY3Rpb24K LSAgICAgICAgICAgICAgICAgICAgIChub3QgcmV0cnkpKQotICAgICAgICAgICAgICAgIChvciAo ZnVuY2FsbCBsaXNwLWluZGVudC1mdW5jdGlvbiBpbmRlbnQtcG9pbnQgc3RhdGUpCi0gICAgICAg ICAgICAgICAgICAgIG5vcm1hbC1pbmRlbnQpKQogICAgICAgICAgICAgICAgKHQKICAgICAgICAg ICAgICAgICBub3JtYWwtaW5kZW50KSkpKSkpCiAgCi0tLSA5MDgsOTU1IC0tLS0KICAgICAgICAo bGV0ICgobm9ybWFsLWluZGVudCAoY3VycmVudC1jb2x1bW4pKSkKICAgICAgICAgIChjb25kICgo ZWx0IHN0YXRlIDMpCiAgICAgICAgICAgICAgICAgOzsgSW5zaWRlIGEgc3RyaW5nLCBkb24ndCBj aGFuZ2UgaW5kZW50YXRpb24uCiEgICAgICAgICAgICAgICAgbmlsKQogICAgICAgICAgICAgICAg KChhbmQgKGludGVnZXJwIGxpc3AtaW5kZW50LW9mZnNldCkgY29udGFpbmluZy1zZXhwKQogICAg ICAgICAgICAgICAgIDs7IEluZGVudCBieSBjb25zdGFudCBvZmZzZXQKICAgICAgICAgICAgICAg ICAoZ290by1jaGFyIGNvbnRhaW5pbmctc2V4cCkKICAgICAgICAgICAgICAgICAoKyAoY3VycmVu dC1jb2x1bW4pIGxpc3AtaW5kZW50LW9mZnNldCkpCisgICAgICAgICAgICAgICAoKHNhdmUtZXhj dXJzaW9uCisgICAgICAgICAgICAgICAgICA7OyB0aGUgY2FyIG11c3QgYmUgZGVmaW5lZCBvbiB0 aGUgc2FtZSBsaW5lIGFzIHRoZSBpbm5lciBwYXJlbnRoZXNpcy4KKyAgICAgICAgICAgICAgICAg IDs7IGluIHRoaXMgY2FzZSBjYWxjdWxhdGUtbGlzcC1pbmRlbnQtbGFzdC1zZXhwIGlzIG5vdCBu aWwuCisgICAgICAgICAgICAgICAgICAoYW5kIGNvbnRhaW5pbmctc2V4cAorICAgICAgICAgICAg ICAgICAgICAgICAoZ290by1jaGFyICgxKyBjb250YWluaW5nLXNleHApKQorICAgICAgICAgICAg ICAgICAgICAgICAoc2tpcC1jaGFycy1mb3J3YXJkICIgXHQiKQorICAgICAgICAgICAgICAgICAg ICAgICBjYWxjdWxhdGUtbGlzcC1pbmRlbnQtbGFzdC1zZXhwKSkKKyAgICAgICAgICAgICAgICAo b3IKKyAgICAgICAgICAgICAgICAgOzsgdHJ5IHRvIGFsaWduIHRoZSBwYXJhbWV0ZXJzIG9mIGEg a25vd24gZnVuY3Rpb24KKyAgICAgICAgICAgICAgICAgKGFuZCAoYm91bmRwICdsaXNwLWluZGVu dC1mdW5jdGlvbikKKyAgICAgICAgICAgICAgICAgICAgICBsaXNwLWluZGVudC1mdW5jdGlvbgor ICAgICAgICAgICAgICAgICAgICAgIChub3QgcmV0cnkpCisgICAgICAgICAgICAgICAgICAgICAg KGZ1bmNhbGwgbGlzcC1pbmRlbnQtZnVuY3Rpb24gaW5kZW50LXBvaW50IHN0YXRlKSkKKyAgICAg ICAgICAgICAgICAgOzsgaWYgbm90IGEgc3RhbmRhcmQgZnVuY3Rpb24sIHRyeSB0byBhbGlnbiBh IGNvbnN0YW50LXN5bWJvbAorICAgICAgICAgICAgICAgICA7OyB1bmRlciB0aGUgbGFzdCBwcmVj ZWRpbmcgY29uc3RhbnQgc3ltYm9sLCBpZiB0aGVyZSBpcyBzdWNoIG9uZQorICAgICAgICAgICAg ICAgICA7OyBvZiB0aGUgbGFzdCAyIHByZWNlZGluZyBzeW1ib2xzLCBpbiB0aGUgcHJldmlvdXMg dW5jb21tZW50ZWQKKyAgICAgICAgICAgICAgICAgOzsgbGluZQorICAgICAgICAgICAgICAgICAo YW5kIChzYXZlLWV4Y3Vyc2lvbgorICAgICAgICAgICAgICAgICAgICAgICAgKGdvdG8tY2hhciBp bmRlbnQtcG9pbnQpCisgICAgICAgICAgICAgICAgICAgICAgICAoc2tpcC1jaGFycy1mb3J3YXJk ICIgXHQiKQorICAgICAgICAgICAgICAgICAgICAgICAgKGxvb2tpbmctYXQgIjoiKSkKKyAgICAg ICAgICAgICAgICAgKGxldCAoKHBhcnNlLXNleHAtaWdub3JlLWNvbW1lbnRzIHQpCisgICAgICAg ICAgICAgICAgICAgICAgIGluZGVudCkKKyAgICAgICAgICAgICAgICAgICAoZ290by1jaGFyIGNh bGN1bGF0ZS1saXNwLWluZGVudC1sYXN0LXNleHApCisgICAgICAgICAgICAgICAgICAgKG9yIChh bmQgKGxvb2tpbmctYXQgIjoiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzZXRxIGlu ZGVudCAoY3VycmVudC1jb2x1bW4pKSkKKyAgICAgICAgICAgICAgICAgICAgICAgKGFuZCAoPiBj YWxjdWxhdGUtbGlzcC1pbmRlbnQtbGFzdC1zZXhwIGNvbnRhaW5pbmctc2V4cCkKKyAgICAgICAg ICAgICAgICAgICAgICAgICAgICAoPCAoc2F2ZS1leGN1cnNpb24gKGJlZ2lubmluZy1vZi1saW5l KSAocG9pbnQpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChwcm9nMiAoYmFja3dh cmQtc2V4cCkgKHBvaW50KSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGxvb2tpbmct YXQgIjoiKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHNldHEgaW5kZW50IChj dXJyZW50LWNvbHVtbikpKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIGluZGVudCkpCisgICAg ICAgICAgICAgICAgIDs7IGFub3RoZXIgc3ltYm9scyBvciBjb25zdGFudHMgbm90IHByZWNlZGVk IGJ5IGEgY29uc3RhbnQKKyAgICAgICAgICAgICAgICAgOzsgYXMgZGVmaW5lZCBhYm92ZS4KKyAg ICAgICAgICAgICAgICAgbm9ybWFsLWluZGVudCkpCisgICAgICAgICAgICAgICA7OyBpbiB0aGlz IGNhc2UgY2FsY3VsYXRlLWxpc3AtaW5kZW50LWxhc3Qtc2V4cCBpcyBuaWwKICAgICAgICAgICAg ICAgIChkZXNpcmVkLWluZGVudCkKICAgICAgICAgICAgICAgICh0CiAgICAgICAgICAgICAgICAg bm9ybWFsLWluZGVudCkpKSkpKQogIAo= ------=_Part_64988_31914138.1172111069000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_Part_64988_31914138.1172111069000--