branch: externals/urgrep commit 73581bc3dbda05d4a32167a6a942154e201f1b8b Author: Jim Porter <jporterb...@gmail.com> Commit: Jim Porter <jporterb...@gmail.com>
Fix byte-compilation issues --- .github/workflows/build.yml | 5 +++-- Makefile | 23 +++++++++++++++++++++++ urgrep-tests.el | 3 +++ urgrep-wgrep.el | 16 +++++++++++----- urgrep.el | 10 ++++++++-- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0a582890b..340f88834b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: emacs-version: ['27.1', '27.2', '28.1', '28.2', 'snapshot'] + action: ['check', 'lint'] fail-fast: false @@ -22,6 +23,6 @@ jobs: - name: Install dependencies run: | make install-deps - - name: Run tests + - name: Run ${{ matrix.action }} run: | - make check + make ${{ matrix.action }} diff --git a/Makefile b/Makefile index 5bde538680..6e053c3c52 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,29 @@ define INSTALL_SCRIPT endef export INSTALL_SCRIPT +EMACS_BATCH := $(EMACS) -Q --batch \ + --eval '(setq package-user-dir (getenv "DEPS_DIR"))' \ + --eval '(package-activate-all)' + +OBJS := $(patsubst %.el,%.elc,$(wildcard *.el)) + +.PHONY: all +all: $(OBJS) + .PHONY: install-deps install-deps: @$(EMACS) -Q --batch urgrep.el --eval "$$INSTALL_SCRIPT" +%.elc: %.el + @echo ELC $@ + @$(EMACS_BATCH) \ + $(if $(STRICT),--eval '(setq byte-compile-error-on-warn t)') \ + -L . --funcall batch-byte-compile $< + +.PHONY: lint +lint: + @$(MAKE) --always-make STRICT=1 all + .PHONY: check check: $(EMACS) -Q --batch \ @@ -26,3 +45,7 @@ check: --eval '(package-activate-all)' \ -L . -l urgrep -l urgrep-tests \ --eval '(ert-run-tests-batch-and-exit t)' + +.PHONY: clean +clean: + rm -f *.elc diff --git a/urgrep-tests.el b/urgrep-tests.el index c4c776c39b..975e3c6a98 100644 --- a/urgrep-tests.el +++ b/urgrep-tests.el @@ -30,6 +30,7 @@ (require 'compat) (require 'ert) (require 'tramp) +(require 'urgrep) (let ((orig-home (getenv "HOME"))) (require 'ert-x) @@ -42,6 +43,7 @@ (let ((inhibit-message t)) (ignore-errors (and + (boundp 'ert-remote-temporary-file-directory) (file-remote-p ert-remote-temporary-file-directory) (file-directory-p ert-remote-temporary-file-directory) (file-writable-p ert-remote-temporary-file-directory))))) @@ -547,6 +549,7 @@ joined to compare against COMMAND." (ert-deftest urgrep-tests/get-tool/remote-host () (skip-unless (urgrep-tests/remote-accessible-p)) + (defvar ert-remote-temporary-file-directory) (connection-local-set-profile-variables 'urgrep-test-ripgrep '((urgrep-preferred-tools . (ripgrep)))) diff --git a/urgrep-wgrep.el b/urgrep-wgrep.el index 2241c54223..4ee6f21ad7 100644 --- a/urgrep-wgrep.el +++ b/urgrep-wgrep.el @@ -29,7 +29,8 @@ ;;; Code: -(require 'wgrep) +(require 'text-property-search) +;;(require 'wgrep) (defvar urgrep-wgrep--grouped-result-regexp (concat "^\\(?:" @@ -59,6 +60,8 @@ displaying context. Group 1 is unused.") Group 1 is the filename, group 2 is the line number, and group 3 is the \"--\" separator used when displaying context.") +(declare-function wgrep-construct-filename-property "wgrep" (filename)) + (defun urgrep-wgrep--propertize-lines (begin end &optional file-name) "Apply wgrep properties to result lines between BEGIN and END. If END is nil, continue to the end of the (narrowed) buffer. @@ -78,10 +81,9 @@ grouped results; if nil, assume the results are ungrouped." ;; If results are ungrouped, mark the filename with ;; `wgrep-construct-filename-property'. (unless file-name - (let ((this-file (match-string-no-properties 1))) - (add-text-properties - (match-beginning 1) (match-end 1) - (list (wgrep-construct-filename-property file-name) file-name)))) + (add-text-properties + (match-beginning 1) (match-end 1) + (list (wgrep-construct-filename-property file-name) file-name))) ;; Mark the line with the filename and line number. (add-text-properties (match-beginning 0) (match-end 0) @@ -138,6 +140,10 @@ This lets wgrep know what to ignore." ;;;###autoload (defun urgrep-wgrep-setup () "Set up a urgrep buffer to use wgrep." + (require 'wgrep) + (declare-function wgrep-setup-internal "wgrep" nil) + (defvar wgrep-header/footer-parser) + (defvar wgrep-results-parser) (setq-local wgrep-header/footer-parser #'urgrep-wgrep-header/footer-parser wgrep-results-parser #'urgrep-wgrep-results-parser) (wgrep-setup-internal)) diff --git a/urgrep.el b/urgrep.el index 930396441f..fa6a2f3cd3 100644 --- a/urgrep.el +++ b/urgrep.el @@ -34,11 +34,11 @@ (require 'cl-lib) (require 'compat) (require 'compile) -(require 'esh-opt) (require 'generator) (require 'grep) (require 'project) (require 'text-property-search) +(require 'xref) ; For `xref--regexp-to-extended'. (defgroup urgrep nil "Run a grep-like command and display the results." @@ -122,7 +122,6 @@ The currently-used tool can be inspected from the hook via ;; function for converting between basic and extended regexps. It ;; might be wise to use our own implementation, but this should work ;; for now. - (require 'xref) (xref--regexp-to-extended expr)) (t expr))) @@ -165,6 +164,7 @@ and escapes null characters." "Quote ARGUMENT if needed for passing to an inferior shell. This works as `shell-quote-argument', but avoids quoting unnecessarily for MS shells." + (declare-function w32-shell-dos-semantics "w32-fns" nil) (if (and (or (eq system-type 'ms-dos) (and (eq system-type 'windows-nt) (w32-shell-dos-semantics))) (not (string-match "[^-0-9a-zA-Z_./=]" argument))) @@ -1143,11 +1143,17 @@ to edit the command before running it." directory (cadr (cl-member :tool query))))) (urgrep--start command command (urgrep-get-tool tool) directory)) +(cl-eval-when (compile) + (require 'esh-cmd) + (require 'esh-opt) + (require 'em-unix)) + ;;;###autoload (defun eshell/urgrep (&rest args) "Recursively search for a pattern, passing ARGS. This is meant to be used as a command in Eshell." (require 'esh-cmd) + (require 'esh-opt) (require 'em-unix) (eshell-eval-using-options "urgrep" args