Skip to content

Commit

Permalink
Skip over comments in indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbauer committed Oct 30, 2018
1 parent 8b3a992 commit 84ee980
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions nix-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down

0 comments on commit 84ee980

Please sign in to comment.