unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: A Soare <alinsoar@voila.fr>
To: "Emacs   Dev  [emacs-devel]" <emacs-devel@gnu.org>
Subject: Re: Indentation of constants in LISP
Date: Fri, 23 Feb 2007 16:58:18 +0100 (CET)	[thread overview]
Message-ID: <9294387.13631172246298204.JavaMail.www@wwinf4205> (raw)

>     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 ).

------------------------------

             reply	other threads:[~2007-02-23 15:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23 15:58 A Soare [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-22 13:29 Indentation of constants in LISP A Soare
2007-02-22  2:53 A Soare
2007-02-22  2:24 A Soare
2007-02-22 17:20 ` Richard Stallman
2007-02-21 22:33 A Soare
2007-02-21 10:41 A Soare
2007-02-22 17:21 ` Richard Stallman
2007-02-21  8:32 A Soare
2007-02-20 19:17 A Soare
2007-02-21  8:38 ` Richard Stallman
2007-02-20 18:23 A Soare
2007-02-20 15:28 A Soare
2007-02-20 14:26 A Soare
2007-02-21 22:55 ` Richard Stallman
2007-02-20 14:14 A Soare
2007-02-20 18:04 ` Stuart D. Herring
2007-02-05 14:33 A Soare
2007-02-05  9:51 A Soare
2007-02-05  7:41 A Soare
2007-02-05 19:06 ` Stefan Monnier
2007-02-04 13:28 A Soare
2007-02-05  0:23 ` Richard Stallman
2007-02-05  1:28 ` Stefan Monnier
2007-02-04 11:37 A Soare
2007-02-02 16:17 A Soare
2007-02-03 11:19 ` Richard Stallman
2007-02-20 13:29 ` Johan Bockgård
2007-02-21  0:44   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9294387.13631172246298204.JavaMail.www@wwinf4205 \
    --to=alinsoar@voila.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).