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: Fri, 23 Feb 2007 16:58:18 +0100 (CET) Message-ID: <9294387.13631172246298204.JavaMail.www@wwinf4205> 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 1172246318 11331 80.91.229.12 (23 Feb 2007 15:58:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 23 Feb 2007 15:58:38 +0000 (UTC) To: "Emacs Dev [emacs-devel]" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 23 16:58:32 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 1HKcoZ-0002mP-Fu for ged-emacs-devel@m.gmane.org; Fri, 23 Feb 2007 16:58:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HKcoZ-00065q-BN for ged-emacs-devel@m.gmane.org; Fri, 23 Feb 2007 10:58:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HKcoP-00065I-9J for emacs-devel@gnu.org; Fri, 23 Feb 2007 10:58:21 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HKcoN-000656-NA for emacs-devel@gnu.org; Fri, 23 Feb 2007 10:58:20 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HKcoN-000653-Ga for emacs-devel@gnu.org; Fri, 23 Feb 2007 10:58:19 -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 1HKcoM-0005cG-Uu for emacs-devel@gnu.org; Fri, 23 Feb 2007 10:58:19 -0500 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf4112.voila.fr (SMTP Server) with ESMTP id 404DD1C00484 for ; Fri, 23 Feb 2007 16:58:18 +0100 (CET) Original-Received: from wwinf4205 (wwinf4205 [10.232.2.32]) by mwinf4112.voila.fr (SMTP Server) with ESMTP id 3646D1C0042D for ; Fri, 23 Feb 2007 16:58:18 +0100 (CET) X-ME-UUID: 20070223155818222.3646D1C0042D@mwinf4112.voila.fr X-Originating-IP: [89.34.170.37] X-Wum-Nature: EMAIL-NATURE X-WUM-FROM: |~| X-WUM-TO: |~| 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:66671 Archived-At: > There are simply different definitions. Maybe there was 2 persons: > one wrote the indentation for a region, and the other for a line. > > Yes, but the two commands are SUPPOSED to indent everything the same way. > If they do it differently, I think that is a bug. > > Can you state a precise test case for this bug? > There some ambiguities: One problem: I do not understand why the indentation of a line is defined twice: one in the function indent-sexp : ;; Now indent the next line according ;; to what we learned from parsing the previous one. (setq bol (point)) (skip-chars-forward " \t") ;; But not if the line is blank, or just a comment ;; (except for double-semi comments; indent them as usual). (if (or (eobp) (looking-at "\\s<\\|\n")) ET CAETERA and, the second time, in the function lisp-indent-line. (defun lisp-indent-line (&optional whole-exp) "Indent current line as Lisp code. With argument, indent any additional lines of the same expression rigidly along with this one." (interactive "P") (let ((indent (calculate-lisp-indent)) shift-amt end (pos (- (point-max) (point))) (beg (progn (beginning-of-line) (point)))) (skip-chars-forward " \t") (if (or (null indent) (looking-at "\\s<\\s<\\s<")) ;; Don't alter indentation of a ;;; comment line ;; or a line that starts in a string. (goto-char (- (point-max) pos)) (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<"))) ;; Single-semicolon comment lines should be indented ;; as comment lines, not as code. This seems ambigous. In indent-sexp we can check simplement whether the line is empty. If it is not empty, we call lisp-indent-line. ---------------------------- The second problem: Why the function lisp-indent-region is written so: (defun lisp-indent-region (start end) "Indent every line whose first char is between START and END inclusive." (save-excursion (let ((endmark (copy-marker end))) (goto-char start) (and (bolp) (not (eolp)) (lisp-indent-line)) (indent-sexp endmark) (set-marker endmark nil)))) using indent-sexp instead to look something like this: (defun lisp-indent-region (start end) "Indent every line whose first char is between START and END inclusive." (save-excursion (goto-char start) (while (< (point) end) (or (eobp) (looking-at "\\s<\\|\n") (lisp-indent-line)) (forward-line)) (set-marker (copy-marker end) nil) (message "indent region finished"))) The logic of indent-sexp seems to have been written to indent a lisp expression, that starts exactly after an open syntax class symbol (, until to its corresponding ). ------------------------------