[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/urgrep 3fb6b95f21 026/115: Add support for smart case-f
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/urgrep 3fb6b95f21 026/115: Add support for smart case-folding |
|
Date: |
Wed, 10 May 2023 03:00:39 -0400 (EDT) |
branch: externals/urgrep
commit 3fb6b95f216e8a0302184aebfb3bb8faf994653d
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Add support for smart case-folding
---
urgrep-tests.el | 121 +++++++++++++++++++++++++++++++++++++++-----------------
urgrep.el | 22 +++++++----
2 files changed, 100 insertions(+), 43 deletions(-)
diff --git a/urgrep-tests.el b/urgrep-tests.el
index ca2c8031ac..d9c8ed4fc4 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -31,95 +31,144 @@
(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 "))
+ ;; String/case
(should (equal (urgrep-command "foo" :tool tool)
- (concat common-args "-F --heading -- foo")))
+ (concat common-args "--heading -i -F -- foo")))
+ (should (equal (urgrep-command "Foo" :tool tool)
+ (concat common-args "--heading -F -- Foo")))
+ (let ((case-fold-search nil))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "--heading -F -- foo"))))
+ ;; Group
(should (equal (urgrep-command "foo" :tool tool :group nil)
- (concat common-args "-F --no-heading -- foo")))
+ (concat common-args "--no-heading -i -F -- foo")))
+ ;; Regexp
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'bre)
- (concat common-args "--heading -- \\\\\\(foo\\\\\\)")))
+ (concat common-args "--heading -i -- \\\\\\(foo\\\\\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'ere)
- (concat common-args "--heading -- \\(foo\\)")))
+ (concat common-args "--heading -i -- \\(foo\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'pcre)
- (concat common-args "--heading -- \\(foo\\)")))
+ (concat common-args "--heading -i -- \\(foo\\)")))
+ ;; Context
(should (equal (urgrep-command "foo" :tool tool :context 3)
- (concat common-args "-C3 -F --heading -- foo")))
+ (concat common-args "--heading -C3 -i -F -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(3 . 3))
- (concat common-args "-C3 -F --heading -- foo")))
+ (concat common-args "--heading -C3 -i -F -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(2 . 4))
- (concat common-args "-B2 -A4 -F --heading -- foo")))))
+ (concat common-args "--heading -B2 -A4 -i -F -- foo")))))
(ert-deftest urgrep-tests-command-ag ()
(let ((tool (assoc "ag" urgrep-tools))
(common-args "ag --color-path 35 --color-match 1\\;31 "))
+ ;; String/case
(should (equal (urgrep-command "foo" :tool tool)
- (concat common-args "-Q --group -- foo")))
+ (concat common-args "--group -i -Q -- foo")))
+ (should (equal (urgrep-command "Foo" :tool tool)
+ (concat common-args "--group -s -Q -- Foo")))
+ (let ((case-fold-search nil))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "--group -s -Q -- foo"))))
+ ;; Group
(should (equal (urgrep-command "foo" :tool tool :group nil)
- (concat common-args "-Q --nogroup -- foo")))
+ (concat common-args "--nogroup -i -Q -- foo")))
+ ;; Regexp
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'bre)
- (concat common-args "--group -- \\\\\\(foo\\\\\\)")))
+ (concat common-args "--group -i -- \\\\\\(foo\\\\\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'ere)
- (concat common-args "--group -- \\(foo\\)")))
+ (concat common-args "--group -i -- \\(foo\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'pcre)
- (concat common-args "--group -- \\(foo\\)")))
+ (concat common-args "--group -i -- \\(foo\\)")))
+ ;; Context
(should (equal (urgrep-command "foo" :tool tool :context 3)
- (concat common-args "-C3 -Q --group -- foo")))
+ (concat common-args "--group -C3 -i -Q -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(3 . 3))
- (concat common-args "-C3 -Q --group -- foo")))
+ (concat common-args "--group -C3 -i -Q -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(2 . 4))
- (concat common-args "-B2 -A4 -Q --group -- foo")))))
+ (concat common-args "--group -B2 -A4 -i -Q -- foo")))))
(ert-deftest urgrep-tests-command-ack ()
(let ((tool (assoc "ack" urgrep-tools))
(common-args "ack --color-filename magenta --color-match bold\\ red "))
+ ;; String/case
(should (equal (urgrep-command "foo" :tool tool)
- (concat common-args "-Q --group -- foo")))
+ (concat common-args "--group -i -Q -- foo")))
+ (should (equal (urgrep-command "Foo" :tool tool)
+ (concat common-args "--group -Q -- Foo")))
+ (let ((case-fold-search nil))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "--group -Q -- foo"))))
+ ;; Group
(should (equal (urgrep-command "foo" :tool tool :group nil)
- (concat common-args "-Q --nogroup -- foo")))
+ (concat common-args "--nogroup -i -Q -- foo")))
+ ;; Regexp
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'bre)
- (concat common-args "--group -- \\\\\\(foo\\\\\\)")))
+ (concat common-args "--group -i -- \\\\\\(foo\\\\\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'ere)
- (concat common-args "--group -- \\(foo\\)")))
+ (concat common-args "--group -i -- \\(foo\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'pcre)
- (concat common-args "--group -- \\(foo\\)")))
+ (concat common-args "--group -i -- \\(foo\\)")))
+ ;; Context
(should (equal (urgrep-command "foo" :tool tool :context 3)
- (concat common-args "-C3 -Q --group -- foo")))
+ (concat common-args "--group -C3 -i -Q -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(3 . 3))
- (concat common-args "-C3 -Q --group -- foo")))
+ (concat common-args "--group -C3 -i -Q -- foo")))
(should (equal (urgrep-command "foo" :tool tool :context '(2 . 4))
- (concat common-args "-B2 -A4 -Q --group -- foo")))))
+ (concat common-args "--group -B2 -A4 -i -Q -- 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 "))
+ ;; String/case
(should (equal (urgrep-command "foo" :tool tool)
- (concat common-args "-F --heading --break -e foo")))
+ (concat common-args "--heading --break -i -F -e foo")))
+ (should (equal (urgrep-command "Foo" :tool tool)
+ (concat common-args "--heading --break -F -e Foo")))
+ (let ((case-fold-search nil))
+ (should (equal (urgrep-command "foo" :tool tool)
+ (concat common-args "--heading --break -F -e foo"))))
+ ;; Group
(should (equal (urgrep-command "foo" :tool tool :group nil)
- (concat common-args "-F -e foo")))
+ (concat common-args "-i -F -e foo")))
+ ;; Regexp
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'bre)
- (concat common-args "-G --heading --break -e \\(foo\\)")))
+ (concat common-args "--heading --break -i -G -e
\\(foo\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'ere)
- (concat common-args "-E --heading --break -e \\(foo\\)")))
+ (concat common-args "--heading --break -i -E -e
\\(foo\\)")))
(should (equal (urgrep-command "(foo)" :tool tool :regexp-syntax 'pcre)
- (concat common-args "-P --heading --break -e \\(foo\\)")))
+ (concat common-args "--heading --break -i -P -e
\\(foo\\)")))
+ ;; Context
(should (equal (urgrep-command "foo" :tool tool :context 3)
- (concat common-args "-C3 -F --heading --break -e foo")))))
+ (concat common-args "--heading --break -C3 -i -F -e foo")))
+ (should (equal (urgrep-command "foo" :tool tool :context '(3 . 3))
+ (concat common-args "--heading --break -C3 -i -F -e foo")))
+ (should (equal (urgrep-command "foo" :tool tool :context '(2 . 4))
+ (concat common-args "--heading --break -B2 -A4 -i -F -e
foo")))))
(ert-deftest urgrep-tests-command-grep ()
(let ((tool (assoc "grep" urgrep-tools)))
- (should (string-match "^find \\."
+ ;; String/case
+ (should (string-match "^find \\. .*grep .*-i .*foo"
(urgrep-command "foo" :tool tool)))
- (should (string-match "^find \\."
+ (should (string-match "^find \\. .*grep .*Foo"
+ (urgrep-command "Foo" :tool tool)))
+ (let ((case-fold-search nil))
+ (should (string-match "^find \\. .*grep .*foo"
+ (urgrep-command "foo" :tool tool))))
+ ;; Group
+ (should (string-match "^find \\. .*grep .*-i .*foo"
(urgrep-command "foo" :tool tool :group nil)))
- (should (string-match "^find \\."
+ ;; Regexp
+ (should (string-match "^find \\. .*grep .*-i .*\\\\(foo\\\\)"
(urgrep-command "(foo)" :tool tool
:regexp-syntax 'bre)))
- (should (string-match "^find \\."
+ (should (string-match "^find \\. .*grep .*-i .*\\\\(foo\\\\)"
(urgrep-command "(foo)" :tool tool
:regexp-syntax 'ere)))
- (should (string-match "^find \\."
+ (should (string-match "^find \\. .*grep .*-i .*\\\\(foo\\\\)"
(urgrep-command "(foo)" :tool tool
:regexp-syntax 'pcre)))
- (should (string-match "^find \\."
+ ;; Context
+ (should (string-match "^find \\. .*grep .*-i .*foo"
(urgrep-command "foo" :tool tool :context 3)))))
(ert-deftest urgrep-tests-get-tool-default ()
diff --git a/urgrep.el b/urgrep.el
index 83eb7dec60..39ef195278 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -104,8 +104,9 @@ If a cons, show CAR and CDR lines before and after,
respectively."
(post-arguments ("--"))
(group-arguments (('nil '("--no-heading"))
(_ '("--heading"))))
+ (context-arguments ,urgrep--context-arguments)
(regexp-arguments (('nil '("-F"))))
- (context-arguments ,urgrep--context-arguments))
+ (case-fold-arguments (((pred identity) '("-i")))))
("ag"
(executable-name "ag")
(regexp-syntax (pcre))
@@ -113,8 +114,10 @@ If a cons, show CAR and CDR lines before and after,
respectively."
(post-arguments ("--"))
(group-arguments (('nil '("--nogroup"))
(_ '("--group"))))
+ (context-arguments ,urgrep--context-arguments)
(regexp-arguments (('nil '("-Q"))))
- (context-arguments ,urgrep--context-arguments))
+ (case-fold-arguments (('nil '("-s"))
+ (_ '("-i")))))
("ack"
(executable-name "ack")
(regexp-syntax (pcre))
@@ -122,8 +125,9 @@ If a cons, show CAR and CDR lines before and after,
respectively."
(post-arguments ("--"))
(group-arguments (('nil '("--nogroup"))
(_ '("--group"))))
+ (context-arguments ,urgrep--context-arguments)
(regexp-arguments (('nil '("-Q"))))
- (context-arguments ,urgrep--context-arguments))
+ (case-fold-arguments (((pred identity) '("-i")))))
("git-grep"
(executable-name "git")
(vc-backend "Git")
@@ -133,11 +137,12 @@ If a cons, show CAR and CDR lines before and after,
respectively."
"--recurse-submodules"))
(post-arguments ("-e"))
(group-arguments (('t '("--heading" "--break"))))
+ (context-arguments ,urgrep--context-arguments)
(regexp-arguments (('bre '("-G"))
('ere '("-E"))
('pcre '("-P"))
(_ '("-F"))))
- (context-arguments ,urgrep--context-arguments))
+ (case-fold-arguments (((pred identity) '("-i")))))
("grep"
(executable-name "grep")
(command-function ,#'urgrep-rgrep--command)))
@@ -246,13 +251,16 @@ for MS shells."
(apply cmd-fun query rest)
(let* ((tool-re-syntax (urgrep--get-best-syntax regexp-syntax tool))
(query (urgrep--convert-regexp query regexp-syntax tool-re-syntax))
+ (fold-case (and case-fold-search
+ (isearch-no-upper-case-p query regexp-syntax)))
(executable (urgrep-get-property tool 'executable-name))
(pre-args (or (urgrep-get-property tool 'pre-arguments) '()))
(arguments (or (urgrep-get-property tool 'post-arguments) '())))
;; Fill in various options according to the tool's argument syntax.
- (dolist (i `((group-arguments . ,group)
- (regexp-arguments . ,tool-re-syntax)
- (context-arguments . ,context)))
+ (dolist (i `((regexp-arguments . ,tool-re-syntax)
+ (case-fold-arguments . ,fold-case)
+ (context-arguments . ,context)
+ (group-arguments . ,group)))
(when-let ((args (urgrep-get-property-pcase tool (car i) (cdr i))))
(setq arguments (append args arguments))))
;; FIXME: Inside compile and dired buffers, `shell-quote-argument'
- [elpa] externals/urgrep 1c08b41324 078/115: s/TRAMP/Tramp/g, (continued)
- [elpa] externals/urgrep 1c08b41324 078/115: s/TRAMP/Tramp/g, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6df13a8dee 071/115: Add support for urgrep command in Eshell, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 11e1f7474e 079/115: Add CI configuration, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep a7d87da8b5 096/115: Slight improvements to docstrings for defcustoms, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 1172efb5a2 107/115: Don't allow using an unknown tool in `urgrep-command`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 7823d384e6 115/115: Add .elpaignore, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e5d485de84 034/115: Improve behavior of `urgrep' to allow passing options and add `urgrep-run-command', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 31fe7d5e5c 022/115: Cache the default tool per-host and allow users to override the tool preferences, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 4fec944d51 016/115: Fix output of git-grep and grep on Linux, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep f2ac6d6b02 011/115: Fix getting vc backend, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3fb6b95f21 026/115: Add support for smart case-folding,
ELPA Syncer <=
- [elpa] externals/urgrep a405b9c459 031/115: Add ability to toggle case-sensitivity for the current search, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 74f38b1021 037/115: Add ability to filter the files to be searched, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 8065bb9f5e 039/115: Update requirements and fix failing MS Windows test, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep b0dbe7c6c1 046/115: Update heading, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e9e70552db 057/115: Use 'format-prompt' if available, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6f5813ba78 062/115: Add support for wgrep; resolves #2, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 69e45bad3c 069/115: Fix unit tests for git-grep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 8c6e3d5ba2 101/115: Ensure we get exactly the colors we want, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 2523b6ed4e 108/115: Improve line wrapping slightly, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e70773d86b 035/115: Refactor urgrep-process-setup so tools can define their own process-setup, ELPA Syncer, 2023/05/10