summaryrefslogtreecommitdiff
path: root/paredit.el
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2011-04-09 18:25:23 +0000
committerTaylor R Campbell <campbell@mumble.net>2011-04-09 18:25:23 +0000
commit6918d89538657a9d31efdb1f51465df65bb4bb7f (patch)
tree813d9e8ea947160f711ae21d1983585f83bead7b /paredit.el
parent678d843137c5a58b586ad0fd6eafe06dfdcf3cce (diff)
Don't indent while the buffer is in intermediate broken states.
Ignore-this: eb090de24ae6a8502605aefee51420a4 Emacs may have indentation methods that rely on the buffer's being balanced. The change to `paredit-forward-barf-sexp' is OK because when `paredit-forward-and-indent' calls `indent-region', the point will be on the same line as the closing delimiter, so it will get indented correctly. Add regression tests. darcs-hash:20110409182523-00fcc-5ed49a704f12afa1fb9353eb8dcd5d97e963964c
Diffstat (limited to 'paredit.el')
-rw-r--r--paredit.el25
1 files changed, 13 insertions, 12 deletions
diff --git a/paredit.el b/paredit.el
index f9654be..5fef46d 100644
--- a/paredit.el
+++ b/paredit.el
@@ -2206,17 +2206,18 @@ If in a string, move the opening double-quote forward by one
(up-list) ; Up to the end of the list to
(let ((close (char-before))) ; save and delete the closing
(backward-delete-char 1) ; delimiter.
- (catch 'return ; Go to the end of the desired
- (while t ; S-expression, going up a
- (paredit-handle-sexp-errors ; list if it's not in this,
- (progn (paredit-forward-and-indent)
- (throw 'return nil))
- (up-list)
- (setq close ; adjusting for mixed
- (prog1 (char-before) ; delimiters as necessary,
- (backward-delete-char 1)
- (insert close))))))
- (insert close))) ; to insert that delimiter.
+ (let ((start (point)))
+ (catch 'return ; Go to the end of the desired
+ (while t ; S-expression, going up a
+ (paredit-handle-sexp-errors ; list if it's not in this,
+ (progn (forward-sexp) (throw 'return nil))
+ (up-list)
+ (setq close ; adjusting for mixed
+ (prog1 (char-before) ; delimiters as necessary,
+ (backward-delete-char 1)
+ (insert close))))))
+ (insert close) ; to insert that delimiter.
+ (indent-region start (point) nil))))
(defun paredit-forward-slurp-into-string ()
(goto-char (1+ (cdr (paredit-string-start+end-points))))
@@ -2245,7 +2246,7 @@ Automatically reindent the newly barfed S-expression with respect to
(cond ((bobp)
(error "Barfing all subexpressions with no open-paren?"))
((paredit-in-comment-p) ; Don't put the close-paren in
- (newline-and-indent))) ; a comment.
+ (newline))) ; a comment.
(insert close))
;; Reindent all of the newly barfed S-expressions.
(paredit-forward-and-indent)))