aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2009-09-10 00:58:15 +0000
committerJuri Linkov2009-09-10 00:58:15 +0000
commit7ae624301eaf097a367628a4ccac6cbc756aa5ba (patch)
tree3e96aad930a4cdfbe97577940dfbe0da4ce073b4
parent50c737e439caee63f0bdee279c05344aa98c2444 (diff)
downloademacs-7ae624301eaf097a367628a4ccac6cbc756aa5ba.tar.gz
emacs-7ae624301eaf097a367628a4ccac6cbc756aa5ba.zip
(grep-template): Add "<X>" to docstring.
(grep-files-aliases): Add "all". Move "el" and "ch" to the top of the list. Move "asm" to the bottom. (grep-find-ignored-directories): Add `choice' with nil value to empty the list easily. (grep-find-ignored-files): New option. (grep-files-history): Set to nil by default instead of '("ch" "el"). (grep-compute-defaults): Add "<X>" to `grep-template'. (grep-read-files): Bind new local variables `default-alias' and `default-extension'. Use a list of default values for the file prompt. (lgrep): Add `--exclude=' command line options composed from `grep-find-ignored-files'. (rgrep): Add `-name' command line options composed from `grep-find-ignored-files'. (Bug#4301)
-rw-r--r--lisp/ChangeLog25
-rw-r--r--lisp/progmodes/grep.el129
2 files changed, 115 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d030d24304e..05bcd0ad18b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,26 @@
12009-09-10 Juri Linkov <juri@jurta.org>
2
3 * isearch.el (isearch-text-char-description): Propertize escape
4 character sequences with the `escape-glyph' face. (Bug#4344)
5
6 * simple.el (shell-command): Set asynchronous process filter to
7 `comint-output-filter'. (Bug#4343)
8
9 * progmodes/grep.el (grep-template): Add "<X>" to docstring.
10 (grep-files-aliases): Add "all". Move "el" and "ch" to the top of
11 the list. Move "asm" to the bottom.
12 (grep-find-ignored-directories): Add `choice' with nil value
13 to empty the list easily.
14 (grep-find-ignored-files): New option.
15 (grep-files-history): Set to nil by default instead of '("ch" "el").
16 (grep-compute-defaults): Add "<X>" to `grep-template'.
17 (grep-read-files): Bind new local variables `default-alias' and
18 `default-extension'. Use a list of default values for the file prompt.
19 (lgrep): Add `--exclude=' command line options composed from
20 `grep-find-ignored-files'.
21 (rgrep): Add `-name' command line options composed from
22 `grep-find-ignored-files'. (Bug#4301)
23
12009-09-09 Stefan Monnier <monnier@iro.umontreal.ca> 242009-09-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 25
3 * diff-mode.el (diff-hunk-kill): Fix the search of the next hunk 26 * diff-mode.el (diff-hunk-kill): Fix the search of the next hunk
@@ -384,7 +407,7 @@
3842009-08-30 Kevin Rodgers <kevin.d.rodgers@gmail.com> 4072009-08-30 Kevin Rodgers <kevin.d.rodgers@gmail.com>
385 408
386 * progmodes/grep.el (grep-read-files): Strip trailing <N> from 409 * progmodes/grep.el (grep-read-files): Strip trailing <N> from
387 buffer names not visiting a file (e.g. cloned buffers). 410 buffer names not visiting a file (e.g. cloned buffers). (Bug#4210)
388 411
3892009-08-30 Nick Roberts <nickrob@snap.net.nz> 4122009-08-30 Nick Roberts <nickrob@snap.net.nz>
390 413
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index bf626f6e308..2c87548e5bf 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -120,6 +120,7 @@ Customize or call the function `grep-apply-setting'."
120The following place holders should be present in the string: 120The following place holders should be present in the string:
121 <C> - place to put -i if case insensitive grep. 121 <C> - place to put -i if case insensitive grep.
122 <F> - file names and wildcards to search. 122 <F> - file names and wildcards to search.
123 <X> - file names and wildcards to exclude.
123 <R> - the regular expression searched for. 124 <R> - the regular expression searched for.
124 <N> - place to insert null-device. 125 <N> - place to insert null-device.
125 126
@@ -176,18 +177,19 @@ Customize or call the function `grep-apply-setting'."
176 :group 'grep) 177 :group 'grep)
177 178
178(defcustom grep-files-aliases 179(defcustom grep-files-aliases
179 '(("asm" . "*.[sS]") 180 '(("all" . "* .*")
181 ("el" . "*.el")
182 ("ch" . "*.[ch]")
180 ("c" . "*.c") 183 ("c" . "*.c")
181 ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++") 184 ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++")
182 ("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++") 185 ("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++")
183 ("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++") 186 ("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++")
184 ("ch" . "*.[ch]")
185 ("el" . "*.el")
186 ("h" . "*.h") 187 ("h" . "*.h")
187 ("l" . "[Cc]hange[Ll]og*") 188 ("l" . "[Cc]hange[Ll]og*")
188 ("m" . "[Mm]akefile*") 189 ("m" . "[Mm]akefile*")
189 ("tex" . "*.tex") 190 ("tex" . "*.tex")
190 ("texi" . "*.texi")) 191 ("texi" . "*.texi")
192 ("asm" . "*.[sS]"))
191 "*Alist of aliases for the FILES argument to `lgrep' and `rgrep'." 193 "*Alist of aliases for the FILES argument to `lgrep' and `rgrep'."
192 :type 'alist 194 :type 'alist
193 :group 'grep) 195 :group 'grep)
@@ -197,7 +199,20 @@ Customize or call the function `grep-apply-setting'."
197 "*List of names of sub-directories which `rgrep' shall not recurse into. 199 "*List of names of sub-directories which `rgrep' shall not recurse into.
198If an element is a cons cell, the car is called on the search directory 200If an element is a cons cell, the car is called on the search directory
199to determine whether cdr should not be recursed into." 201to determine whether cdr should not be recursed into."
200 :type '(repeat string) 202 :type '(choice (repeat :tag "Ignored directories" string)
203 (const :tag "No ignored directories" nil))
204 :group 'grep)
205
206(defcustom grep-find-ignored-files
207 (cons ".#*" (delq nil (mapcar (lambda (s)
208 (unless (string-match-p "/\\'" s)
209 (concat "*" s)))
210 completion-ignored-extensions)))
211 "*List of file names which `rgrep' and `lgrep' shall exclude.
212If an element is a cons cell, the car is called on the search directory
213to determine whether cdr should not be excluded."
214 :type '(choice (repeat :tag "Ignored file" string)
215 (const :tag "No ignored files" nil))
201 :group 'grep) 216 :group 'grep)
202 217
203(defcustom grep-error-screen-columns nil 218(defcustom grep-error-screen-columns nil
@@ -421,7 +436,7 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
421 436
422;; History of lgrep and rgrep regexp and files args. 437;; History of lgrep and rgrep regexp and files args.
423(defvar grep-regexp-history nil) 438(defvar grep-regexp-history nil)
424(defvar grep-files-history '("ch" "el")) 439(defvar grep-files-history nil)
425 440
426;;;###autoload 441;;;###autoload
427(defun grep-process-setup () 442(defun grep-process-setup ()
@@ -524,7 +539,7 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
524 (format "%s %s " grep-program grep-options))) 539 (format "%s %s " grep-program grep-options)))
525 (unless grep-template 540 (unless grep-template
526 (setq grep-template 541 (setq grep-template
527 (format "%s <C> %s <R> <F>" grep-program grep-options))) 542 (format "%s <X> <C> %s <R> <F>" grep-program grep-options)))
528 (unless grep-find-use-xargs 543 (unless grep-find-use-xargs
529 (setq grep-find-use-xargs 544 (setq grep-find-use-xargs
530 (cond 545 (cond
@@ -753,20 +768,24 @@ substitution string. Note dynamic scoping of variables.")
753 (fn (and bn 768 (fn (and bn
754 (stringp bn) 769 (stringp bn)
755 (file-name-nondirectory bn))) 770 (file-name-nondirectory bn)))
771 (default-alias
772 (and fn
773 (let ((aliases grep-files-aliases)
774 alias)
775 (while aliases
776 (setq alias (car aliases)
777 aliases (cdr aliases))
778 (if (string-match (wildcard-to-regexp (cdr alias)) fn)
779 (setq aliases nil)
780 (setq alias nil)))
781 (cdr alias))))
782 (default-extension
783 (and fn
784 (let ((ext (file-name-extension fn)))
785 (and ext (concat "*." ext)))))
756 (default 786 (default
757 (or (and fn 787 (or default-alias
758 (let ((aliases grep-files-aliases) 788 default-extension
759 alias)
760 (while aliases
761 (setq alias (car aliases)
762 aliases (cdr aliases))
763 (if (string-match (wildcard-to-regexp (cdr alias)) fn)
764 (setq aliases nil)
765 (setq alias nil)))
766 (cdr alias)))
767 (and fn
768 (let ((ext (file-name-extension fn)))
769 (and ext (concat "*." ext))))
770 (car grep-files-history) 789 (car grep-files-history)
771 (car (car grep-files-aliases)))) 790 (car (car grep-files-aliases))))
772 (files (read-string 791 (files (read-string
@@ -774,7 +793,10 @@ substitution string. Note dynamic scoping of variables.")
774 "\" in files" 793 "\" in files"
775 (if default (concat " (default " default ")")) 794 (if default (concat " (default " default ")"))
776 ": ") 795 ": ")
777 nil 'grep-files-history default))) 796 nil 'grep-files-history
797 (delete-dups
798 (delq nil (append (list default default-alias default-extension)
799 (mapcar 'car grep-files-aliases)))))))
778 (and files 800 (and files
779 (or (cdr (assoc files grep-files-aliases)) 801 (or (cdr (assoc files grep-files-aliases))
780 files)))) 802 files))))
@@ -822,7 +844,20 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
822 (setq command (grep-expand-template 844 (setq command (grep-expand-template
823 grep-template 845 grep-template
824 regexp 846 regexp
825 files)) 847 files
848 nil
849 (and grep-find-ignored-files
850 (concat " --exclude="
851 (mapconcat
852 #'(lambda (ignore)
853 (cond ((stringp ignore)
854 (shell-quote-argument ignore))
855 ((consp ignore)
856 (and (funcall (car ignore) dir)
857 (shell-quote-argument
858 (cdr ignore))))))
859 grep-find-ignored-files
860 " --exclude=")))))
826 (when command 861 (when command
827 (if confirm 862 (if confirm
828 (setq command 863 (setq command
@@ -892,26 +927,44 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
892 (concat " -o " find-name-arg " ")) 927 (concat " -o " find-name-arg " "))
893 " " 928 " "
894 (shell-quote-argument ")")) 929 (shell-quote-argument ")"))
895 dir 930 dir
931 (concat
896 (and grep-find-ignored-directories 932 (and grep-find-ignored-directories
897 (concat (shell-quote-argument "(") 933 (concat (shell-quote-argument "(")
898 ;; we should use shell-quote-argument here 934 ;; we should use shell-quote-argument here
899 " -path " 935 " -path "
900 (mapconcat 936 (mapconcat
901 #'(lambda (ignore) 937 #'(lambda (ignore)
902 (cond ((stringp ignore) 938 (cond ((stringp ignore)
903 (shell-quote-argument 939 (shell-quote-argument
904 (concat "*/" ignore))) 940 (concat "*/" ignore)))
905 ((consp ignore) 941 ((consp ignore)
906 (and (funcall (car ignore) dir) 942 (and (funcall (car ignore) dir)
907 (shell-quote-argument 943 (shell-quote-argument
908 (concat "*/" 944 (concat "*/"
909 (cdr ignore))))))) 945 (cdr ignore)))))))
910 grep-find-ignored-directories 946 grep-find-ignored-directories
911 " -o -path ") 947 " -o -path ")
948 " "
949 (shell-quote-argument ")")
950 " -prune -o "))
951 (and grep-find-ignored-files
952 (concat (shell-quote-argument "(")
953 ;; we should use shell-quote-argument here
954 " -name "
955 (mapconcat
956 #'(lambda (ignore)
957 (cond ((stringp ignore)
958 (shell-quote-argument ignore))
959 ((consp ignore)
960 (and (funcall (car ignore) dir)
961 (shell-quote-argument
962 (cdr ignore))))))
963 grep-find-ignored-files
964 " -o -name ")
912 " " 965 " "
913 (shell-quote-argument ")") 966 (shell-quote-argument ")")
914 " -prune -o "))))) 967 " -prune -o "))))))
915 (when command 968 (when command
916 (if confirm 969 (if confirm
917 (setq command 970 (setq command