all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: john.b.mastro@gmail.com, 23590@debbugs.gnu.org, agrambot@gmail.com
Subject: bug#23590: 25.0.94; Errors in default lgrep command
Date: Tue, 13 Oct 2020 23:09:22 +0300	[thread overview]
Message-ID: <87imbej8vh.fsf@mail.linkov.net> (raw)
In-Reply-To: <87k0w06nmq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 09 Oct 2020 06:15:25 +0200")

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

>> The original bug report was about "M-x lgrep".  Can we make this
>> change affect only that command?
>>
>> In any case, this is a user-visible change, so it should be called out
>> in NEWS.
>
> Yup, and yup.

The latest fix has two problems:

1. it runs grep-probe every time lgrep is used;
2. it adds --directories=skip to the end of the command after regexp and file names

This patch improves both:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: grep-use-directories-skip.patch --]
[-- Type: text/x-diff, Size: 2164 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index f028a4279d..9b1dc337e8 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -959,10 +959,10 @@ grep-expand-keywords
 these include `opts', `dir', `files', `null-device', `excl' and
 `regexp'.")
 
-(defun grep-expand-template (template &optional regexp files dir excl)
+(defun grep-expand-template (template &optional regexp files dir excl more-opts)
   "Expand grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>."
   (let* ((command template)
-         (env `((opts . ,(let (opts)
+         (env `((opts . ,(let ((opts more-opts))
                            (when (and case-fold-search
                                       (isearch-no-upper-case-p regexp t))
                              (push "-i" opts))
@@ -1058,6 +1058,8 @@ grep-read-files
 	 (or (cdr (assoc files grep-files-aliases))
 	     files))))
 
+(defvar grep-use-directories-skip 'auto-detect)
+
 ;;;###autoload
 (defun lgrep (regexp &optional files dir confirm)
   "Run grep, searching for REGEXP in FILES in directory DIR.
@@ -1103,6 +1105,12 @@ lgrep
 	  (if (string= command grep-command)
 	      (setq command nil))
 	(setq dir (file-name-as-directory (expand-file-name dir)))
+	(unless (or (not grep-use-directories-skip) (eq grep-use-directories-skip t))
+	  (setq grep-use-directories-skip
+		(grep-probe grep-program
+			  `(nil nil nil "--directories=skip" "foo"
+				,null-device)
+			  nil 1)))
 	(setq command (grep-expand-template
 		       grep-template
 		       regexp
@@ -1119,13 +1127,10 @@ lgrep
 						     (shell-quote-argument
 						      (cdr ignore))))))
 				     grep-find-ignored-files
-				     " --exclude=")))))
+				     " --exclude=")))
+		       (and grep-use-directories-skip
+			    '("--directories=skip"))))
 	(when command
-          (when (grep-probe grep-program
-                            `(nil nil nil "--directories=skip" "foo"
-                                  ,null-device)
-                            nil 1)
-            (setq command (concat command " --directories=skip")))
 	  (if confirm
 	      (setq command
 		    (read-from-minibuffer "Confirm: "

  reply	other threads:[~2020-10-13 20:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-21  0:11 bug#23590: 25.0.94; Errors in default lgrep command Alex
2016-07-23  2:16 ` John Mastro
2016-07-23  7:45   ` Eli Zaretskii
2016-07-23 16:57     ` John Mastro
2016-07-23 17:15       ` Eli Zaretskii
2016-07-23 17:23         ` John Mastro
2016-07-23 17:58           ` Eli Zaretskii
2016-07-23 19:52             ` Glenn Morris
2016-07-23 17:28     ` Alex
2016-07-23 18:00       ` Eli Zaretskii
2016-07-23 18:18         ` Eli Zaretskii
2016-07-23 22:12           ` Alex
2020-09-04 14:09             ` Lars Ingebrigtsen
2020-10-07  3:41               ` Lars Ingebrigtsen
2020-10-07  8:17                 ` Eli Zaretskii
2020-10-09  4:15                   ` Lars Ingebrigtsen
2020-10-13 20:09                     ` Juri Linkov [this message]
2020-10-14  4:10                       ` Lars Ingebrigtsen
2016-07-23 17:11   ` Alex

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

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

  git send-email \
    --in-reply-to=87imbej8vh.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=23590@debbugs.gnu.org \
    --cc=agrambot@gmail.com \
    --cc=john.b.mastro@gmail.com \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.