-
Notifications
You must be signed in to change notification settings - Fork 67
/
elm-tags.el
62 lines (49 loc) · 2.01 KB
/
elm-tags.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;; elm-tags.el --- etags support for Elm.
;; Copyright (C) 2016 Bogdan Popa
;; Author: Bogdan Popa
;; URL: https://github.com/jcollard/elm-mode
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'elm-util)
(require 'f)
(defcustom elm-tags-on-save nil
"Controls whether or not TAGS files should be generated on save."
:group 'elm-tags
:type 'boolean)
(defcustom elm-tags-exclude-elm-stuff t
"Whether to exclude the `elm-stuff' directory from the TAGS file."
:group 'elm-tags
:type 'boolean)
(defconst elm-tags-regexps
(f-join
(f-dirname load-file-name)
"elm.tags"))
;;;###autoload
(defun elm-mode-generate-tags ()
"Generate a TAGS file for the current project."
(interactive)
(when (elm--has-dependency-file)
(let* ((default-directory (elm--find-dependency-file-path))
(find-command "find . -type f -name \"*.elm\" -print")
(exclude-command (if elm-tags-exclude-elm-stuff
(concat find-command " | egrep -v elm-stuff")
find-command))
(etags-command (concat
exclude-command
" | etags --language=none --regex=@"
(shell-quote-argument elm-tags-regexps)
" -")))
(call-process-shell-command (concat etags-command "&") nil 0))))
(provide 'elm-tags)
;;; elm-tags.el ends here