[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indentation of constants in LISP
From: |
A Soare |
Subject: |
Re: Indentation of constants in LISP |
Date: |
Thu, 22 Feb 2007 03:53:43 +0100 (CET) |
I made a new little modification, because I forgot to cut 3 lines before the
old (looking-at ).
Please forget about the later patch.
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:51:26 -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,950 ----
(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))
+ (calculate-lisp-indent-last-sexp
+ ;; in this case calculate-lisp-indent-last-sexp is not nil.
+ (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))))))
- Re: Indentation of constants in LISP, (continued)
- Re: Indentation of constants in LISP, A Soare, 2007/02/20
- Re: Indentation of constants in LISP, A Soare, 2007/02/20
- Re: Indentation of constants in LISP, A Soare, 2007/02/20
- Re: Indentation of constants in LISP, A Soare, 2007/02/21
- Re: Indentation of constants in LISP, A Soare, 2007/02/21
- Re: Indentation of constants in LISP, A Soare, 2007/02/21
- Re: Indentation of constants in LISP, A Soare, 2007/02/21
- Re: Indentation of constants in LISP,
A Soare <=
- Re: Indentation of constants in LISP, A Soare, 2007/02/22
- Re: Indentation of constants in LISP, A Soare, 2007/02/23