[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 63121eb 049/108: Restore point even when errors.
From: |
Artur Malabarba |
Subject: |
[elpa] master 63121eb 049/108: Restore point even when errors. |
Date: |
Wed, 25 Mar 2015 18:39:03 +0000 |
branch: master
commit 63121eb44a515ed489face58e4b8e526dbe63481
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Restore point even when errors.
Fixes #23.
---
aggressive-indent.el | 46 ++++++++++++++++++++++++----------------------
1 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/aggressive-indent.el b/aggressive-indent.el
index 893567f..07bc7d5 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -276,28 +276,30 @@ until nothing more happens."
(let ((p (point-marker))
was-begining-of-line)
(set-marker-insertion-type p t)
- (goto-char r)
- (setq was-begining-of-line
- (= r (line-beginning-position)))
- ;; If L is at the end of a line, skip that line.
- (unless (= l r)
- (goto-char l)
- (when (= l (line-end-position))
- (cl-incf l)))
- ;; Indent the affected region.
- (unless (= l r) (indent-region l r))
- ;; `indent-region' doesn't do anything if R was the beginning of a line,
so we indent manually there.
- (when was-begining-of-line
- (indent-according-to-mode))
- ;; And then we indent each following line until nothing happens.
- (forward-line 1)
- (while (and (null (eobp))
- (/= (progn (skip-chars-forward "[:blank:]\n")
- (point))
- (progn (indent-according-to-mode)
- (point))))
- (forward-line 1))
- (goto-char p)))
+ (unwind-protect
+ (progn
+ (goto-char r)
+ (setq was-begining-of-line
+ (= r (line-beginning-position)))
+ ;; If L is at the end of a line, skip that line.
+ (unless (= l r)
+ (goto-char l)
+ (when (= l (line-end-position))
+ (cl-incf l)))
+ ;; Indent the affected region.
+ (unless (= l r) (indent-region l r))
+ ;; `indent-region' doesn't do anything if R was the beginning of a
line, so we indent manually there.
+ (when was-begining-of-line
+ (indent-according-to-mode))
+ ;; And then we indent each following line until nothing happens.
+ (forward-line 1)
+ (while (and (null (eobp))
+ (/= (progn (skip-chars-forward "[:blank:]\n")
+ (point))
+ (progn (indent-according-to-mode)
+ (point))))
+ (forward-line 1)))
+ (goto-char p))))
(defun -softly-indent-region-and-on (l r &rest _)
"Indent current defun unobstrusively.
- [elpa] master c35bc62 039/108: Skip indenting lines only barely touched by changed region., (continued)
- [elpa] master c35bc62 039/108: Skip indenting lines only barely touched by changed region., Artur Malabarba, 2015/03/25
- [elpa] master 130b938 040/108: Redundant group specification., Artur Malabarba, 2015/03/25
- [elpa] master 69b5adc 042/108: Merge pull request #20 from tuhdo/master, Artur Malabarba, 2015/03/25
- [elpa] master c81d5c2 044/108: Add erc-mode to excluded-modes, Artur Malabarba, 2015/03/25
- [elpa] master 278084b 047/108: Add more to excluded-modes, Artur Malabarba, 2015/03/25
- [elpa] master d0a4bae 048/108: Typo, Artur Malabarba, 2015/03/25
- [elpa] master 7d8d0d2 038/108: Version bump, Artur Malabarba, 2015/03/25
- [elpa] master 45d25c3 045/108: List dependency in the Readme, Artur Malabarba, 2015/03/25
- [elpa] master 32f6156 050/108: Rename changed-list to -changed-list, Artur Malabarba, 2015/03/25
- [elpa] master 94d84bc 051/108: Doc, Artur Malabarba, 2015/03/25
- [elpa] master 63121eb 049/108: Restore point even when errors.,
Artur Malabarba <=
- [elpa] master 34d80b4 043/108: Remove apology, Artur Malabarba, 2015/03/25
- [elpa] master 2a9c593 052/108: Remove old special treatment for css-mode, Artur Malabarba, 2015/03/25
- [elpa] master 675224c 054/108: Rename gifs, Artur Malabarba, 2015/03/25
- [elpa] master 7a4794a 053/108: Use the do-softly macro, Artur Malabarba, 2015/03/25
- [elpa] master ecfbf94 055/108: Define new delete-backward bound to backspace., Artur Malabarba, 2015/03/25
- [elpa] master e169391 046/108: Prevent electric indenting on ruby-mode, Artur Malabarba, 2015/03/25
- [elpa] master 726291c 058/108: Redo fix for #25, Artur Malabarba, 2015/03/25
- [elpa] master a8e467c 056/108: Quick fix for the buggy map., Artur Malabarba, 2015/03/25
- [elpa] master dae81af 060/108: Merge pull request #28 from tsdh/master, Artur Malabarba, 2015/03/25
- [elpa] master f70f0ff 059/108: Don't indent in strings (fixes #27), Artur Malabarba, 2015/03/25