From: A Soare <alinsoar@voila.fr>
To: rms@gnu.org
Cc: "Emacs Dev \[emacs-devel\]" <emacs-devel@gnu.org>
Subject: Re: Indentation of constants in LISP
Date: Thu, 22 Feb 2007 03:24:29 +0100 (CET) [thread overview]
Message-ID: <13329186.795071172111069001.JavaMail.www@wwinf4204> (raw)
[-- Attachment #1: Type: text/plain, Size: 5629 bytes --]
> 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))))))
[-- Attachment #2: /patch --]
[-- Type: application/octet-stream, Size: 4526 bytes --]
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))))))
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next reply other threads:[~2007-02-22 2:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-22 2:24 A Soare [this message]
2007-02-22 17:20 ` Indentation of constants in LISP Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2007-02-23 15:58 A Soare
2007-02-22 13:29 A Soare
2007-02-22 2:53 A Soare
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13329186.795071172111069001.JavaMail.www@wwinf4204 \
--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.