[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/urgrep aba02cc3f9 017/115: Add support for ripgrep and
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/urgrep aba02cc3f9 017/115: Add support for ripgrep and ack |
|
Date: |
Wed, 10 May 2023 03:00:38 -0400 (EDT) |
branch: externals/urgrep
commit aba02cc3f96fc77ef1c093eca4222aaf42f4e47f
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Add support for ripgrep and ack
---
README.md | 2 +-
urgrep-tests.el | 24 ++++++++++++++++++++++++
urgrep.el | 31 +++++++++++++++++++++++++++----
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index abb2c401f0..18b3e8c28e 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Urgrep is an experimental Emacs package to provide an alternative to `M-x
rgrep`
(and similar packages) which will eventually support for *any* grep-like tool.
-Currently, `ag`, `git grep`, and `grep`/`find` are supported.
+Currently, `ripgrep`, `ag`, `ack`, `git grep`, and `grep`/`find` are supported.
## Using Urgrep
diff --git a/urgrep-tests.el b/urgrep-tests.el
index ec4d2c0e82..fd79b04b7b 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -26,6 +26,18 @@
(require 'ert)
+(ert-deftest urgrep-tests-command-ripgrep ()
+ (let ((tool (assoc "ripgrep" urgrep-tools))
+ (common-args "rg --color always --colors path\\:fg\\:magenta --colors
match\\:fg\\:red --colors match\\:style\\:bold "))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "-F --heading -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :group nil)
+ (concat common-args "-F --no-heading -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :regexp t)
+ (concat common-args "--heading -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :context 3)
+ (concat common-args "-C3 -F --heading -- foo")))))
+
(ert-deftest urgrep-tests-command-ag ()
(let ((tool (assoc "ag" urgrep-tools))
(common-args "ag --color-path 35 --color-match 1\\;31 "))
@@ -38,6 +50,18 @@
(should (equal (urgrep-command "foo" :tool tool :context 3)
(concat common-args "-C3 -Q --group -- foo")))))
+(ert-deftest urgrep-tests-command-ack ()
+ (let ((tool (assoc "ack" urgrep-tools))
+ (common-args "ack --color-filename magenta --color-match bold\\ red "))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "-Q --group -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :group nil)
+ (concat common-args "-Q --nogroup -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :regexp t)
+ (concat common-args "--group -- foo")))
+ (should (equal (urgrep-command "foo" :tool tool :context 3)
+ (concat common-args "-C3 -Q --group -- foo")))))
+
(ert-deftest urgrep-tests-command-git-grep ()
(let ((tool (assoc "git-grep" urgrep-tools))
(common-args "git --no-pager -c color.grep.filename\\=magenta -c
color.grep.match\\=bold\\ red grep --color -n --recurse-submodules "))
diff --git a/urgrep.el b/urgrep.el
index 10451daa0d..98f3d03516 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -23,8 +23,8 @@
;;; Commentary:
-;; A universal frontend to various grep-like tools. Currently, ag, git-grep,
and
-;; grep are supported.
+;; A universal frontend to various grep-like tools. Currently, ripgrep, ag,
ack,
+;; git-grep, and grep are supported.
;;; Code:
@@ -79,7 +79,16 @@
(rgrep-default-command query "*" nil))
(defvar urgrep-tools
- `(("ag"
+ `(("ripgrep"
+ (executable-name "rg")
+ (pre-arguments ("--color" "always" "--colors" "path:fg:magenta"
+ "--colors" "match:fg:red" "--colors" "match:style:bold"))
+ (post-arguments ("--"))
+ (group-arguments ((t ("--heading"))
+ (nil ("--no-heading"))))
+ (regexp-arguments ((nil ("-F"))))
+ (context-arguments "-C%d"))
+ ("ag"
(executable-name "ag")
(pre-arguments ("--color-path" "35" "--color-match" "1;31"))
(post-arguments ("--"))
@@ -87,6 +96,14 @@
(nil ("--nogroup"))))
(regexp-arguments ((nil ("-Q"))))
(context-arguments "-C%d"))
+ ("ack"
+ (executable-name "ack")
+ (pre-arguments ("--color-filename" "magenta" "--color-match" "bold red"))
+ (post-arguments ("--"))
+ (group-arguments ((t ("--group"))
+ (nil ("--nogroup"))))
+ (regexp-arguments ((nil ("-Q"))))
+ (context-arguments "-C%d"))
("git-grep"
(executable-name "git")
(vc-backend "Git")
@@ -341,7 +358,13 @@ This function is called from `compilation-filter-hook'."
(when (< (point) end)
(setq end (copy-marker end))
;; Highlight matches and delete ANSI escapes.
- (while (re-search-forward "\033\\[0?1;31m\\(.*?\\)\033\\[0?m" end 1)
+ (while (re-search-forward
+ (concat "\\(?:"
+ "\033\\[0?1;31m" ; Find the escapes together...
+ "\\|"
+ "\033\\[1m\033\\[31m" ; ... or apart.
+ "\\)\\(.*?\\)\033\\[0?m")
+ end 1)
(replace-match
(propertize (match-string 1) 'face nil 'font-lock-face
'urgrep-match)
t t)
- [elpa] branch externals/urgrep created (now 7823d384e6), ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep ccd6fe0d4c 002/115: Add a basic keymap, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 8832dc103f 003/115: Add support for find/grep by delegating to Emacs' built-in `rgrep', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 133d308eec 004/115: Don't add `-face' to face names, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 4ec9d9febd 010/115: Fix behavior of temporarily overriding `urgrep-search-regexp', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 7780887977 005/115: Add initial support for git grep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep d965e6b848 007/115: Add the ability to toggle regexp mode when entering a search, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 764742fd14 006/115: Recurse submodules with git grep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6d9217c344 013/115: Rename urgrep-test.el to urgrep-tests.el, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep aba02cc3f9 017/115: Add support for ripgrep and ack,
ELPA Syncer <=
- [elpa] externals/urgrep 53d72fe09c 023/115: Don't cache tool results for hosts which can use VC-specific tools, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 266965a0a2 024/115: Add support for intelligent editing of previous search commands, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 350d6d1889 027/115: Add support for regexp-syntax and context with the grep backend, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 887114113c 001/115: Initial revision, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep b578b0f857 009/115: Add a README and more-detailed docstrings, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 026c54d11e 012/115: Add support for setting context, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep ca67ad1f4d 030/115: Use isearch-like bindings in the urgrep minibuffer, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 8bb469a526 036/115: Add some details about our buffer-local variables, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 9ff22a4481 041/115: Minor fixes to defcustoms, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep c879c02558 040/115: Add some docs and clean up spacing, ELPA Syncer, 2023/05/10