Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 76324:b72eb510e3d7
(calculate-lisp-indent): Redo previous change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 05 Mar 2007 03:20:58 +0000 |
parents | 2e16068bd4fb |
children | def0f242e449 91bf6e05918b |
comparison
equal
deleted
inserted
replaced
76323:0aef0bcf12f7 | 76324:b72eb510e3d7 |
---|---|
907 ;; or if the desired indentation has already been computed. | 907 ;; or if the desired indentation has already been computed. |
908 (let ((normal-indent (current-column))) | 908 (let ((normal-indent (current-column))) |
909 (cond ((elt state 3) | 909 (cond ((elt state 3) |
910 ;; Inside a string, don't change indentation. | 910 ;; Inside a string, don't change indentation. |
911 nil) | 911 nil) |
912 ((save-excursion | |
913 ;; test whether current line begins with a constant | |
914 (goto-char indent-point) | |
915 (skip-chars-forward " \t") | |
916 (looking-at ":")) | |
917 (let ((desired-indent | |
918 (save-excursion | |
919 (goto-char (1+ containing-sexp)) | |
920 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) | |
921 (point))) | |
922 (parse-sexp-ignore-comments t)) | |
923 ;; Align a constant symbol under the last constant symbol | |
924 (goto-char calculate-lisp-indent-last-sexp) | |
925 (while (> (point) desired-indent) | |
926 (if (looking-at ":") | |
927 (setq desired-indent (point)) | |
928 (backward-sexp 1)))) | |
929 (current-column)) | |
930 ((and (integerp lisp-indent-offset) containing-sexp) | 912 ((and (integerp lisp-indent-offset) containing-sexp) |
931 ;; Indent by constant offset | 913 ;; Indent by constant offset |
932 (goto-char containing-sexp) | 914 (goto-char containing-sexp) |
933 (+ (current-column) lisp-indent-offset)) | 915 (+ (current-column) lisp-indent-offset)) |
916 ;; in this case calculate-lisp-indent-last-sexp is not nil | |
917 (calculate-lisp-indent-last-sexp | |
918 (or | |
919 ;; try to align the parameters of a known function | |
920 (and lisp-indent-function | |
921 (not retry) | |
922 (funcall lisp-indent-function indent-point state)) | |
923 ;; If the function has no special alignment | |
924 ;; or it does not apply to this argument, | |
925 ;; try to align a constant-symbol under the last | |
926 ;; preceding constant symbol, if there is such one of | |
927 ;; the last 2 preceding symbols, in the previous | |
928 ;; uncommented line. | |
929 (and (save-excursion | |
930 (goto-char indent-point) | |
931 (skip-chars-forward " \t") | |
932 (looking-at ":")) | |
933 (> calculate-lisp-indent-last-sexp | |
934 (save-excursion | |
935 (goto-char (1+ containing-sexp)) | |
936 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) | |
937 (point))) | |
938 (let ((parse-sexp-ignore-comments t) | |
939 indent) | |
940 (goto-char calculate-lisp-indent-last-sexp) | |
941 (or (and (looking-at ":") | |
942 (setq indent (current-column))) | |
943 (and (< (save-excursion (beginning-of-line) (point)) | |
944 (prog2 (backward-sexp) (point))) | |
945 (looking-at ":") | |
946 (setq indent (current-column)))) | |
947 indent)) | |
948 ;; another symbols or constants not preceded by a constant | |
949 ;; as defined above. | |
950 normal-indent)) | |
951 ;; in this case calculate-lisp-indent-last-sexp is nil | |
934 (desired-indent) | 952 (desired-indent) |
935 ((and (boundp 'lisp-indent-function) | |
936 lisp-indent-function | |
937 (not retry)) | |
938 (or (funcall lisp-indent-function indent-point state) | |
939 normal-indent)) | |
940 (t | 953 (t |
941 normal-indent)))))) | 954 normal-indent)))))) |
942 | 955 |
943 (defun lisp-indent-function (indent-point state) | 956 (defun lisp-indent-function (indent-point state) |
944 "This function is the normal value of the variable `lisp-indent-function'. | 957 "This function is the normal value of the variable `lisp-indent-function'. |