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

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

[elpa] master 820db3c 035/108: Don't indent inside comments, but allow a


From: Artur Malabarba
Subject: [elpa] master 820db3c 035/108: Don't indent inside comments, but allow as an option.
Date: Wed, 25 Mar 2015 18:38:58 +0000

branch: master
commit 820db3cc196344f87e472897a4e867479029684b
Author: Wilfred Hughes <address@hidden>
Commit: Wilfred Hughes <address@hidden>

    Don't indent inside comments, but allow as an option.
---
 aggressive-indent.el |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/aggressive-indent.el b/aggressive-indent.el
index af6d2ac..2f28fd3 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -123,12 +123,18 @@ commands will NOT be followed by a re-indent."
   :type '(repeat symbol)
   :package-version '(aggressive-indent . "0.1"))
 
+(defcustom comments-too nil
+  "If non-nil, aggressively indent in comments as well."
+  :type 'boolean)
+
 (defvar -internal-dont-indent-if
   '((memq this-command aggressive-indent-protected-commands)
     (region-active-p)
     buffer-read-only
     (null (buffer-modified-p))
-    (string-match "\\`[[:blank:]]*\n?\\'" (thing-at-point 'line)))
+    (string-match "\\`[[:blank:]]*\n?\\'" (thing-at-point 'line))
+    (and (aggressive-indent--in-comment-p)
+         (not aggressive-indent-comments-too)))
   "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.")
@@ -303,6 +309,11 @@ Like `aggressive-indent-indent-region-and-on', but wrapped 
in a
   (push l changed-list-left)
   (push r changed-list-right))
 
+(defun -in-comment-p ()
+  "Return non-nil if point is inside a comment.
+Assumes that the syntax table is sufficient to find comments."
+  (nth 4 (syntax-ppss)))
+
 
 ;;; Minor modes
 :autoload



reply via email to

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