unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Antoine Beaupré" <anarcat@orangeseeds.org>, 35326@debbugs.gnu.org
Subject: bug#35326: 26.1; vc-git-grep should pass -i like isearch
Date: Mon, 24 Jun 2019 23:45:51 +0300	[thread overview]
Message-ID: <87v9wu4sqo.fsf@mail.linkov.net> (raw)
In-Reply-To: <m336k00ybf.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 23 Jun 2019 23:46:44 +0200")

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

>> grep-expand-template adds the option -i on this condition:
>>
>>   (and case-fold-search (isearch-no-upper-case-p regexp t))
>>
>> It's very like when isearch turns into case-insensitive search
>> when the search string contains no upper-case letters.
>
> Yeah, sure, but no confusion here was why `M-x lgrep' adds the -i and
> `M-x grep' does not?  (running from -Q.)

The confusion was caused by the original report mentioning `M-x grep'.
In fact, `M-x grep' doesn't expand the template.  Only the following
commands expand the template:

  lgrep
  rgrep
  vc-git-grep

> And should the vc-git version be more like grep or lgrep?

vc-git-grep should be like other commands that expand the template,
i.e. lgrep and rgrep, that the patch in the original report
correctly achieves, so committing it would be an improvement
since `git grep' supports most of grep options, including --color,
-i and -w.

PS: Regarding -w that I proposed previously, I could create
a separate request, but here is a preliminary version:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: wrgrep.patch --]
[-- Type: text/x-diff, Size: 1422 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 67222f7862..d76ee3c90c 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -948,10 +948,14 @@ grep-expand-keywords
 If car of an element matches, the cdr is evalled in to get the
 substitution string.  Note dynamic scoping of variables.")
 
+(defvar grep-word-search nil)
+
 (defun grep-expand-template (template &optional regexp files dir excl)
   "Patch grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>."
   (let* ((command template)
          (env `((opts . ,(let (opts)
+                           (when grep-word-search
+                             (push "-w" opts))
                            (when (and case-fold-search
                                       (isearch-no-upper-case-p regexp t))
                              (push "-i" opts))
@@ -1248,6 +1252,14 @@ grep-find-toggle-abbreviation
             (add-text-properties beg end grep-find-abbreviate-properties))
         (user-error "No abbreviated part to hide/show")))))
 
+;;;###autoload
+(defun wrgrep ()
+  "Word-based version of `rgrep'.
+Modifies the grep-find template to add the option `-w' that matches whole words."
+  (interactive)
+  (let ((grep-word-search t))
+    (call-interactively 'rgrep)))
+
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)
   "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.

  reply	other threads:[~2019-06-24 20:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19 18:10 bug#35326: 26.1; vc-git-grep should pass -i like isearch Antoine Beaupré
2019-06-23 19:02 ` Lars Ingebrigtsen
2019-06-23 21:38   ` Juri Linkov
2019-06-23 21:46     ` Lars Ingebrigtsen
2019-06-24 20:45       ` Juri Linkov [this message]
2019-06-25 10:59         ` Lars Ingebrigtsen
2019-06-27 20:31           ` Juri Linkov
2019-06-25 11:00 ` Lars Ingebrigtsen
2019-06-25 13:03   ` Antoine Beaupré

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v9wu4sqo.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=35326@debbugs.gnu.org \
    --cc=anarcat@orangeseeds.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).