[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8af72c5 024/108: Factor out the soft part into a macro.
From: |
Artur Malabarba |
Subject: |
[elpa] master 8af72c5 024/108: Factor out the soft part into a macro. |
Date: |
Wed, 25 Mar 2015 18:38:53 +0000 |
branch: master
commit 8af72c5ea68edd3dbdf9081b3dc27daa61c2d141
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Factor out the soft part into a macro.
---
aggressive-indent.el | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/aggressive-indent.el b/aggressive-indent.el
index 4b5d359..a88204b 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -172,24 +172,6 @@ See `aggressive-indent--internal-dont-indent-if' for usage
examples."
"Keep track of whether `aggressive-indent-dont-indent-if' is throwing.
This is used to prevent an infinite error loop on the user.")
-(defun -softly-indent-defun ()
- "Indent current defun unobstrusively.
-Like `aggressive-indent-indent-defun', except do nothing if
-mark is active (to avoid deactivaing it), or if buffer is not
-modified (to avoid creating accidental modifications).
-Also, never throw errors nor messages.
-
-Meant for use in hooks. Interactively, use the other one.
-Indentation is not performed if any of the forms in
-`dont-indent-if' evaluates to non-nil."
- (unless (or (run-hook-wrapped
- 'aggressive-indent--internal-dont-indent-if
- #'eval)
- (-run-user-hooks))
- (ignore-errors
- (cl-letf (((symbol-function 'message) #'ignore))
- (indent-defun)))))
-
(defun -run-user-hooks ()
"Safely run forms in `aggressive-indent-dont-indent-if'.
If any of them errors out, we only report it once until it stops
@@ -203,6 +185,24 @@ 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.
@@ -215,6 +215,12 @@ Throw an error if parentheses are unbalanced."
(save-excursion (end-of-defun 1) (point)))
(goto-char p)))
+(defun -softly-indent-defun ()
+ "Indent current defun unobstrusively.
+Like `aggressive-indent-indent-defun', but wrapped in a
+`aggressive-indent--do-softly'."
+ (-do-softly (indent-defun)))
+
;;; Minor modes
:autoload
- [elpa] master 36abeb1 002/108: First Commit., (continued)
- [elpa] master 36abeb1 002/108: First Commit., Artur Malabarba, 2015/03/25
- [elpa] master 759f365 018/108: Merge pull request #8 from tuhdo/master, Artur Malabarba, 2015/03/25
- [elpa] master eaa8cee 013/108: Whitespace, Artur Malabarba, 2015/03/25
- [elpa] master 2e993b8 008/108: Remove trailing whitespace, Artur Malabarba, 2015/03/25
- [elpa] master a1429e5 019/108: Fix variable I forgot to namespace, Artur Malabarba, 2015/03/25
- [elpa] master 7cd4e57 015/108: Fix Version, Artur Malabarba, 2015/03/25
- [elpa] master aebe081 020/108: Improve css-mode support, Artur Malabarba, 2015/03/25
- [elpa] master 1c74518 023/108: Fix last-command -> this-command bug, Artur Malabarba, 2015/03/25
- [elpa] master ebcafdb 022/108: Version Bump, Artur Malabarba, 2015/03/25
- [elpa] master a07019e 021/108: Move up the screencast, Artur Malabarba, 2015/03/25
- [elpa] master 8af72c5 024/108: Factor out the soft part into a macro.,
Artur Malabarba <=
- [elpa] master 7c3cb86 017/108: Add demo screenshot, Artur Malabarba, 2015/03/25
- [elpa] master 6a4296b 028/108: Add demo for non-Lisp mode, Artur Malabarba, 2015/03/25
- [elpa] master 215ddf7 030/108: Don't use do-softly for now., Artur Malabarba, 2015/03/25
- [elpa] master 81fadf1 029/108: Add modes to prefer defun., Artur Malabarba, 2015/03/25
- [elpa] master e4d3601 026/108: Implement a smarter engine for non-lisp modes., Artur Malabarba, 2015/03/25
- [elpa] master e774765 031/108: Merge branch 'region-indent', Artur Malabarba, 2015/03/25
- [elpa] master 7762250 032/108: Don't indent on empty line., Artur Malabarba, 2015/03/25
- [elpa] master 6e1d5a1 027/108: Merge pull request #12 from Bruce-Connor/region-indent, Artur Malabarba, 2015/03/25
- [elpa] master c15c56d 033/108: Skip empty lines when indenting blocks, Artur Malabarba, 2015/03/25
- [elpa] master 82c5d78 034/108: Merge pull request #17 from pmachata/master, Artur Malabarba, 2015/03/25