Skip to content

Commit

Permalink
Add elisp defmacro rule (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
chasecaleb authored Jun 20, 2022
1 parent 1dd5830 commit ba41273
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.cask/
.cask/
\#.*test#
.*test~
6 changes: 6 additions & 0 deletions dumb-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ or most optimal searcher."
:not ("(defun test-asdf (blah)" "(defun test-blah\n" "(cl-defun test-asdf (blah)"
"(cl-defun test-blah\n" "(defun tester (blah)" "(defun test? (blah)" "(defun test- (blah)"))

(:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
:regex "\\\(defmacro\\s+JJJ\\j"
:tests ("(defmacro test (blah)" "(defmacro test\n")
:not ("(defmacro test-asdf (blah)" "(defmacro test-blah\n" "(defmacro tester (blah)"
"(defmacro test? (blah)" "(defmacro test- (blah)"))

(:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
:regex "\\\(defvar\\b\\s*JJJ\\j"
:tests ("(defvar test " "(defvar test\n")
Expand Down
46 changes: 28 additions & 18 deletions test/dumb-jump-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
(regexes (dumb-jump-get-contextual-regexes "elisp" nil 'grep))
(expected-regexes (--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
Expand All @@ -93,6 +94,7 @@
(regexes (dumb-jump-get-contextual-regexes "elisp" nil 'gnu-grep))
(expected-regexes (--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)[[:space:]]+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro[[:space:]]+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defvar\\b[[:space:]]*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defcustom\\b[[:space:]]*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(setq\\b[[:space:]]*tester($|[^a-zA-Z0-9\\?\\*-])"
Expand All @@ -102,19 +104,19 @@

(ert-deftest dumb-jump-generate-ag-command-no-ctx-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag))
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "ag --nocolor --nogroup --elisp " (shell-quote-argument expected-regexes) " .")))
(should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "." regexes "elisp" nil)))))

(ert-deftest dumb-jump-generate-ag-command-exclude-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag))
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "ag --nocolor --nogroup --elisp --ignore-dir this/is/excluded " (shell-quote-argument expected-regexes) " /path/to/proj-root")))
(should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" '("/path/to/proj-root/this/is/excluded"))))))

(ert-deftest dumb-jump-generate-git-grep-plus-ag-command-no-ctx-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag))
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "ag --nocolor --nogroup -G '(/path/to/proj-root/blah.el)' " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) ;; NOTE no "--elisp" and the `-G` arg is new
(with-mock
(mock (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg * *) => "'(/path/to/proj-root/blah.el)'")
Expand All @@ -123,7 +125,7 @@

(ert-deftest dumb-jump-generate-git-grep-plus-ag-command-exclude-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag))
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "ag --nocolor --nogroup -G '(/path/to/proj-root/blah.el)' --ignore-dir this/is/excluded " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) ;; NOTE no "--elisp" and the `-G` arg is new
(with-mock
(mock (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg * *) => "'(/path/to/proj-root/blah.el)'")
Expand All @@ -132,26 +134,26 @@

(ert-deftest dumb-jump-generate-rg-command-no-ctx-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "rg --color never --no-heading --line-number -U --pcre2 --type elisp " (shell-quote-argument expected-regexes) " .")))
(should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "." regexes "elisp" nil)))))

(ert-deftest dumb-jump-generate-rg-command-remote-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected (concat "rg --color never --no-heading --line-number -U --pcre2 --type elisp -g \\!this/is/excluded " (shell-quote-argument expected-regexes) " /path/to/proj-root")))
(should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" '("/path/to/proj-root/this/is/excluded"))))))

(ert-deftest dumb-jump-generate-git-grep-command-no-ctx-test ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(excludes '("one" "two" "three"))
(expected (concat "git grep --color=never --line-number --untracked -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three")))
(should (string= expected (dumb-jump-generate-git-grep-command "tester" "blah.el" "." regexes "elisp" excludes)))))

