branch: elpa/nix-mode
commit 84ee98019fbb48854ebd57cc74848b7e7327a78c
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Skip over comments in indentation
---
nix-mode.el | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 9b885a6736..821f53b5d3 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -53,6 +53,12 @@ Valid functions for this are:
:group 'nix-mode
:type '(repeat string))
+(defcustom nix-mode-comments
+ '("#" "/*" "*/")
+ "Regular expressions to consider comment codes."
+ :group 'nix-mode
+ :type '(repeat string))
+
(defgroup nix-faces nil
"Nix faces."
:group 'nix-mode
@@ -390,11 +396,15 @@ STRING-TYPE type of string based off of Emacs syntax
table types"
"Return regexp for matching string quotes."
(nix-mode-make-regexp nix-mode-quotes))
+(defun nix-mode-comments-regexp ()
+ "Return regexp for matching comments."
+ (nix-mode-make-regexp nix-mode-comments))
+
(defun nix-mode-combined-regexp ()
"Return combined regexp for matching items of interest."
- (nix-mode-make-regexp (append nix-mode-caps
- nix-mode-ends
- nix-mode-quotes)))
+ (nix-mode-make-regexp (append nix-mode-caps
+ nix-mode-ends
+ nix-mode-quotes)))
(defun nix-mode-search-backward ()
"Search backward for items of interest regarding indentation."
@@ -415,6 +425,9 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
((looking-at (nix-mode-quotes-regexp))
;; skip over strings entirely
(re-search-backward (nix-mode-quotes-regexp) nil t))
+ ((looking-at (nix-mode-comments-regexp))
+ ;; skip over comments entirely
+ (re-search-backward (nix-mode-comments-regexp) nil t))
((looking-at (nix-mode-ends-regexp))
;; count the matched end
;; this means we expect to find at least one more cap