emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master b957752 07/13: Don't indent if the user is starting to typ


From: Artur Malabarba
Subject: [elpa] master b957752 07/13: Don't indent if the user is starting to type a comment. Fix #51
Date: Wed, 05 Aug 2015 21:54:10 +0000

branch: master
commit b957752b12ac10ef0093756735b24754b131bfd0
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    Don't indent if the user is starting to type a comment. Fix #51
---
 aggressive-indent.el |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/aggressive-indent.el b/aggressive-indent.el
index b6181fb..dfa431a 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -173,7 +173,15 @@ commands will NOT be followed by a re-indent."
     buffer-read-only
     (null (buffer-modified-p))
     (and (boundp 'smerge-mode) smerge-mode)
-    (string-match "\\`[[:blank:]]*\n?\\'" (or (thing-at-point 'line) ""))
+    (let ((line (thing-at-point 'line)))
+      (when (stringp line)
+        (or (string-match "\\`[[:blank:]]*\n?\\'" line)
+            ;; If the user is starting to type a comment.
+            (and (stringp comment-start)
+                 (string-match (concat "\\`[[:blank:]]*"
+                                       (substring comment-start 0 1)
+                                       "[[:blank:]]*$")
+                               line)))))
     (let ((sp (syntax-ppss)))
       ;; Comments.
       (or (and (not aggressive-indent-comments-too) (elt sp 4))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]