From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 23219@debbugs.gnu.org
Subject: bug#23219: 25.0.92; Find command cannot be customized for grep-find
Date: Tue, 05 Apr 2016 18:01:34 +0300 [thread overview]
Message-ID: <83twjgm75d.fsf@gnu.org> (raw)
In-Reply-To: <7bd3dc00-912e-48bf-e5ef-dc716b7ef49d@yandex.ru> (message from Dmitry Gutov on Tue, 5 Apr 2016 00:16:32 +0300)
> From: Dmitry Gutov <dgutov@yandex.ru>
> 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 <X> <C> %s <R> <F>" grep-program grep-options)))
+ (format "%s <X> <C> %s <R> <F>" 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 <C> %s <R>"
- 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 <D> <X> -type f <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 <D> <X> -type f <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 <D> <X> -type f <F> -exec %s %s{} +"
- find-program gcmd null))
+ grep-find-program gcmd null))
(t
(format "%s <D> <X> -type f <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)
next prev parent reply other threads:[~2016-04-05 15:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 20:37 bug#23219: 25.0.92; Find command cannot be customized for grep-find Eli Zaretskii
2016-04-04 21:16 ` Dmitry Gutov
2016-04-05 15:01 ` Eli Zaretskii [this message]
2016-04-05 15:12 ` Dmitry Gutov
2016-04-05 15:40 ` Eli Zaretskii
2016-04-05 15:42 ` Dmitry Gutov
2016-04-08 13:56 ` Eli Zaretskii
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=83twjgm75d.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=23219@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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.