aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuanma Barranquero2007-11-20 16:40:16 +0000
committerJuanma Barranquero2007-11-20 16:40:16 +0000
commit1571d112d97475f53d99a3aff303139ff6ac748b (patch)
tree182df168bce5d58c1e5bb857ab9f9687269a3c0d /lisp
parent48b4313069f1c3e6d8bc1f5e3e4729833a088d32 (diff)
downloademacs-1571d112d97475f53d99a3aff303139ff6ac748b.tar.gz
emacs-1571d112d97475f53d99a3aff303139ff6ac748b.zip
(xargs-program): New variable.
(grep-compute-defaults): Use it. (grep-default-command): Doc fix. (grep, lgrep, rgrep): Reflow docstrings.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/progmodes/grep.el48
2 files changed, 36 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 84fc597c93d..4d04952b62e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12007-11-20 Juanma Barranquero <lekktu@gmail.com>
2
3 * progmodes/grep.el (xargs-program): New variable.
4 (grep-compute-defaults): Use it.
5 (grep-default-command): Doc fix.
6 (grep, lgrep, rgrep): Reflow docstrings.
7
12007-11-20 Dan Nicolaescu <dann@ics.uci.edu> 82007-11-20 Dan Nicolaescu <dann@ics.uci.edu>
2 9
3 * vc.el (vc-find-revision): Set the parent buffer. 10 * vc.el (vc-find-revision): Set the parent buffer.
@@ -14,8 +21,7 @@
14 * emacs-lisp/tcover-ses.el (ses-set-curcell, ses-update-cells) 21 * emacs-lisp/tcover-ses.el (ses-set-curcell, ses-update-cells)
15 (ses-load, ses-vector-delete, ses-create-header-string) 22 (ses-load, ses-vector-delete, ses-create-header-string)
16 (ses-read-cell, ses-read-symbol, ses-command-hook, ses-jump): 23 (ses-read-cell, ses-read-symbol, ses-command-hook, ses-jump):
17 * emacs-lisp/gulp.el (mail-subject, mail-send): Declare as 24 * emacs-lisp/gulp.el (mail-subject, mail-send): Declare as functions.
18 functions.
19 25
202007-11-20 Stefan Monnier <monnier@iro.umontreal.ca> 262007-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
21 27
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 091735ee09d..1fee8cbd093 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -333,6 +333,12 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
333This variable's value takes effect when `grep-compute-defaults' is called.") 333This variable's value takes effect when `grep-compute-defaults' is called.")
334 334
335;;;###autoload 335;;;###autoload
336(defvar xargs-program "xargs"
337 "The default xargs program for `grep-find-command'.
338See `grep-find-use-xargs'.
339This variable's value takes effect when `grep-compute-defaults' is called.")
340
341;;;###autoload
336(defvar grep-find-use-xargs nil 342(defvar grep-find-use-xargs nil
337 "Non-nil means that `grep-find' uses the `xargs' utility by default. 343 "Non-nil means that `grep-find' uses the `xargs' utility by default.
338If `exec', use `find -exec'. 344If `exec', use `find -exec'.
@@ -475,15 +481,15 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
475 (cond 481 (cond
476 ((and 482 ((and
477 (grep-probe find-program `(nil nil nil ,null-device "-print0")) 483 (grep-probe find-program `(nil nil nil ,null-device "-print0"))
478 (grep-probe "xargs" `(nil nil nil "-0" "-e" "echo"))) 484 (grep-probe xargs-program `(nil nil nil "-0" "-e" "echo")))
479 'gnu) 485 'gnu)
480 (t 486 (t
481 'exec)))) 487 'exec))))
482 (unless grep-find-command 488 (unless grep-find-command
483 (setq grep-find-command 489 (setq grep-find-command
484 (cond ((eq grep-find-use-xargs 'gnu) 490 (cond ((eq grep-find-use-xargs 'gnu)
485 (format "%s . -type f -print0 | xargs -0 -e %s" 491 (format "%s . -type f -print0 | %s -0 -e %s"
486 find-program grep-command)) 492 find-program xargs-program grep-command))
487 ((eq grep-find-use-xargs 'exec) 493 ((eq grep-find-use-xargs 'exec)
488 (let ((cmd0 (format "%s . -type f -exec %s" 494 (let ((cmd0 (format "%s . -type f -exec %s"
489 find-program grep-command))) 495 find-program grep-command)))
@@ -493,22 +499,22 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
493 (shell-quote-argument ";")) 499 (shell-quote-argument ";"))
494 (1+ (length cmd0))))) 500 (1+ (length cmd0)))))
495 (t 501 (t
496 (format "%s . -type f -print | xargs %s" 502 (format "%s . -type f -print | %s %s"
497 find-program grep-command))))) 503 find-program xargs-program grep-command)))))
498 (unless grep-find-template 504 (unless grep-find-template
499 (setq grep-find-template 505 (setq grep-find-template
500 (let ((gcmd (format "%s <C> %s <R>" 506 (let ((gcmd (format "%s <C> %s <R>"
501 grep-program grep-options))) 507 grep-program grep-options)))
502 (cond ((eq grep-find-use-xargs 'gnu) 508 (cond ((eq grep-find-use-xargs 'gnu)
503 (format "%s . <X> -type f <F> -print0 | xargs -0 -e %s" 509 (format "%s . <X> -type f <F> -print0 | %s -0 -e %s"
504 find-program gcmd)) 510 find-program xargs-program gcmd))
505 ((eq grep-find-use-xargs 'exec) 511 ((eq grep-find-use-xargs 'exec)
506 (format "%s . <X> -type f <F> -exec %s {} %s %s" 512 (format "%s . <X> -type f <F> -exec %s {} %s %s"
507 find-program gcmd null-device 513 find-program gcmd null-device
508 (shell-quote-argument ";"))) 514 (shell-quote-argument ";")))
509 (t 515 (t
510 (format "%s . <X> -type f <F> -print | xargs %s" 516 (format "%s . <X> -type f <F> -print | %s %s"
511 find-program gcmd)))))))) 517 find-program xargs-program gcmd))))))))
512 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t)) 518 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t))
513 (setq grep-highlight-matches 519 (setq grep-highlight-matches
514 (with-temp-buffer 520 (with-temp-buffer
@@ -543,7 +549,7 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
543 "")) 549 ""))
544 550
545(defun grep-default-command () 551(defun grep-default-command ()
546 "Compute the default grep command for C-u M-x grep to offer." 552 "Compute the default grep command for \\[universal-argument] \\[grep] to offer."
547 (let ((tag-default (shell-quote-argument (grep-tag-default))) 553 (let ((tag-default (shell-quote-argument (grep-tag-default)))
548 ;; This a regexp to match single shell arguments. 554 ;; This a regexp to match single shell arguments.
549 ;; Could someone please add comments explaining it? 555 ;; Could someone please add comments explaining it?
@@ -596,19 +602,19 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
596 "Run grep, with user-specified args, and collect output in a buffer. 602 "Run grep, with user-specified args, and collect output in a buffer.
597While grep runs asynchronously, you can use \\[next-error] (M-x next-error), 603While grep runs asynchronously, you can use \\[next-error] (M-x next-error),
598or \\<grep-mode-map>\\[compile-goto-error] in the grep \ 604or \\<grep-mode-map>\\[compile-goto-error] in the grep \
599output buffer, to go to the lines 605output buffer, to go to the lines where grep
600where grep found matches. 606found matches.
601 607
602For doing a recursive `grep', see the `rgrep' command. For running 608For doing a recursive `grep', see the `rgrep' command. For running
603`grep' in a specific directory, see `lgrep'. 609`grep' in a specific directory, see `lgrep'.
604 610
605This command uses a special history list for its COMMAND-ARGS, so you can 611This command uses a special history list for its COMMAND-ARGS, so you
606easily repeat a grep command. 612can easily repeat a grep command.
607 613
608A prefix argument says to default the argument based upon the current 614A prefix argument says to default the argument based upon the current
609tag the cursor is over, substituting it into the last grep command 615tag the cursor is over, substituting it into the last grep command
610in the grep command history (or into `grep-command' 616in the grep command history (or into `grep-command' if that history
611if that history list is empty)." 617list is empty)."
612 (interactive 618 (interactive
613 (progn 619 (progn
614 (grep-compute-defaults) 620 (grep-compute-defaults)
@@ -736,8 +742,9 @@ before it is executed.
736With two \\[universal-argument] prefixes, directly edit and run `grep-command'. 742With two \\[universal-argument] prefixes, directly edit and run `grep-command'.
737 743
738Collect output in a buffer. While grep runs asynchronously, you 744Collect output in a buffer. While grep runs asynchronously, you
739can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] 745can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \
740in the grep output buffer, to go to the lines where grep found matches. 746in the grep output buffer,
747to go to the lines where grep found matches.
741 748
742This command shares argument histories with \\[rgrep] and \\[grep]." 749This command shares argument histories with \\[rgrep] and \\[grep]."
743 (interactive 750 (interactive
@@ -797,8 +804,9 @@ before it is executed.
797With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'. 804With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'.
798 805
799Collect output in a buffer. While find runs asynchronously, you 806Collect output in a buffer. While find runs asynchronously, you
800can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] 807can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \
801in the grep output buffer, to go to the lines where grep found matches. 808in the grep output buffer,
809to go to the lines where grep found matches.
802 810
803This command shares argument histories with \\[lgrep] and \\[grep-find]." 811This command shares argument histories with \\[lgrep] and \\[grep-find]."
804 (interactive 812 (interactive