(ert-deftest dumb-jump-generate-git-grep-command-no-ctx-extra-args ()
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(excludes '("one" "two" "three"))
(dumb-jump-git-grep-search-args "--recurse-submodules")
(expected (concat "git grep --color=never --line-number --untracked --recurse-submodules -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three")))
Expand All @@ -160,15 +162,15 @@
(ert-deftest dumb-jump-generate-ag-command-no-ctx-extra-args ()
;; ag args
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag))
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester(?![a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester(?![a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester(?![a-zA-Z0-9\\?\\*-])\\s*\\)?")
(dumb-jump-ag-search-args "--follow")
(expected (concat "ag --nocolor --nogroup --follow --elisp " (shell-quote-argument expected-regexes) " .")))
(should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "." regexes "elisp" nil)))))

(ert-deftest dumb-jump-generate-rg-command-no-ctx-extra-args ()
;; rg-args
(let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(dumb-jump-rg-search-args "--no-pcre2 --follow")
(expected (concat "rg --color never --no-heading --line-number -U --no-pcre2 --follow --type elisp " (shell-quote-argument expected-regexes) " .")))
(should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "." regexes "elisp" nil)))))
Expand All @@ -177,7 +179,7 @@
(let* ((dumb-jump-git-grep-search-args "")
(dumb-jump-git-grep-search-untracked nil)
(regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])|\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])|\\(tester\\s+|\\((defun|cl-defun)\\s*.+\\(?\\s*tester($|[^a-zA-Z0-9\\?\\*-])\\s*\\)?")
(excludes '("one" "two" "three"))
(expected (concat "git grep --color=never --line-number -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three")))
(should (string= expected (dumb-jump-generate-git-grep-command "tester" "blah.el" "." regexes "elisp" excludes)))))
Expand All @@ -186,9 +188,12 @@
(let* ((system-type 'darwin)
(dumb-jump-functions-only t)
(regexes (dumb-jump-get-contextual-regexes "elisp" nil 'grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])")
(expected (concat "LANG=C grep -REn -e " (shell-quote-argument expected-regexes) " ."))
(zexpected (concat "LANG=C zgrep -REn -e " (shell-quote-argument expected-regexes) " .")))
(expected-regexes (s-join ""
(--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])"))))
(expected (concat "LANG=C grep -REn" expected-regexes " ."))
(zexpected (concat "LANG=C zgrep -REn" expected-regexes " .")))
(should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil)))
(should (string= zexpected (dumb-jump-generate-grep-command "tester" "blah.el.gz" "." regexes "" nil)))))

Expand All @@ -197,8 +202,10 @@
(ctx-type (dumb-jump-get-ctx-type-by-language "elisp" '(:left "(" :right nil)))
(dumb-jump-ignore-context nil) ;; overriding the default
(regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type 'grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])")
(expected (concat "LANG=C grep -REn -e " (shell-quote-argument expected-regexes) " .")))
(expected-regexes (--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])")))
(expected (concat "LANG=C grep -REn" (s-join "" expected-regexes) " .")))
;; the point context being passed should match a "function" type so only the one command
(should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil)))))

Expand All @@ -208,8 +215,10 @@
(ctx-type (dumb-jump-get-ctx-type-by-language "elisp" '(:left "(" :right nil)))
(dumb-jump-ignore-context nil) ;; overriding the default
(regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type 'grep))
(expected-regexes "\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])")
(expected (concat "grep -REn -e " (shell-quote-argument expected-regexes) " .")))
(expected-regexes (--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])")))
(expected (concat "grep -REn" (s-join "" expected-regexes) " .")))
(should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil))))))

(ert-deftest dumb-jump-generate-grep-command-with-ctx-but-ignored-test ()
Expand All @@ -219,6 +228,7 @@
(regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type nil))
(expected-regexes (--map (concat " -e " (shell-quote-argument it))
'("\\((defun|cl-defun)\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defmacro\\s+tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defvar\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(defcustom\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
"\\(setq\\b\\s*tester($|[^a-zA-Z0-9\\?\\*-])"
Expand Down

0 comments on commit ba41273

Please sign in to comment.