summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lisp-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el38
1 files changed, 32 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 5aa656bd2b5..5576a4882b0 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -97,6 +97,7 @@
'("defun" "defun*" "defsubst" "defmacro"
"defadvice" "define-skeleton"
"define-minor-mode" "define-global-minor-mode"
+ "define-globalized-minor-mode"
"define-derived-mode" "define-generic-mode"
"define-compiler-macro" "define-modify-macro"
"defsetf" "define-setf-expander"
@@ -143,6 +144,7 @@
(put 'define-minor-mode 'doc-string-elt 2)
(put 'easy-mmode-define-global-mode 'doc-string-elt 2)
(put 'define-global-minor-mode 'doc-string-elt 2)
+(put 'define-globalized-minor-mode 'doc-string-elt 2)
(put 'define-generic-mode 'doc-string-elt 7)
(put 'define-ibuffer-filter 'doc-string-elt 2)
(put 'define-ibuffer-op 'doc-string-elt 3)
@@ -907,6 +909,24 @@ is the buffer position of the start of the containing expression."
(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)
@@ -1128,19 +1148,25 @@ ENDPOS is encountered."
(make-list (- next-depth) nil))
last-depth (- last-depth next-depth)
next-depth 0)))
- (or outer-loop-done endpos
- (setq outer-loop-done (<= next-depth 0)))
- (if outer-loop-done
- (forward-line 1)
+ (forward-line 1)
+ ;; Decide whether to exit.
+ (if endpos
+ ;; If we have already reached the specified end,
+ ;; give up and do not reindent this line.
+ (if (<= endpos (point))
+ (setq outer-loop-done t))
+ ;; If no specified end, we are done if we have finished one sexp.
+ (if (<= next-depth 0)
+ (setq outer-loop-done t)))
+ (unless outer-loop-done
(while (> last-depth next-depth)
(setq indent-stack (cdr indent-stack)
last-depth (1- last-depth)))
(while (< last-depth next-depth)
(setq indent-stack (cons nil indent-stack)
last-depth (1+ last-depth)))
- ;; Now go to the next line and indent it according
+ ;; Now indent the next line according
;; to what we learned from parsing the previous one.
- (forward-line 1)
(setq bol (point))
(skip-chars-forward " \t")
;; But not if the line is blank, or just a comment