all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: A Soare <alinsoar@voila.fr>
To: rms@gnu.org
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Indentation of constants in LISP
Date: Mon,  5 Feb 2007 15:33:33 +0100 (CET)	[thread overview]
Message-ID: <24895774.9101170686013081.JavaMail.www@wwinf4006> (raw)

[-- Attachment #1: Type: text/plain, Size: 156 bytes --]

I send again teh files, because I see now that there was an error in change-log and one in diff-long-format, and one error in diff-short-format.

A Soare



[-- Attachment #2: /diff-long-format --]
[-- Type: application/octet-stream, Size: 3807 bytes --]


Index: emacs/lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.196
diff -c -r1.196 lisp-mode.el
*** emacs/lisp/emacs-lisp/lisp-mode.el	21 Jan 2007 02:44:24 -0000	1.196
--- emacs/lisp/emacs-lisp/lisp-mode.el	5 Feb 2007 14:23:37 -0000
***************
*** 907,912 ****
--- 907,960 ----
          (cond ((elt state 3)
                 ;; Inside a string, don't change indentation.
  	       nil)
+               ((save-excursion
+                  ;; test whether current line begins with a constant
+                  ;;
+                  ;; from the beginning of the current-line (indent-point) we jump
+                  ;; to the first readable character, if there is one.
+                  ;; before this first readable character we have or SPACE, or TAB
+                  ;; or NEW-LINE. If the first character is ?\:, we consider that it
+                  ;; is the start of a constant symbol, because the syntax class of ?\:
+                  ;; is "_", i.e. ":" is symbol constituent. If there is possible to
+                  ;; change the syntax table of LISP major mode for some practical
+                  ;; reasons, so that one of the characters SPACE, TAB or NEW-LINE
+                  ;; become a symbol constituent, it is necessary to uncomment and
+                  ;; insert into save-excursion just one of the 2 last conditions
+                  (goto-char indent-point)
+                  (skip-chars-forward " \t")
+                  (looking-at ":"))
+                ;;(and (string-equal (string (char-syntax ?\:)) "_")
+                ;;     (not (char-equal (char-syntax (preceding-char)) ?\_)))
+                ;;(zerop (skip-syntax-backward "w_"))
+                (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
+                  ;; Not used keywordp in order not to intern it.
+                  ;;
+                  ;; desired-indent is initialised with the beginning of the
+                  ;; first sexp from the last opened parenthesis (i.e. the first
+                  ;; expression from the same level as the point's).
+                  ;; we begin checking from the last sexp before the indent-point
+                  ;; i.e. from calculate-lisp-indent-last-sexp.
+                  ;; backward-sexp goes back one sexp by one sexp.
+                  ;; In case that we find a ":", we stop, because this is the beginning of
+                  ;; a symbol. If it were not the beginning , then backward-sexp would
+                  ;; jump more, so it is not necessary to do another verification
+                  ;; to check this is a constant.
+                  ;; I made parse-sexp-ignore-comments locally true, to be sure that
+                  ;; comments are ignored by backward-sexp in this searching
+                  ;; finally we return the current column, which will be the result of
+                  ;; this function.
+                  (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)


[-- Attachment #3: /diff-short-format --]
[-- Type: application/octet-stream, Size: 1605 bytes --]

Index: emacs/lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.196
diff -c -r1.196 lisp-mode.el
*** emacs/lisp/emacs-lisp/lisp-mode.el	21 Jan 2007 02:44:24 -0000	1.196
--- emacs/lisp/emacs-lisp/lisp-mode.el	5 Feb 2007 14:26:46 -0000
***************
*** 907,912 ****
--- 907,930 ----
          (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)

[-- Attachment #4: /change-log --]
[-- Type: application/octet-stream, Size: 166 bytes --]

2007-02-05  Alin C. Soare  <alinsoar@voila.fr>  (tiny change)

	* lisp/emacs-lisp/lisp-mode.el (calculate-lisp-indent):
	Added indentation for the constants of Lisp.

[-- Attachment #5: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-02-05 14:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05 14:33 A Soare [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-23 15:58 Indentation of constants in LISP A Soare
2007-02-22 13:29 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  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

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

  git send-email \
    --in-reply-to=24895774.9101170686013081.JavaMail.www@wwinf4006 \
    --to=alinsoar@voila.fr \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.