[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7a4794a 053/108: Use the do-softly macro
From: |
Artur Malabarba |
Subject: |
[elpa] master 7a4794a 053/108: Use the do-softly macro |
Date: |
Wed, 25 Mar 2015 18:39:05 +0000 |
branch: master
commit 7a4794a6d13ae970d80d901de49d387c8df38d88
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Use the do-softly macro
---
aggressive-indent.el | 52 +++++++++++++++++++------------------------------
1 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/aggressive-indent.el b/aggressive-indent.el
index e5c5648..7d6f519 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -89,6 +89,24 @@
(require 'cl-lib)
(require 'names)
+(defmacro aggressive-indent--do-softly (&rest body)
+ "Execute body unobstrusively.
+This means:
+ 1. Do nothing in several situations, specified by
+ `aggressive-indent-dont-indent-if' and
+ `aggressive-indent--internal-dont-indent-if'.
+ 2. Silence all messages.
+ 3. Never throw errors.
+Meant for use in functions which go in hooks."
+ (declare (debug t))
+ `(unless (or (run-hook-wrapped
+ 'aggressive-indent--internal-dont-indent-if
+ #'eval)
+ (aggressive-indent--run-user-hooks))
+ (ignore-errors
+ (cl-letf (((symbol-function 'message) #'ignore))
+ ,@body))))
+
;;;###autoload
(define-namespace aggressive-indent- :group indent
@@ -219,24 +237,6 @@ erroring again."
(setq -has-errored t)
(message -error-message er))))))
-(defmacro -do-softly (&rest body)
- "Execute body unobstrusively.
-This means: do nothing if mark is active (to avoid deactivaing
-it), or if buffer is not modified (to avoid creating accidental
-modifications), or if any of the forms in
-`aggressive-indent-dont-indent-if' evaluates to non-nil.
-
-Also, never throw errors nor messages.
-Meant for use in functions which go in hooks."
- (declare (debug t))
- `(unless (or (run-hook-wrapped
- 'aggressive-indent--internal-dont-indent-if
- #'eval)
- (aggressive-indent--run-user-hooks))
- (ignore-errors
- (cl-letf (((symbol-function 'message) #'ignore))
- ,@body))))
-
:autoload
(defun indent-defun ()
"Indent current defun.
@@ -253,13 +253,7 @@ Throw an error if parentheses are unbalanced."
"Indent current defun unobstrusively.
Like `aggressive-indent-indent-defun', but wrapped in a
`aggressive-indent--do-softly'."
- (unless (or (run-hook-wrapped
- 'aggressive-indent--internal-dont-indent-if
- #'eval)
- (aggressive-indent--run-user-hooks))
- (ignore-errors
- (cl-letf (((symbol-function 'message) #'ignore))
- (indent-defun)))))
+ (aggressive-indent--do-softly (indent-defun)))
:autoload
(defun indent-region-and-on (l r)
@@ -299,13 +293,7 @@ until nothing more happens."
"Indent current defun unobstrusively.
Like `aggressive-indent-indent-region-and-on', but wrapped in a
`aggressive-indent--do-softly'."
- (unless (or (run-hook-wrapped
- 'aggressive-indent--internal-dont-indent-if
- #'eval)
- (aggressive-indent--run-user-hooks))
- (ignore-errors
- (cl-letf (((symbol-function 'message) #'ignore))
- (indent-region-and-on l r)))))
+ (aggressive-indent--do-softly (indent-region-and-on l r)))
(defvar -changed-list-right nil
"List of right limit of regions changed in the last command loop.")
- [elpa] master 278084b 047/108: Add more to excluded-modes, (continued)
- [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, 2015/03/25
- [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 <=
- [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
- [elpa] master eefeecc 062/108: Add diff-mode and makefile-mode to excluded-modes., Artur Malabarba, 2015/03/25
- [elpa] master e4a4026 061/108: Prevent that to replace the 'message' func to 'ignore' func., Artur Malabarba, 2015/03/25
- [elpa] master 105e746 057/108: Another quickfix, Artur Malabarba, 2015/03/25
- [elpa] master e9fea53 066/108: Fix corner-case with thing-at-point, Artur Malabarba, 2015/03/25