[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f70f0ff 059/108: Don't indent in strings (fixes #27)
From: |
Artur Malabarba |
Subject: |
[elpa] master f70f0ff 059/108: Don't indent in strings (fixes #27) |
Date: |
Wed, 25 Mar 2015 18:39:08 +0000 |
branch: master
commit f70f0ff3366610ad350463ecc97e783d90bf43fb
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
Don't indent in strings (fixes #27)
Also improve #25 by not enabling delete-indentation for backspace at
locations where the user doesn't want aggressive indentation.
---
aggressive-indent.el | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/aggressive-indent.el b/aggressive-indent.el
index 3db3819..0b9f26e 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -171,7 +171,8 @@ commands will NOT be followed by a re-indent."
(null (buffer-modified-p))
(string-match "\\`[[:blank:]]*\n?\\'" (thing-at-point 'line))
(and (not aggressive-indent-comments-too)
- (aggressive-indent--in-comment-p)))
+ (aggressive-indent--in-comment-p))
+ (aggressive-indent--in-string-p))
"List of forms which prevent indentation when they evaluate to non-nil.
This is for internal use only. For user customization, use
`aggressive-indent-dont-indent-if' instead.")
@@ -334,6 +335,12 @@ Like `aggressive-indent-indent-region-and-on', but wrapped
in a
Assumes that the syntax table is sufficient to find comments."
(nth 4 (syntax-ppss)))
+(defun -in-string-p ()
+ "Return non-nil if point is inside a string.
+Assumes that the syntax table is sufficient for recognizing
+strings."
+ (nth 3 (syntax-ppss)))
+
;;; Minor modes
:autoload
@@ -341,8 +348,14 @@ Assumes that the syntax table is sufficient to find
comments."
'(("" . aggressive-indent-indent-defun)
([backspace] menu-item "maybe-delete-indentation" ignore
:filter (lambda (&optional _)
- (when (looking-back "^[[:blank:]]+")
- #'delete-indentation))))
+ (when (and (looking-back "^[[:blank:]]+")
+ ;; Wherever we don't want to indent, we probably also
+ ;; want the default backspace behavior.
+ (not (run-hook-wrapped
+ 'aggressive-indent--internal-dont-indent-if
+ #'eval))
+ (not (aggressive-indent--run-user-hooks)))
+ #'delete-indentation))))
(if mode
(if (and global-aggressive-indent-mode
(or (cl-member-if #'derived-mode-p excluded-modes)
- [elpa] master 63121eb 049/108: Restore point even when errors., (continued)
- [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, 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 <=
- [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
- [elpa] master ae996bb 064/108: Merge pull request #30 from vmfhrmfoaj/master, Artur Malabarba, 2015/03/25
- [elpa] master 6e345d2 063/108: Merge pull request #29 from tsdh/master, Artur Malabarba, 2015/03/25
- [elpa] master 095f778 069/108: Add Custom-mode to excluded modes, Artur Malabarba, 2015/03/25
- [elpa] master b3881a6 065/108: Readme, Artur Malabarba, 2015/03/25
- [elpa] master 9e81033 067/108: Indentation, Artur Malabarba, 2015/03/25
- [elpa] master 46f2010 071/108: Don't indent smerge-mode, Artur Malabarba, 2015/03/25