[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/urgrep 3643c933c4 055/115: Add support for ugrep
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/urgrep 3643c933c4 055/115: Add support for ugrep |
|
Date: |
Wed, 10 May 2023 03:00:43 -0400 (EDT) |
branch: externals/urgrep
commit 3643c933c4264e3185942965f76c5a78abca4068
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Add support for ugrep
---
README.md | 11 ++++++++-
urgrep-tests.el | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
urgrep.el | 21 +++++++++++++++-
3 files changed, 103 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 07827482fd..701c80a4be 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
**Urgrep** is an Emacs package to provide a universal frontend for *any*
grep-like tool, as an alternative to the built-in `M-x rgrep` (and other
similar
-packages). Currently, `ripgrep`, `ag`, `ack`, `git grep`, and `grep`/`find` are
+packages). Currently, [`ugrep`][ugrep], [`ripgrep`][ripgrep], [`ag`][ag],
+[`ack`][ack], [`git grep`][git-grep], and [`grep`][grep]/[`find`][find] are
supported.
## Why Urgrep?
@@ -86,3 +87,11 @@ arguments. For more information, consult the docstring for
`urgrep-command`.
Feedback is welcome, but it's a bit early for code contributions. Thanks for
the
thought, though! (Hopefully this will change after not too long.)
+
+[ugrep]: https://github.com/Genivia/ugrep
+[ripgrep]: https://github.com/BurntSushi/ripgrep
+[ag]: https://github.com/ggreer/the_silver_searcher
+[ack]: https://beyondgrep.com/
+[git-grep]: https://git-scm.com/docs/git-grep
+[grep]: https://www.gnu.org/software/grep/
+[find]: https://www.gnu.org/software/findutils/
diff --git a/urgrep-tests.el b/urgrep-tests.el
index 5d04e4e90a..75f2d8c535 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -48,6 +48,77 @@
(should (string= command (mapconcat #'urgrep--maybe-shell-quote-argument
expected-arguments " "))))
+(ert-deftest urgrep-tests-command-ugrep ()
+ (let ((tool (assq 'ugrep urgrep-tools))
+ (common-args '("ugrep" "--color=always"
+ "--colors=mt=01;31:fn=35:ln=:bn=:se=:sl=:cx=:ne"
+ "-n" "--ignore-files")))
+ ;; String/case
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool)
+ (append common-args '("--heading" "--break" "-i" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "Foo" :tool tool)
+ (append common-args '("--heading" "--break" "-F" "-e" "Foo")))
+ (let ((case-fold-search nil))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool)
+ (append common-args '("--heading" "--break" "-F" "-e" "foo"))))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :case-fold t)
+ (append common-args '("--heading" "--break" "-i" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :case-fold nil)
+ (append common-args '("--heading" "--break" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :case-fold 'smart)
+ (append common-args '("--heading" "--break" "-i" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "Foo" :tool tool :case-fold 'smart)
+ (append common-args '("--heading" "--break" "-F" "-e" "Foo")))
+ ;; Group
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :group nil)
+ (append common-args '("-i" "-F" "-e" "foo")))
+ ;; Regexp
+ (urgrep-test--check-command
+ (urgrep-command "(foo)" :tool tool :regexp t)
+ (append common-args '("--heading" "--break" "-i" "-G" "-e" "(foo)")))
+ (urgrep-test--check-command
+ (urgrep-command "(foo)" :tool tool :regexp 'bre)
+ (append common-args '("--heading" "--break" "-i" "-G" "-e" "(foo)")))
+ (urgrep-test--check-command
+ (urgrep-command "(foo)" :tool tool :regexp 'ere)
+ (append common-args '("--heading" "--break" "-i" "-E" "-e" "(foo)")))
+ (urgrep-test--check-command
+ (urgrep-command "(foo)" :tool tool :regexp 'pcre)
+ (append common-args '("--heading" "--break" "-i" "-P" "-e" "(foo)")))
+ ;; Context
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :context 3)
+ (append common-args '("--heading" "--break" "-C3" "-i" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :context '(3 . 3))
+ (append common-args '("--heading" "--break" "-C3" "-i" "-F" "-e" "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :context '(2 . 4))
+ (append common-args '("--heading" "--break" "-B2" "-A4" "-i" "-F" "-e"
+ "foo")))
+ ;; File wildcard
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :files "*.el")
+ (append common-args '("--include=*.el" "--heading" "--break" "-i" "-F"
"-e"
+ "foo")))
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+ (append common-args '("--include=*.c" "--include=*.h" "--heading"
"--break"
+ "-i" "-F" "-e" "foo")))
+ ;; Color
+ (urgrep-test--check-command
+ (urgrep-command "foo" :tool tool :color nil)
+ (append '("ugrep" "--color=never" "-n" "--ignore-files" "--heading"
+ "--break" "-i" "-F" "-e" "foo")))))
+
(ert-deftest urgrep-tests-command-ripgrep ()
(let ((tool (assq 'ripgrep urgrep-tools))
(common-args '("rg" "--color" "always" "--colors" "path:fg:magenta"
@@ -383,8 +454,8 @@
(cl-letf (((symbol-function #'executable-find) #'always))
(let* ((urgrep--host-defaults)
(tool (urgrep-get-tool)))
- (should (equal (car tool) 'ripgrep))
- (should (equal (urgrep--get-prop 'executable-name tool) "rg"))
+ (should (equal (car tool) 'ugrep))
+ (should (equal (urgrep--get-prop 'executable-name tool) "ugrep"))
(should (equal urgrep--host-defaults `((localhost . ,tool)))))))
(ert-deftest urgrep-tests-get-tool-default-cached ()
diff --git a/urgrep.el b/urgrep.el
index 75974f1a4e..8554cde585 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -201,7 +201,26 @@ See also `grep-process-setup'."
(setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne"))
(defvar urgrep-tools
- `((ripgrep
+ `((ugrep
+ (executable-name . "ugrep")
+ (regexp-syntax bre ere pcre)
+ (arguments executable color "-n" "--ignore-files" file-wildcards group
+ context case-fold regexp "-e" query)
+ (color-arguments
+ ('nil '("--color=never"))
+ (_ '("--color=always"
+ "--colors=mt=01;31:fn=35:ln=:bn=:se=:sl=:cx=:ne")))
+ (group-arguments ((pred identity) '("--heading" "--break")))
+ (context-arguments . ,urgrep--context-arguments)
+ (regexp-arguments ('bre '("-G"))
+ ('ere '("-E"))
+ ('pcre '("-P"))
+ (_ '("-F")))
+ (case-fold-arguments ((pred identity) '("-i")))
+ (file-wildcards-arguments
+ ((and x (pred identity))
+ (mapcar (lambda (i) (concat "--include=" i)) x))))
+ (ripgrep
(executable-name . "rg")
(regexp-syntax pcre)
(arguments executable color file-wildcards group context case-fold regexp
- [elpa] externals/urgrep 229ae0bfb5 110/115: Use a version identifier compatible with 'version-to-string', (continued)
- [elpa] externals/urgrep 229ae0bfb5 110/115: Use a version identifier compatible with 'version-to-string', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6aefc895bc 113/115: Set system-type to gnu/linux when making the Urgrep command for Eshell, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 83e62357da 018/115: Provide a friendly default value when searching, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 98e20f0630 021/115: Use pcase macros for filling in optional arguments, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep bf24dac2ac 025/115: Allow for separate before/after contexts, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep f2ba643f35 028/115: Typo, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep c26ff9b22b 029/115: Add note about grep issues on MS Windows, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6f50ef99d3 032/115: Remove urgrep--to-command, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3599ad1a56 033/115: Update comment, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep ba2b01b91b 042/115: Remove no-longer-needed `post-arguments', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3643c933c4 055/115: Add support for ugrep,
ELPA Syncer <=
- [elpa] externals/urgrep 0de93bfdb9 068/115: Fix use of wgrep on long urgrep results, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e2e8898ab2 074/115: Update copyright, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0c966b2001 075/115: Ensure `default-directory' stays in sync, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep c15be33112 076/115: Wrap shell argument quoting with `with-connection-local-variables`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e63c6c5173 089/115: Add link to wgrep package and clarify the README, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 61478da305 077/115: Improve reliability of running urgrep over Tramp, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 77fcfc1916 090/115: Use `push` instead of `add-to-list`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 559b2c07cd 091/115: Add a unit test for getting the preferred tool on multiple hosts, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep fe13a3cbb5 081/115: Fix project-root call on Emacs 27, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep f2c87e7520 080/115: Improve robustness of tests for grep command generation, ELPA Syncer, 2023/05/10