From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23219: 25.0.92; Find command cannot be customized for grep-find Date: Tue, 05 Apr 2016 18:01:34 +0300 Message-ID: <83twjgm75d.fsf@gnu.org> References: <83a8l9nm99.fsf@gnu.org> <7bd3dc00-912e-48bf-e5ef-dc716b7ef49d@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1459868613 14553 80.91.229.3 (5 Apr 2016 15:03:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Apr 2016 15:03:33 +0000 (UTC) Cc: 23219@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 05 17:03:22 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1anSVh-0003Tn-1l for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Apr 2016 17:03:17 +0200 Original-Received: from localhost ([::1]:37577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSVg-0001B9-II for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Apr 2016 11:03:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSVY-0001A0-2O for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 11:03:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anSVR-0006af-Uq for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 11:03:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSVR-0006ab-Qz for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 11:03:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1anSVR-0004Ph-Ks for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 11:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Apr 2016 15:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23219 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23219-submit@debbugs.gnu.org id=B23219.145986853516910 (code B ref 23219); Tue, 05 Apr 2016 15:03:01 +0000 Original-Received: (at 23219) by debbugs.gnu.org; 5 Apr 2016 15:02:15 +0000 Original-Received: from localhost ([127.0.0.1]:52453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anSUh-0004Og-Ft for submit@debbugs.gnu.org; Tue, 05 Apr 2016 11:02:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53699) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anSUc-0004OQ-8f for 23219@debbugs.gnu.org; Tue, 05 Apr 2016 11:02:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anSUQ-0006AN-PU for 23219@debbugs.gnu.org; Tue, 05 Apr 2016 11:02:05 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSUQ-0006AG-M5; Tue, 05 Apr 2016 11:01:58 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4255 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1anSUP-0005Ld-Lq; Tue, 05 Apr 2016 11:01:58 -0400 In-reply-to: <7bd3dc00-912e-48bf-e5ef-dc716b7ef49d@yandex.ru> (message from Dmitry Gutov on Tue, 5 Apr 2016 00:16:32 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:116059 Archived-At: > From: Dmitry Gutov > Date: Tue, 5 Apr 2016 00:16:32 +0300 > > On 04/04/2016 11:37 PM, Eli Zaretskii wrote: > > On one of my machines, the GNU Find utility's executable file is named > > 'gfind'. To have xref-collect-matches work, I customized > > grep-find-command to have the value "gfind", but the find-grep pipe > > used after that still tried to invoke 'find', not 'gfind'. > > You need grep-find-template, not grep-find-command. > > > Looking > > around, I see that grep-compute-defaults effectively ignores > > grep-find-command and uses the value of find-program instead. Now, > > find-program is a defvar, so it wasn't supposed to be customized. Its > > value is never changed, no matter what are your customizations. > > Yes, it's a mess. Auto-computed custom variable values don't make much > sense to me either, but maybe the idea is if you want to change the > program to use as 'find', it'll likely have a slightly different syntax > (not in your case, though), and grep-compute-defaults might fail to > work, so you're better off customizing the end values. I see. But if only the name of the program's executable changes, then customizing everything would be an overkill, IMO. > > How am I supposed to make this stuff work in this situation? If the > > solution is to poke find-program, > > Probably. > > > it should be defcustom, > > *shrug* OK, suggested patch below. Thanks for the feedback. --- lisp/progmodes/grep.el~0 2016-02-15 06:39:16.000000000 +0200 +++ lisp/progmodes/grep.el 2016-04-05 17:45:42.595409800 +0300 @@ -411,21 +411,33 @@ This gets tacked on the end of the generated expressions.") ;;;###autoload -(defvar grep-program (purecopy "grep") +(defcustom grep-grep-program (purecopy "grep") "The default grep program for `grep-command' and `grep-find-command'. -This variable's value takes effect when `grep-compute-defaults' is called.") +This variable's value takes effect when `grep-compute-defaults' is called." + :type 'string + :set 'grep-apply-setting + :version "25.1" + :group 'grep) ;;;###autoload -(defvar find-program (purecopy "find") +(defcustom grep-find-program (purecopy "find") "The default find program. This is used by commands like `grep-find-command', `find-dired' -and others.") +and others." + :type 'string + :set 'grep-apply-setting + :version "25.1" + :group 'grep) ;;;###autoload -(defvar xargs-program (purecopy "xargs") +(defcustom grep-xargs-program (purecopy "xargs") "The default xargs program for `grep-find-command'. See `grep-find-use-xargs'. -This variable's value takes effect when `grep-compute-defaults' is called.") +This variable's value takes effect when `grep-compute-defaults' is called." + :type 'string + :set 'grep-apply-setting + :version "25.1" + :group 'grep) ;;;###autoload (defvar grep-find-use-xargs nil @@ -549,8 +561,8 @@ (grep-probe grep-command `(nil t nil "^English" ,hello-file) #'call-process-shell-command) - ;; otherwise use `grep-program' - (grep-probe grep-program + ;; otherwise use `grep-grep-program' + (grep-probe grep-grep-program `(nil t nil "-nH" "^English" ,hello-file))) (progn (goto-char (point-min)) @@ -561,7 +573,7 @@ (when (eq grep-highlight-matches 'auto-detect) (setq grep-highlight-matches (with-temp-buffer - (and (grep-probe grep-program '(nil t nil "--help")) + (and (grep-probe grep-grep-program '(nil t nil "--help")) (progn (goto-char (point-min)) (search-forward "--color" nil t)) @@ -573,16 +585,16 @@ grep-template grep-find-template) (let ((grep-options (concat (if grep-use-null-device "-n" "-nH") - (if (grep-probe grep-program + (if (grep-probe grep-grep-program `(nil nil nil "-e" "foo" ,null-device) nil 1) " -e")))) (unless grep-command (setq grep-command - (format "%s %s %s " grep-program + (format "%s %s %s " grep-grep-program (or (and grep-highlight-matches - (grep-probe grep-program + (grep-probe grep-grep-program `(nil nil nil "--color" "x" ,null-device) nil 1) (if (eq grep-highlight-matches 'always) @@ -591,17 +603,18 @@ grep-options))) (unless grep-template (setq grep-template - (format "%s %s " grep-program grep-options))) + (format "%s %s " grep-grep-program grep-options))) (unless grep-find-use-xargs (setq grep-find-use-xargs (cond - ((grep-probe find-program + ((grep-probe grep-find-program `(nil nil nil ,null-device "-exec" "echo" "{}" "+")) 'exec-plus) ((and - (grep-probe find-program `(nil nil nil ,null-device "-print0")) - (grep-probe xargs-program `(nil nil nil "-0" "echo"))) + (grep-probe grep-find-program + `(nil nil nil ,null-device "-print0")) + (grep-probe grep-xargs-program `(nil nil nil "-0" "echo"))) 'gnu) (t 'exec)))) @@ -612,10 +625,11 @@ ;; after the pipe symbol be quoted if they use ;; forward slashes as directory separators. (format "%s . -type f -print0 | \"%s\" -0 %s" - find-program xargs-program grep-command)) + grep-find-program grep-xargs-program + grep-command)) ((memq grep-find-use-xargs '(exec exec-plus)) (let ((cmd0 (format "%s . -type f -exec %s" - find-program grep-command)) + grep-find-program grep-command)) (null (if grep-use-null-device (format "%s " null-device) ""))) @@ -627,27 +641,28 @@ (1+ (length cmd0))))) (t (format "%s . -type f -print | \"%s\" %s" - find-program xargs-program grep-command))))) + grep-find-program grep-xargs-program + grep-command))))) (unless grep-find-template (setq grep-find-template (let ((gcmd (format "%s %s " - grep-program grep-options)) + grep-grep-program grep-options)) (null (if grep-use-null-device (format "%s " null-device) ""))) (cond ((eq grep-find-use-xargs 'gnu) (format "%s -type f -print0 | \"%s\" -0 %s" - find-program xargs-program gcmd)) + grep-find-program grep-xargs-program gcmd)) ((eq grep-find-use-xargs 'exec) (format "%s -type f -exec %s {} %s%s" - find-program gcmd null + grep-find-program gcmd null (shell-quote-argument ";"))) ((eq grep-find-use-xargs 'exec-plus) (format "%s -type f -exec %s %s{} +" - find-program gcmd null)) + grep-find-program gcmd null)) (t (format "%s -type f -print | \"%s\" %s" - find-program xargs-program gcmd)))))))) + grep-find-program grep-xargs-program gcmd)))))))) ;; Save defaults for this host. (setq grep-host-defaults-alist @@ -1080,7 +1095,7 @@ ;;;###autoload (defun zrgrep (regexp &optional files dir confirm template) "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR. -Like `rgrep' but uses `zgrep' for `grep-program', sets the default +Like `rgrep' but uses `zgrep' for `grep-grep-program', sets the default file name to `*.gz', and sets `grep-highlight-matches' to `always'." (interactive (progn @@ -1088,7 +1103,7 @@ (grep-compute-defaults) ;; Compute the default zrgrep command by running `grep-compute-defaults' ;; for grep program "zgrep", but not changing global values. - (let ((grep-program "zgrep") + (let ((grep-grep-program "zgrep") ;; Don't change global values for variables computed ;; by `grep-compute-defaults'. (grep-find-template nil)