From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#23590: 25.0.94; Errors in default lgrep command Date: Tue, 13 Oct 2020 23:09:22 +0300 Organization: LINKOV.NET Message-ID: <87imbej8vh.fsf@mail.linkov.net> References: <87futcp8wp.fsf@gmail.com> <83fur0x0ft.fsf@gnu.org> <87fur0clhm.fsf@gmail.com> <83a8h8utdm.fsf@gnu.org> <838twsuskk.fsf@gnu.org> <87twfg0zrs.fsf@gmail.com> <87r1rh8wgf.fsf@gnus.org> <871ria7ldn.fsf@gnus.org> <837ds2a1r2.fsf@gnu.org> <87k0w06nmq.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28806"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: john.b.mastro@gmail.com, 23590@debbugs.gnu.org, agrambot@gmail.com To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 13 22:20:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSQmN-0007P9-BS for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Oct 2020 22:20:15 +0200 Original-Received: from localhost ([::1]:33002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSQmM-0007zz-8x for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Oct 2020 16:20:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSQmB-0007yc-Dk for bug-gnu-emacs@gnu.org; Tue, 13 Oct 2020 16:20:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kSQmA-0006xW-RK for bug-gnu-emacs@gnu.org; Tue, 13 Oct 2020 16:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kSQmA-0002Ag-EG for bug-gnu-emacs@gnu.org; Tue, 13 Oct 2020 16:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Oct 2020 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23590 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed patch Original-Received: via spool by 23590-submit@debbugs.gnu.org id=B23590.16026203718278 (code B ref 23590); Tue, 13 Oct 2020 20:20:02 +0000 Original-Received: (at 23590) by debbugs.gnu.org; 13 Oct 2020 20:19:31 +0000 Original-Received: from localhost ([127.0.0.1]:48996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kSQlf-00029S-GG for submit@debbugs.gnu.org; Tue, 13 Oct 2020 16:19:31 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:50101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kSQlc-00029D-RJ for 23590@debbugs.gnu.org; Tue, 13 Oct 2020 16:19:30 -0400 X-Originating-IP: 91.129.102.160 Original-Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 7AB9D1BF205; Tue, 13 Oct 2020 20:19:21 +0000 (UTC) In-Reply-To: <87k0w06nmq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 09 Oct 2020 06:15:25 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:190448 Archived-At: --=-=-= Content-Type: text/plain >> 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=grep-use-directories-skip.patch 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 , , , , and ." (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: " --=-=-=--