Skip to content

Commit

Permalink
jacktasia#150 enable lexical bindings
Browse files Browse the repository at this point in the history
It's been observed that tests fail on GNU Emacs 24.3 if lexical-bindings are
enabled. There could be various reasons for this, but most obvious is
that Emacs 24.3 had `byte-compile-add-to-list` function, which was used
as byte-compiled version of `add-to-list`:
emacs-mirror/emacs@0b31660#diff-38337c5e732c14fa599af4a0f6e53f18L4272

ert-runner compiles files before the test run, so tests used the
compiled version.

This commit rewrites functions that depended on add-to-list.
  • Loading branch information
Artem Khramov committed Jul 25, 2017
1 parent e1a6647 commit 7acc874
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ If you want to stop a directory from registering as the project root (and have D

* `(setq dumb-jump-default-project "~/code")` to change default project if one is not found (defaults to `~`)
* `(setq dumb-jump-quiet t)` if Dumb Jump is too chatty.
* To support more languages and/or definition types use `add-to-list` on `dumb-jump-find-rules` (see source code).
* To support more languages and/or definition types customize `dumb-jump-find-rules` variable.
* `(add-hook 'dumb-jump-after-jump-hook 'some-function)` to execute code after you jump
* `(setq dumb-jump-selector 'ivy)` to use [ivy](https://github.com/abo-abo/swiper#ivy) instead of the default popup for multiple options.
* `(setq dumb-jump-selector 'helm)` to use [helm](https://github.com/emacs-helm/helm) instead of the default popup for multiple options.
Expand Down
59 changes: 29 additions & 30 deletions dumb-jump.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dumb-jump.el --- jump to definition for multiple languages without configuration.
;;; dumb-jump.el --- jump to definition for multiple languages without configuration. -*- lexical-binding: t; -*-

;; Copyright (C) 2015-2016 jack angers
;; Author: jack angers
Expand Down Expand Up @@ -1025,77 +1025,76 @@ not just a string."
(defun dumb-jump-test-rules (&optional run-not-tests)
"Test all the grep rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules."
(let ((failures '())
(fail-tmpl "grep %s FAILURE '%s' %s in response '%s' | CMD: '%s' | regex: '%s'")
(variant (if (eq (dumb-jump-grep-installed?) 'gnu) 'gnu-grep 'grep)))
(-each (--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "grep FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'")
(variant (if (eq (dumb-jump-grep-installed?) 'gnu) 'gnu-grep 'grep)))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "grep -En -e "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" variant))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl (if run-not-tests "not" "")
test (if run-not-tests "IS unexpectedly" "NOT") resp cmd (plist-get rule :regex)))))))))
failures))
(list (format fail-tmpl (if run-not-tests "not" "")
test (if run-not-tests "IS unexpectedly" "NOT") resp cmd (plist-get rule :regex))))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-ag-rules (&optional run-not-tests)
"Test all the ag rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "ag FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "ag" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "ag FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "ag --nocolor --nogroup "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'ag))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "ag" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-rg-rules (&optional run-not-tests)
"Test all the rg rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "rg" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "rg --color never --no-heading "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'rg))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "rg" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-git-grep-rules (&optional run-not-tests)
"Test all the git grep rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "git grep FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "git-grep" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "git grep --color=never -h --untracked -E "
(shell-quote-argument
(dumb-jump-populate-regex (plist-get rule :regex) "test" 'git-grep))))
(let* ((cmd (concat "git grep --color=never -h --untracked -E "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'git-grep))))
(resp (dumb-jump-run-git-grep-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-message (str &rest args)
"Log message STR with ARGS to the *Messages* buffer if not using dumb-jump-quiet."
Expand Down

0 comments on commit 7acc874

Please sign in to comment.