aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-05 21:51:44 +0000
committerRichard M. Stallman1997-04-05 21:51:44 +0000
commit531cbff1cc53fe36ddf29a33876f3fdb9eb3666b (patch)
tree0e917a9d3a6314c365e24f6009b37c492864e915
parente7c8378c39bbb87659d3b9251dcc28b0d8cdb509 (diff)
downloademacs-531cbff1cc53fe36ddf29a33876f3fdb9eb3666b.tar.gz
emacs-531cbff1cc53fe36ddf29a33876f3fdb9eb3666b.zip
(indent-sexp): If calculate-lisp-indent returns nil,
don't change the line's indentation. (lisp-indent-line): Likewise. (lisp-comment-indent): Likewise. (calculate-lisp-indent): Return nil if line starts inside a string.
-rw-r--r--lisp/emacs-lisp/lisp-mode.el36
1 files changed, 20 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index a48a7efe421..ebdee0673ee 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -338,7 +338,7 @@ With argument, insert value in current buffer after the defun."
338 (if (looking-at "\\s<\\s<\\s<") 338 (if (looking-at "\\s<\\s<\\s<")
339 (current-column) 339 (current-column)
340 (if (looking-at "\\s<\\s<") 340 (if (looking-at "\\s<\\s<")
341 (let ((tem (calculate-lisp-indent))) 341 (let ((tem (or (calculate-lisp-indent) (current-column))))
342 (if (listp tem) (car tem) tem)) 342 (if (listp tem) (car tem) tem))
343 (skip-chars-backward " \t") 343 (skip-chars-backward " \t")
344 (max (if (bolp) 0 (1+ (current-column))) 344 (max (if (bolp) 0 (1+ (current-column)))
@@ -357,8 +357,9 @@ rigidly along with this one."
357 (beginning-of-line) 357 (beginning-of-line)
358 (setq beg (point)) 358 (setq beg (point))
359 (skip-chars-forward " \t") 359 (skip-chars-forward " \t")
360 (if (looking-at "\\s<\\s<\\s<") 360 (if (or (null indent) (looking-at "\\s<\\s<\\s<"))
361 ;; Don't alter indentation of a ;;; comment line. 361 ;; Don't alter indentation of a ;;; comment line
362 ;; or a line that starts in a string.
362 (goto-char (- (point-max) pos)) 363 (goto-char (- (point-max) pos))
363 (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<"))) 364 (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<")))
364 ;; Single-semicolon comment lines should be indented 365 ;; Single-semicolon comment lines should be indented
@@ -391,11 +392,14 @@ rigidly along with this one."
391(defun calculate-lisp-indent (&optional parse-start) 392(defun calculate-lisp-indent (&optional parse-start)
392 "Return appropriate indentation for current line as Lisp code. 393 "Return appropriate indentation for current line as Lisp code.
393In usual case returns an integer: the column to indent to. 394In usual case returns an integer: the column to indent to.
394Can instead return a list, whose car is the column to indent to. 395If the value is nil, that means don't change the indentation
396because the line starts inside a string.
397
398The value can also be a list of the form (COLUMN CONTAINING-SEXP-START).
395This means that following lines at the same level of indentation 399This means that following lines at the same level of indentation
396should not necessarily be indented the same way. 400should not necessarily be indented the same as this line.
397The second element of the list is the buffer position 401Then COLUMN is the column to indent to, and CONTAINING-SEXP-START
398of the start of the containing expression." 402is the buffer position of the start of the containing expression."
399 (save-excursion 403 (save-excursion
400 (beginning-of-line) 404 (beginning-of-line)
401 (let ((indent-point (point)) 405 (let ((indent-point (point))
@@ -470,9 +474,7 @@ of the start of the containing expression."
470 (let ((normal-indent (current-column))) 474 (let ((normal-indent (current-column)))
471 (cond ((elt state 3) 475 (cond ((elt state 3)
472 ;; Inside a string, don't change indentation. 476 ;; Inside a string, don't change indentation.
473 (goto-char indent-point) 477 nil)
474 (skip-chars-forward " \t")
475 (current-column))
476 ((and (integerp lisp-indent-offset) containing-sexp) 478 ((and (integerp lisp-indent-offset) containing-sexp)
477 ;; Indent by constant offset 479 ;; Indent by constant offset
478 (goto-char containing-sexp) 480 (goto-char containing-sexp)
@@ -692,12 +694,14 @@ ENDPOS is encountered."
692 (let ((val (calculate-lisp-indent 694 (let ((val (calculate-lisp-indent
693 (if (car indent-stack) (- (car indent-stack)) 695 (if (car indent-stack) (- (car indent-stack))
694 starting-point)))) 696 starting-point))))
695 (if (integerp val) 697 (if (null val)
696 (setcar indent-stack 698 (setq this-indent val)
697 (setq this-indent val)) 699 (if (integerp val)
698 (setcar indent-stack (- (car (cdr val)))) 700 (setcar indent-stack
699 (setq this-indent (car val))))) 701 (setq this-indent val))
700 (if (/= (current-column) this-indent) 702 (setcar indent-stack (- (car (cdr val))))
703 (setq this-indent (car val))))))
704 (if (and this-indent (/= (current-column) this-indent))
701 (progn (delete-region bol (point)) 705 (progn (delete-region bol (point))
702 (indent-to this-indent))))) 706 (indent-to this-indent)))))
703 (or outer-loop-done 707 (or outer-loop-done