Mercurial > emacs
annotate lisp/progmodes/grep.el @ 100330:3f13e82befbc
* Makefile.in (ELCFILES): Add ruby-mode.elc.
* progmodes/ruby-mode.el: New file.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 10 Dec 2008 18:59:36 +0000 |
parents | 90b078ed2dc4 |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
62160 | 1 ;;; grep.el --- run Grep as inferior of Emacs, parse match messages |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
2 |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
87560
62e8690b9f1a
(find-name-arg): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87523
diff
changeset
|
4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
62e8690b9f1a
(find-name-arg): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87523
diff
changeset
|
5 ;; Free Software Foundation, Inc. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
6 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
7 ;; Author: Roland McGrath <roland@gnu.org> |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
8 ;; Maintainer: FSF |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
9 ;; Keywords: tools, processes |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
10 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
12 |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94566
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94566
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94566
diff
changeset
|
16 ;; (at your option) any later version. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
17 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
22 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94566
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
25 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
26 ;;; Commentary: |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
27 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
28 ;; This package provides the grep facilities documented in the Emacs |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 ;; user's manual. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
30 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
31 ;;; Code: |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
32 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
33 (require 'compile) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
34 |
65232
6b7109ed93a0
(font-lock-lines-before): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
65126
diff
changeset
|
35 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
36 (defgroup grep nil |
70258 | 37 "Run grep as inferior of Emacs, parse error messages." |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
38 :group 'tools |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
39 :group 'processes) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
40 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 ;;;###autoload |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
43 (defcustom grep-window-height nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 "*Number of lines in a grep window. If nil, use `compilation-window-height'." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 :type '(choice (const :tag "Default" nil) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
46 integer) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
47 :version "22.1" |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
48 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
49 |
56948
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
50 (defcustom grep-highlight-matches 'auto-detect |
56960
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
51 "If t, use special markers to highlight grep matches. |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
52 |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
53 Some grep programs are able to surround matches with special |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
54 markers in grep output. Such markers can be used to highlight |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
55 matches in grep mode. |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
56 |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
57 This option sets the environment variable GREP_COLOR to specify |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
58 markers for highlighting and GREP_OPTIONS to add the --color |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
59 option in front of any explicit grep options before starting |
56960
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
60 the grep. |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
61 |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
62 The default value of this variable is set up by `grep-compute-defaults'; |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
63 call that function before using this variable in your program." |
56948
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
64 :type '(choice (const :tag "Do not highlight matches with grep markers" nil) |
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
65 (const :tag "Highlight matches with grep markers" t) |
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
66 (other :tag "Not Set" auto-detect)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
67 :version "22.1" |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
68 :group 'grep) |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
69 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
70 (defcustom grep-scroll-output nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
71 "*Non-nil to scroll the *grep* buffer window as output appears. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
72 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
73 Setting it causes the grep commands to put point at the end of their |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
74 output window so that the end of the output is always visible rather |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
75 than the begining." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
76 :type 'boolean |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
77 :version "22.1" |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
78 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
79 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
80 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
81 (defcustom grep-command nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
82 "The default grep command for \\[grep]. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
83 If the grep program used supports an option to always include file names |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
84 in its output (such as the `-H' option to GNU grep), it's a good idea to |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
85 include it when specifying `grep-command'. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
86 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
87 The default value of this variable is set up by `grep-compute-defaults'; |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
88 call that function before using this variable in your program." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
89 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
90 (const :tag "Not Set" nil)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
91 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
92 |
70258 | 93 (defcustom grep-template nil |
94 "The default command to run for \\[lgrep]. | |
95 The default value of this variable is set up by `grep-compute-defaults'; | |
96 call that function before using this variable in your program. | |
97 The following place holders should be present in the string: | |
98 <C> - place to put -i if case insensitive grep. | |
99 <F> - file names and wildcards to search. | |
100 <R> - the regular expression searched for. | |
101 <N> - place to insert null-device." | |
102 :type '(choice string | |
103 (const :tag "Not Set" nil)) | |
104 :version "22.1" | |
105 :group 'grep) | |
106 | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
107 (defcustom grep-use-null-device 'auto-detect |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
108 "If t, append the value of `null-device' to `grep' commands. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
109 This is done to ensure that the output of grep includes the filename of |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
110 any match in the case where only a single file is searched, and is not |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
111 necessary if the grep program used supports the `-H' option. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
112 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
113 The default value of this variable is set up by `grep-compute-defaults'; |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
114 call that function before using this variable in your program." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
115 :type '(choice (const :tag "Do Not Append Null Device" nil) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
116 (const :tag "Append Null Device" t) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
117 (other :tag "Not Set" auto-detect)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
118 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
119 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
120 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
121 (defcustom grep-find-command nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
122 "The default find command for \\[grep-find]. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
123 The default value of this variable is set up by `grep-compute-defaults'; |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
124 call that function before using this variable in your program." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
125 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
126 (const :tag "Not Set" nil)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
127 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
128 |
70258 | 129 (defcustom grep-find-template nil |
130 "The default command to run for \\[rgrep]. | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
131 The default value of this variable is set up by `grep-compute-defaults'; |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
132 call that function before using this variable in your program. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
133 The following place holders should be present in the string: |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
134 <D> - base directory for find |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
135 <X> - find options to restrict or expand the directory list |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
136 <F> - find options to limit the files matched |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
137 <C> - place to put -i if case insensitive grep |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
138 <R> - the regular expression searched for." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
139 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
140 (const :tag "Not Set" nil)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
141 :version "22.1" |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
142 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
143 |
83780
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
144 (defcustom grep-files-aliases |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
145 '(("asm" . "*.[sS]") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
146 ("c" . "*.c") |
96604
8e43e1211ac1
(grep-files-aliases): Improve the C++ source
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94775
diff
changeset
|
147 ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++") |
8e43e1211ac1
(grep-files-aliases): Improve the C++ source
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94775
diff
changeset
|
148 ("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++") |
8e43e1211ac1
(grep-files-aliases): Improve the C++ source
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94775
diff
changeset
|
149 ("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++") |
83780
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
150 ("ch" . "*.[ch]") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
151 ("el" . "*.el") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
152 ("h" . "*.h") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
153 ("l" . "[Cc]hange[Ll]og*") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
154 ("m" . "[Mm]akefile*") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
155 ("tex" . "*.tex") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
156 ("texi" . "*.texi")) |
70258 | 157 "*Alist of aliases for the FILES argument to `lgrep' and `rgrep'." |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
158 :type 'alist |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
159 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
160 |
83778
309cf30d46f5
(grep-find-ignored-directories): Add
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82421
diff
changeset
|
161 (defcustom grep-find-ignored-directories |
87523
fe5c2c0f8dcf
* progmodes/grep.el (grep-find-ignored-directories): Initialize
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
87453
diff
changeset
|
162 vc-directory-exclusion-list |
70258 | 163 "*List of names of sub-directories which `rgrep' shall not recurse into." |
164 :type '(repeat string) | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
165 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
166 |
56226
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
167 (defcustom grep-error-screen-columns nil |
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
168 "*If non-nil, column numbers in grep hits are screen columns. |
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
169 See `compilation-error-screen-columns'" |
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
170 :type '(choice (const :tag "Default" nil) |
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
171 integer) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
172 :version "22.1" |
56226
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
173 :group 'grep) |
bfe817c8d413
(grep-error-screen-columns): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
56155
diff
changeset
|
174 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
175 ;;;###autoload |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
176 (defcustom grep-setup-hook nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
177 "List of hook functions run by `grep-process-setup' (see `run-hooks')." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
178 :type 'hook |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
179 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
180 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
181 (defvar grep-mode-map |
94775
b51bb57e843b
(compilation-minor-mode-map, compilation-mode-map):
Sam Steingold <sds@gnu.org>
parents:
94673
diff
changeset
|
182 (let ((map (make-sparse-keymap))) |
b51bb57e843b
(compilation-minor-mode-map, compilation-mode-map):
Sam Steingold <sds@gnu.org>
parents:
94673
diff
changeset
|
183 (set-keymap-parent map compilation-minor-mode-map) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
184 (define-key map " " 'scroll-up) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
185 (define-key map "\^?" 'scroll-down) |
57022
463edf7390ca
(grep-mode-map): Rename `next-error-follow-mode' to `next-error-follow-minor-mode'.
Juri Linkov <juri@jurta.org>
parents:
56998
diff
changeset
|
186 (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
187 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
188 (define-key map "\r" 'compile-goto-error) ;; ? |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
189 (define-key map "n" 'next-error-no-select) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
190 (define-key map "p" 'previous-error-no-select) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
191 (define-key map "{" 'compilation-previous-file) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
192 (define-key map "}" 'compilation-next-file) |
64728
c1b77e79c51a
(grep-mode-map): Bind TAB to `compilation-next-error'
Juri Linkov <juri@jurta.org>
parents:
64725
diff
changeset
|
193 (define-key map "\t" 'compilation-next-error) |
c1b77e79c51a
(grep-mode-map): Bind TAB to `compilation-next-error'
Juri Linkov <juri@jurta.org>
parents:
64725
diff
changeset
|
194 (define-key map [backtab] 'compilation-previous-error) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
195 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
196 ;; Set up the menu-bar |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
197 (define-key map [menu-bar grep] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
198 (cons "Grep" (make-sparse-keymap "Grep"))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
199 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
200 (define-key map [menu-bar grep compilation-kill-compilation] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
201 '(menu-item "Kill Grep" kill-compilation |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
202 :help "Kill the currently running grep process")) |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
203 (define-key map [menu-bar grep compilation-separator2] '("----")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 (define-key map [menu-bar grep compilation-compile] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
205 '(menu-item "Compile..." compile |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
206 :help "Compile the program including the current buffer. Default: run `make'")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
207 (define-key map [menu-bar grep compilation-grep] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
208 '(menu-item "Another grep..." grep |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
209 :help "Run grep, with user-specified args, and collect output in a buffer.")) |
70258 | 210 (define-key map [menu-bar grep compilation-grep-find] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
211 '(menu-item "Recursive grep..." grep-find |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
212 :help "Run grep via find, with user-specified args")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
213 (define-key map [menu-bar grep compilation-recompile] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
214 '(menu-item "Repeat grep" recompile |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
215 :help "Run grep again")) |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
216 (define-key map [menu-bar grep compilation-separator2] '("----")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
217 (define-key map [menu-bar grep compilation-first-error] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
218 '(menu-item "First Match" first-error |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
219 :help "Restart at the first match, visit corresponding location")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
220 (define-key map [menu-bar grep compilation-previous-error] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
221 '(menu-item "Previous Match" previous-error |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
222 :help "Visit the previous match and corresponding location")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
223 (define-key map [menu-bar grep compilation-next-error] |
92493
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
224 '(menu-item "Next Match" next-error |
402ee2cfca27
* bindings.el (mode-line-remote): Add mouse-face. Improve tooltip.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92230
diff
changeset
|
225 :help "Visit the next match and corresponding location")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
226 map) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
227 "Keymap for grep buffers. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
228 `compilation-minor-mode-map' is a cdr of this.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
229 |
92204
ab425a596ec9
(grep-mode-tool-bar-map): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
88102
diff
changeset
|
230 (defvar grep-mode-tool-bar-map |
98660
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
231 ;; When bootstrapping, tool-bar-map is not properly initialized yet, |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
232 ;; so don't do anything. |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
233 (when (keymapp (butlast tool-bar-map)) |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
234 (let ((map (butlast (copy-keymap tool-bar-map))) |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
235 (help (last tool-bar-map))) ;; Keep Help last in tool bar |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
236 (tool-bar-local-item |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
237 "left-arrow" 'previous-error-no-select 'previous-error-no-select map |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
238 :rtl "right-arrow" |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
239 :help "Goto previous match") |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
240 (tool-bar-local-item |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
241 "right-arrow" 'next-error-no-select 'next-error-no-select map |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
242 :rtl "left-arrow" |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
243 :help "Goto next match") |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
244 (tool-bar-local-item |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
245 "cancel" 'kill-compilation 'kill-compilation map |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
246 :enable '(let ((buffer (compilation-find-buffer))) |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
247 (get-buffer-process buffer)) |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
248 :help "Stop grep") |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
249 (tool-bar-local-item |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
250 "refresh" 'recompile 'recompile map |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
251 :help "Restart grep") |
90b078ed2dc4
(grep-mode-tool-bar-map): Check if tool-bar-map has been initialized
Chong Yidong <cyd@stupidchicken.com>
parents:
98629
diff
changeset
|
252 (append map help)))) |
92204
ab425a596ec9
(grep-mode-tool-bar-map): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
88102
diff
changeset
|
253 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
254 (defalias 'kill-grep 'kill-compilation) |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
255 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
256 ;;;; TODO --- refine this!! |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
257 |
94141
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
258 ;; (defcustom grep-use-compilation-buffer t |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
259 ;; "When non-nil, grep specific commands update `compilation-last-buffer'. |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
260 ;; This means that standard compile commands like \\[next-error] and \\[compile-goto-error] |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
261 ;; can be used to navigate between grep matches (the default). |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
262 ;; Otherwise, the grep specific commands like \\[grep-next-match] must |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
263 ;; be used to navigate between grep matches." |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
264 ;; :type 'boolean |
e93898d6903e
Fix up comment convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93335
diff
changeset
|
265 ;; :group 'grep) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
266 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
267 ;; override compilation-last-buffer |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
268 (defvar grep-last-buffer nil |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
269 "The most recent grep buffer. |
71854
a4944423be59
(grep-last-buffer): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71422
diff
changeset
|
270 A grep buffer becomes most recent when you select Grep mode in it. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
271 Notice that using \\[next-error] or \\[compile-goto-error] modifies |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
272 `complation-last-buffer' rather than `grep-last-buffer'.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
273 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
274 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
275 (defvar grep-regexp-alist |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
276 '(("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2" |
64725
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
277 1 3) |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
278 ;; Rule to match column numbers is commented out since no known grep |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
279 ;; produces them |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
280 ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?" |
64725
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
281 ;; 1 3 (4 . 5)) |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
282 ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\ |
64509 | 283 \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)" |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
284 2 3 |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
285 ;; Calculate column positions (beg . end) of first grep match on a line |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
286 ((lambda () |
64509 | 287 (setq compilation-error-screen-columns nil) |
288 (- (match-beginning 4) (match-end 1))) | |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
289 . |
64509 | 290 (lambda () (- (match-end 5) (match-end 1) |
291 (- (match-end 4) (match-beginning 4))))) | |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
292 nil 1) |
64740
eeed7a7c1afa
(grep-regexp-alist): Set 5th arg `TYPE' to
Juri Linkov <juri@jurta.org>
parents:
64728
diff
changeset
|
293 ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
294 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
295 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
296 (defvar grep-error "grep hit" |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
297 "Message to print when no matches are found.") |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
298 |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
299 ;; Reverse the colors because grep hits are not errors (though we jump there |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
300 ;; with `next-error'), and unreadable files can't be gone to. |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
301 (defvar grep-hit-face compilation-info-face |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
302 "Face name to use for grep hits.") |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
303 |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
304 (defvar grep-error-face 'compilation-error |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
305 "Face name to use for grep error messages.") |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
306 |
58988
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
307 (defvar grep-match-face 'match |
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
308 "Face name to use for grep matches.") |
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
309 |
64725
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
310 (defvar grep-context-face 'shadow |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
311 "Face name to use for grep context lines.") |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
312 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
313 (defvar grep-mode-font-lock-keywords |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
314 '(;; Command output lines. |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
315 ("^\\([A-Za-z_0-9/\.+-]+\\)[ \t]*:" 1 font-lock-function-name-face) |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
316 (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$" |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
317 1 grep-error-face) |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
318 ;; remove match from grep-regexp-alist before fontifying |
71422
2611669abf9e
(grep-mode-font-lock-keywords): Correct regexps
Kim F. Storm <storm@cua.dk>
parents:
70712
diff
changeset
|
319 ("^Grep[/a-zA-z]* started.*" |
65126
559a37c2f306
(grep, grep-mode): Make buffer-local variables
Juri Linkov <juri@jurta.org>
parents:
65056
diff
changeset
|
320 (0 '(face nil message nil help-echo nil mouse-face nil) t)) |
71422
2611669abf9e
(grep-mode-font-lock-keywords): Correct regexps
Kim F. Storm <storm@cua.dk>
parents:
70712
diff
changeset
|
321 ("^Grep[/a-zA-z]* finished \\(?:(\\(matches found\\))\\|with \\(no matches found\\)\\).*" |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
322 (0 '(face nil message nil help-echo nil mouse-face nil) t) |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
323 (1 compilation-info-face nil t) |
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
324 (2 compilation-warning-face nil t)) |
71422
2611669abf9e
(grep-mode-font-lock-keywords): Correct regexps
Kim F. Storm <storm@cua.dk>
parents:
70712
diff
changeset
|
325 ("^Grep[/a-zA-z]* \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*" |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
326 (0 '(face nil message nil help-echo nil mouse-face nil) t) |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
327 (1 grep-error-face) |
64944
c845f6151d83
(grep-mode-map): Add ellipsis to "Another grep".
Juri Linkov <juri@jurta.org>
parents:
64864
diff
changeset
|
328 (2 grep-error-face nil t)) |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
329 ("^.+?-[0-9]+-.*\n" (0 grep-context-face)) |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
330 ;; Highlight grep matches and delete markers |
64509 | 331 ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)" |
61902
e8076329ceee
(grep-mode-font-lock-keywords): Use the font-lock-face property to
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
332 ;; Refontification does not work after the markers have been |
e8076329ceee
(grep-mode-font-lock-keywords): Use the font-lock-face property to
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
333 ;; deleted. So we use the font-lock-face property here as Font |
e8076329ceee
(grep-mode-font-lock-keywords): Use the font-lock-face property to
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
334 ;; Lock does not clear that. |
e8076329ceee
(grep-mode-font-lock-keywords): Use the font-lock-face property to
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
335 (2 (list 'face nil 'font-lock-face grep-match-face)) |
64509 | 336 ((lambda (bound)) |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
337 (progn |
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
338 ;; Delete markers with `replace-match' because it updates |
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
339 ;; the match-data, whereas `delete-region' would render it obsolete. |
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
340 (replace-match "" t t nil 3) |
64509 | 341 (replace-match "" t t nil 1)))) |
342 ("\\(\033\\[[0-9;]*[mK]\\)" | |
343 ;; Delete all remaining escape sequences | |
344 ((lambda (bound)) | |
345 (replace-match "" t t nil 1)))) | |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
346 "Additional things to highlight in grep output. |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
347 This gets tacked on the end of the generated expressions.") |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
348 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
349 ;;;###autoload |
76966
e1190fd4a1f2
(grep-program): Remove commentary about zgrep.
Kim F. Storm <storm@cua.dk>
parents:
76455
diff
changeset
|
350 (defvar grep-program "grep" |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
351 "The default grep program for `grep-command' and `grep-find-command'. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
352 This variable's value takes effect when `grep-compute-defaults' is called.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
353 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
354 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
355 (defvar find-program "find" |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
356 "The default find program for `grep-find-command'. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
357 This variable's value takes effect when `grep-compute-defaults' is called.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
358 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
359 ;;;###autoload |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
360 (defvar xargs-program "xargs" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
361 "The default xargs program for `grep-find-command'. |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
362 See `grep-find-use-xargs'. |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
363 This variable's value takes effect when `grep-compute-defaults' is called.") |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
364 |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
365 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
366 (defvar grep-find-use-xargs nil |
77033
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
367 "Non-nil means that `grep-find' uses the `xargs' utility by default. |
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
368 If `exec', use `find -exec'. |
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
369 If `gnu', use `find -print0' and `xargs -0'. |
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
370 Any other non-nil value means to use `find -print' and `xargs'. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
371 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
372 This variable's value takes effect when `grep-compute-defaults' is called.") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
373 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
374 ;; History of grep commands. |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
375 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
376 (defvar grep-history nil) |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
377 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
378 (defvar grep-find-history nil) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
379 |
70258 | 380 ;; History of lgrep and rgrep regexp and files args. |
381 (defvar grep-regexp-history nil) | |
382 (defvar grep-files-history '("ch" "el")) | |
383 | |
81972
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
384 (defvar grep-host-defaults-alist nil |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
385 "Default values depending on target host. |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
386 `grep-compute-defaults' returns default values for every local or |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
387 remote host `grep' runs. These values can differ from host to |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
388 host. Once computed, the default values are kept here in order |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
389 to avoid computing them again.") |
70258 | 390 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
391 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
392 (defun grep-process-setup () |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
393 "Setup compilation variables and buffer for `grep'. |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
394 Set up `compilation-exit-message-function' and run `grep-setup-hook'." |
56960
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
395 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t)) |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
396 (grep-compute-defaults)) |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
397 (when (eq grep-highlight-matches t) |
86354
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
398 ;; `setenv' modifies `process-environment' let-bound in `compilation-start' |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
399 ;; Any TERM except "dumb" allows GNU grep to use `--color=auto' |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
400 (setenv "TERM" "emacs-grep") |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
401 ;; `--color=auto' emits escape sequences on a tty rather than on a pipe, |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
402 ;; thus allowing to use multiple grep filters on the command line |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
403 ;; and to output escape sequences only on the final grep output |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
404 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=auto")) |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
405 ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions |
64509 | 406 (setenv "GREP_COLOR" "01;31") |
86354
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
407 ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions |
64509 | 408 (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:ml=:cx=:ne")) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
409 (set (make-local-variable 'compilation-exit-message-function) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
410 (lambda (status code msg) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
411 (if (eq status 'exit) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
412 (cond ((zerop code) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
413 '("finished (matches found)\n" . "matched")) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
414 ((= code 1) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
415 '("finished with no matches found\n" . "no match")) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
416 (t |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
417 (cons msg code))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
418 (cons msg code)))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
419 (run-hooks 'grep-setup-hook)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
420 |
70258 | 421 (defun grep-probe (command args &optional func result) |
422 (equal (condition-case nil | |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
423 (apply (or func 'process-file) command args) |
70258 | 424 (error nil)) |
425 (or result 0))) | |
426 | |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
427 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
428 (defun grep-compute-defaults () |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
429 ;; Keep default values. |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
430 (unless grep-host-defaults-alist |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
431 (add-to-list |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
432 'grep-host-defaults-alist |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
433 (cons nil |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
434 `((grep-command ,grep-command) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
435 (grep-template ,grep-template) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
436 (grep-use-null-device ,grep-use-null-device) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
437 (grep-find-command ,grep-find-command) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
438 (grep-find-template ,grep-find-template) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
439 (grep-find-use-xargs ,grep-find-use-xargs) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
440 (grep-highlight-matches ,grep-highlight-matches))))) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
441 (let* ((host-id |
88102
0fa30755c209
(grep-compute-defaults):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87560
diff
changeset
|
442 (intern (or (file-remote-p default-directory) "localhost"))) |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
443 (host-defaults (assq host-id grep-host-defaults-alist)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
444 (defaults (assq nil grep-host-defaults-alist))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
445 ;; There are different defaults on different hosts. They must be |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
446 ;; computed for every host once. |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
447 (setq grep-command |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
448 (or (cadr (assq 'grep-command host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
449 (cadr (assq 'grep-command defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
450 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
451 grep-template |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
452 (or (cadr (assq 'grep-template host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
453 (cadr (assq 'grep-template defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
454 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
455 grep-use-null-device |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
456 (or (cadr (assq 'grep-use-null-device host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
457 (cadr (assq 'grep-use-null-device defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
458 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
459 grep-find-command |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
460 (or (cadr (assq 'grep-find-command host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
461 (cadr (assq 'grep-find-command defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
462 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
463 grep-find-template |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
464 (or (cadr (assq 'grep-find-template host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
465 (cadr (assq 'grep-find-template defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
466 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
467 grep-find-use-xargs |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
468 (or (cadr (assq 'grep-find-use-xargs host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
469 (cadr (assq 'grep-find-use-xargs defaults))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
470 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
471 grep-highlight-matches |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
472 (or (cadr (assq 'grep-highlight-matches host-defaults)) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
473 (cadr (assq 'grep-highlight-matches defaults)))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
474 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
475 (unless (or (not grep-use-null-device) (eq grep-use-null-device t)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
476 (setq grep-use-null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
477 (with-temp-buffer |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
478 (let ((hello-file (expand-file-name "HELLO" data-directory))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
479 (not |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
480 (and (if grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
481 ;; `grep-command' is already set, so |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
482 ;; use that for testing. |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
483 (grep-probe grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
484 `(nil t nil "^English" ,hello-file) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
485 #'call-process-shell-command) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
486 ;; otherwise use `grep-program' |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
487 (grep-probe grep-program |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
488 `(nil t nil "-nH" "^English" ,hello-file))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
489 (progn |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
490 (goto-char (point-min)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
491 (looking-at |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
492 (concat (regexp-quote hello-file) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
493 ":[0-9]+:English"))))))))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
494 (unless (and grep-command grep-find-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
495 grep-template grep-find-template) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
496 (let ((grep-options |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
497 (concat (if grep-use-null-device "-n" "-nH") |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
498 (if (grep-probe grep-program |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
499 `(nil nil nil "-e" "foo" ,null-device) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
500 nil 1) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
501 " -e")))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
502 (unless grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
503 (setq grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
504 (format "%s %s " grep-program grep-options))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
505 (unless grep-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
506 (setq grep-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
507 (format "%s <C> %s <R> <F>" grep-program grep-options))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
508 (unless grep-find-use-xargs |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
509 (setq grep-find-use-xargs |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
510 (cond |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
511 ((and |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
512 (grep-probe find-program `(nil nil nil ,null-device "-print0")) |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
513 (grep-probe xargs-program `(nil nil nil "-0" "-e" "echo"))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
514 'gnu) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
515 (t |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
516 'exec)))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
517 (unless grep-find-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
518 (setq grep-find-command |
70258 | 519 (cond ((eq grep-find-use-xargs 'gnu) |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
520 (format "%s . -type f -print0 | %s -0 -e %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
521 find-program xargs-program grep-command)) |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
522 ((eq grep-find-use-xargs 'exec) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
523 (let ((cmd0 (format "%s . -type f -exec %s" |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
524 find-program grep-command))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
525 (cons |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
526 (format "%s {} %s %s" |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
527 cmd0 null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
528 (shell-quote-argument ";")) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
529 (1+ (length cmd0))))) |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
530 (t |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
531 (format "%s . -type f -print | %s %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
532 find-program xargs-program grep-command))))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
533 (unless grep-find-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
534 (setq grep-find-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
535 (let ((gcmd (format "%s <C> %s <R>" |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
536 grep-program grep-options))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
537 (cond ((eq grep-find-use-xargs 'gnu) |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
538 (format "%s . <X> -type f <F> -print0 | %s -0 -e %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
539 find-program xargs-program gcmd)) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
540 ((eq grep-find-use-xargs 'exec) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
541 (format "%s . <X> -type f <F> -exec %s {} %s %s" |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
542 find-program gcmd null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
543 (shell-quote-argument ";"))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
544 (t |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
545 (format "%s . <X> -type f <F> -print | %s %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
546 find-program xargs-program gcmd)))))))) |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
547 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
548 (setq grep-highlight-matches |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
549 (with-temp-buffer |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
550 (and (grep-probe grep-program '(nil t nil "--help")) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
551 (progn |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
552 (goto-char (point-min)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
553 (search-forward "--color" nil t)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
554 t)))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
555 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
556 ;; Save defaults for this host. |
81972
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
557 (setq grep-host-defaults-alist |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
558 (delete (assq host-id grep-host-defaults-alist) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
559 grep-host-defaults-alist)) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
560 (add-to-list |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
561 'grep-host-defaults-alist |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
562 (cons host-id |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
563 `((grep-command ,grep-command) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
564 (grep-template ,grep-template) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
565 (grep-use-null-device ,grep-use-null-device) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
566 (grep-find-command ,grep-find-command) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
567 (grep-find-template ,grep-find-template) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
568 (grep-find-use-xargs ,grep-find-use-xargs) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
569 (grep-highlight-matches ,grep-highlight-matches)))))) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
570 |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
571 (defun grep-tag-default () |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
572 (or (and transient-mark-mode mark-active |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
573 (/= (point) (mark)) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
574 (buffer-substring-no-properties (point) (mark))) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
575 (funcall (or find-tag-default-function |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
576 (get major-mode 'find-tag-default-function) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
577 'find-tag-default)) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
578 "")) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
579 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
580 (defun grep-default-command () |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
581 "Compute the default grep command for \\[universal-argument] \\[grep] to offer." |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
582 (let ((tag-default (shell-quote-argument (grep-tag-default))) |
72173
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
583 ;; This a regexp to match single shell arguments. |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
584 ;; Could someone please add comments explaining it? |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
585 (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
586 (grep-default (or (car grep-history) grep-command))) |
72173
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
587 ;; In the default command, find the arg that specifies the pattern. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
588 (when (or (string-match |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
589 (concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*" |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
590 sh-arg-re "\\(\\s +\\(\\S +\\)\\)?") |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
591 grep-default) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
592 ;; If the string is not yet complete. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
593 (string-match "\\(\\)\\'" grep-default)) |
72173
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
594 ;; Maybe we will replace the pattern with the default tag. |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
595 ;; But first, maybe replace the file name pattern. |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
596 (condition-case nil |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
597 (unless (or (not (stringp buffer-file-name)) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
598 (when (match-beginning 2) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
599 (save-match-data |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
600 (string-match |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
601 (wildcard-to-regexp |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
602 (file-name-nondirectory |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
603 (match-string 3 grep-default))) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
604 (file-name-nondirectory buffer-file-name))))) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
605 (setq grep-default (concat (substring grep-default |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
606 0 (match-beginning 2)) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
607 " *." |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
608 (file-name-extension buffer-file-name)))) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
609 ;; In case wildcard-to-regexp gets an error |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
610 ;; from invalid data. |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
611 (error nil)) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
612 ;; Now replace the pattern with the default tag. |
57908
a4ed247d476f
(grep-default-command): Take empty string
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
57769
diff
changeset
|
613 (replace-match tag-default t t grep-default 1)))) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
614 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
615 |
64509 | 616 ;;;###autoload |
55018 | 617 (define-compilation-mode grep-mode "Grep" |
618 "Sets `grep-last-buffer' and `compilation-window-height'." | |
619 (setq grep-last-buffer (current-buffer)) | |
92204
ab425a596ec9
(grep-mode-tool-bar-map): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
88102
diff
changeset
|
620 (set (make-local-variable 'tool-bar-map) grep-mode-tool-bar-map) |
55018 | 621 (set (make-local-variable 'compilation-error-face) |
622 grep-hit-face) | |
623 (set (make-local-variable 'compilation-error-regexp-alist) | |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
624 grep-regexp-alist) |
65126
559a37c2f306
(grep, grep-mode): Make buffer-local variables
Juri Linkov <juri@jurta.org>
parents:
65056
diff
changeset
|
625 (set (make-local-variable 'compilation-process-setup-function) |
559a37c2f306
(grep, grep-mode): Make buffer-local variables
Juri Linkov <juri@jurta.org>
parents:
65056
diff
changeset
|
626 'grep-process-setup) |
69499
caf8f09897bc
* font-lock.el (font-lock-lines-before): Delete variable, subsumed by
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68773
diff
changeset
|
627 (set (make-local-variable 'compilation-disable-input) t)) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
628 |
70258 | 629 |
630 ;;;###autoload | |
631 (defun grep (command-args) | |
632 "Run grep, with user-specified args, and collect output in a buffer. | |
633 While grep runs asynchronously, you can use \\[next-error] (M-x next-error), | |
634 or \\<grep-mode-map>\\[compile-goto-error] in the grep \ | |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
635 output buffer, to go to the lines where grep |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
636 found matches. |
70258 | 637 |
75803
81c369551691
(grep): Mention lgrep and rgrep in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
75347
diff
changeset
|
638 For doing a recursive `grep', see the `rgrep' command. For running |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
639 `grep' in a specific directory, see `lgrep'. |
75803
81c369551691
(grep): Mention lgrep and rgrep in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
75347
diff
changeset
|
640 |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
641 This command uses a special history list for its COMMAND-ARGS, so you |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
642 can easily repeat a grep command. |
70258 | 643 |
644 A prefix argument says to default the argument based upon the current | |
645 tag the cursor is over, substituting it into the last grep command | |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
646 in the grep command history (or into `grep-command' if that history |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
647 list is empty)." |
70258 | 648 (interactive |
649 (progn | |
650 (grep-compute-defaults) | |
651 (let ((default (grep-default-command))) | |
93114
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
652 (list (read-shell-command "Run grep (like this): " |
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
653 (if current-prefix-arg default grep-command) |
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
654 'grep-history |
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
655 (if current-prefix-arg nil default)))))) |
70258 | 656 |
657 ;; Setting process-setup-function makes exit-message-function work | |
658 ;; even when async processes aren't supported. | |
659 (compilation-start (if (and grep-use-null-device null-device) | |
660 (concat command-args " " null-device) | |
661 command-args) | |
662 'grep-mode)) | |
663 | |
664 | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
665 ;;;###autoload |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
666 (defun grep-find (command-args) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
667 "Run grep via find, with user-specified args COMMAND-ARGS. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
668 Collect output in a buffer. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
669 While find runs asynchronously, you can use the \\[next-error] command |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
670 to find the text that grep hits refer to. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
671 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
672 This command uses a special history list for its arguments, so you can |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
673 easily repeat a find command." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
674 (interactive |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
675 (progn |
70258 | 676 (grep-compute-defaults) |
53750
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
677 (if grep-find-command |
93114
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
678 (list (read-shell-command "Run find (like this): " |
57fa8ebfd227
* progmodes/compile.el (compile):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92493
diff
changeset
|
679 grep-find-command 'grep-find-history)) |
53750
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
680 ;; No default was set |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
681 (read-string |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
682 "compile.el: No `grep-find-command' command available. Press RET.") |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
683 (list nil)))) |
70712
070ab453b31f
(grep-find): Don't check grep-find-command
Kim F. Storm <storm@cua.dk>
parents:
70534
diff
changeset
|
684 (when command-args |
53750
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
685 (let ((null-device nil)) ; see grep |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
686 (grep command-args)))) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
687 |
59688
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
688 ;;;###autoload |
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
689 (defalias 'find-grep 'grep-find) |
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
690 |
70258 | 691 |
692 ;; User-friendly interactive API. | |
693 | |
694 (defconst grep-expand-keywords | |
695 '(("<C>" . (and cf (isearch-no-upper-case-p regexp t) "-i")) | |
696 ("<D>" . dir) | |
697 ("<F>" . files) | |
698 ("<N>" . null-device) | |
699 ("<X>" . excl) | |
700 ("<R>" . (shell-quote-argument (or regexp "")))) | |
701 "List of substitutions performed by `grep-expand-template'. | |
702 If car of an element matches, the cdr is evalled in to get the | |
703 substitution string. Note dynamic scoping of variables.") | |
704 | |
705 (defun grep-expand-template (template &optional regexp files dir excl) | |
706 "Patch grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>." | |
707 (let ((command template) | |
708 (cf case-fold-search) | |
709 (case-fold-search nil)) | |
710 (dolist (kw grep-expand-keywords command) | |
711 (if (string-match (car kw) command) | |
70315
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
712 (setq command |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
713 (replace-match |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
714 (or (if (symbolp (cdr kw)) |
70340
3146cc3b9e56
(grep-expand-template): Use symbol-value instead of eval on symbols.
Kim F. Storm <storm@cua.dk>
parents:
70315
diff
changeset
|
715 (symbol-value (cdr kw)) |
70315
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
716 (save-match-data (eval (cdr kw)))) |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
717 "") |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
718 t t command)))))) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
719 |
70258 | 720 (defun grep-read-regexp () |
721 "Read regexp arg for interactive grep." | |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
722 (let ((default (grep-tag-default))) |
70258 | 723 (read-string |
724 (concat "Search for" | |
725 (if (and default (> (length default) 0)) | |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
726 (format " (default \"%s\"): " default) ": ")) |
70258 | 727 nil 'grep-regexp-history default))) |
728 | |
729 (defun grep-read-files (regexp) | |
730 "Read files arg for interactive grep." | |
70259
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
731 (let* ((bn (or (buffer-file-name) (buffer-name))) |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
732 (fn (and bn |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
733 (stringp bn) |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
734 (file-name-nondirectory bn))) |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
735 (default |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
736 (or (and fn |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
737 (let ((aliases grep-files-aliases) |
70258 | 738 alias) |
739 (while aliases | |
740 (setq alias (car aliases) | |
741 aliases (cdr aliases)) | |
742 (if (string-match (wildcard-to-regexp (cdr alias)) fn) | |
743 (setq aliases nil) | |
744 (setq alias nil))) | |
745 (cdr alias))) | |
70259
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
746 (and fn |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
747 (let ((ext (file-name-extension fn))) |
72165
301cc56a3482
(grep-read-files): Use car of grep-files-history or grep-files-aliases
Kim F. Storm <storm@cua.dk>
parents:
72163
diff
changeset
|
748 (and ext (concat "*." ext)))) |
301cc56a3482
(grep-read-files): Use car of grep-files-history or grep-files-aliases
Kim F. Storm <storm@cua.dk>
parents:
72163
diff
changeset
|
749 (car grep-files-history) |
301cc56a3482
(grep-read-files): Use car of grep-files-history or grep-files-aliases
Kim F. Storm <storm@cua.dk>
parents:
72163
diff
changeset
|
750 (car (car grep-files-aliases)))) |
70258 | 751 (files (read-string |
752 (concat "Search for \"" regexp | |
70259
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
753 "\" in files" |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
754 (if default (concat " (default " default ")")) |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
755 ": ") |
70258 | 756 nil 'grep-files-history default))) |
757 (and files | |
758 (or (cdr (assoc files grep-files-aliases)) | |
759 files)))) | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
760 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
761 ;;;###autoload |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
762 (defun lgrep (regexp &optional files dir) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
763 "Run grep, searching for REGEXP in FILES in directory DIR. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
764 The search is limited to file names matching shell pattern FILES. |
70258 | 765 FILES may use abbreviations defined in `grep-files-aliases', e.g. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
766 entering `ch' is equivalent to `*.[ch]'. |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
767 |
70526 | 768 With \\[universal-argument] prefix, you can edit the constructed shell command line |
769 before it is executed. | |
770 With two \\[universal-argument] prefixes, directly edit and run `grep-command'. | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
771 |
70258 | 772 Collect output in a buffer. While grep runs asynchronously, you |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
773 can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \ |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
774 in the grep output buffer, |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
775 to go to the lines where grep found matches. |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
776 |
70258 | 777 This command shares argument histories with \\[rgrep] and \\[grep]." |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
778 (interactive |
70258 | 779 (progn |
780 (grep-compute-defaults) | |
781 (cond | |
782 ((and grep-command (equal current-prefix-arg '(16))) | |
783 (list (read-from-minibuffer "Run: " grep-command | |
784 nil nil 'grep-history) | |
785 nil)) | |
786 ((not grep-template) | |
787 (list nil | |
788 (read-string "grep.el: No `grep-template' available. Press RET."))) | |
789 (t (let* ((regexp (grep-read-regexp)) | |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
790 (files (grep-read-files regexp)) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
791 (dir (read-directory-name "In directory: " |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
792 nil default-directory t))) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
793 (list regexp files dir)))))) |
70258 | 794 (when (and (stringp regexp) (> (length regexp) 0)) |
795 (let ((command regexp)) | |
796 (if (null files) | |
797 (if (string= command grep-command) | |
798 (setq command nil)) | |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
799 (setq dir (file-name-as-directory (expand-file-name dir))) |
70258 | 800 (setq command (grep-expand-template |
801 grep-template | |
802 regexp | |
803 files)) | |
804 (when command | |
805 (if (equal current-prefix-arg '(4)) | |
806 (setq command | |
807 (read-from-minibuffer "Confirm: " | |
808 command nil nil 'grep-history)) | |
70421
47fe68ac1971
(lgrep, rgrep): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
70340
diff
changeset
|
809 (add-to-history 'grep-history command)))) |
70258 | 810 (when command |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
811 (let ((default-directory dir)) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
812 ;; Setting process-setup-function makes exit-message-function work |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
813 ;; even when async processes aren't supported. |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
814 (compilation-start (if (and grep-use-null-device null-device) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
815 (concat command " " null-device) |
82421 | 816 command) |
817 'grep-mode)) | |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
818 (if (eq next-error-last-buffer (current-buffer)) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
819 (setq default-directory dir)))))) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
820 |
70258 | 821 |
87560
62e8690b9f1a
(find-name-arg): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87523
diff
changeset
|
822 (defvar find-name-arg) ; autoloaded |
70258 | 823 |
824 ;;;###autoload | |
825 (defun rgrep (regexp &optional files dir) | |
70526 | 826 "Recursively grep for REGEXP in FILES in directory tree rooted at DIR. |
70258 | 827 The search is limited to file names matching shell pattern FILES. |
828 FILES may use abbreviations defined in `grep-files-aliases', e.g. | |
829 entering `ch' is equivalent to `*.[ch]'. | |
830 | |
70526 | 831 With \\[universal-argument] prefix, you can edit the constructed shell command line |
832 before it is executed. | |
833 With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'. | |
70258 | 834 |
835 Collect output in a buffer. While find runs asynchronously, you | |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
836 can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \ |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
837 in the grep output buffer, |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
838 to go to the lines where grep found matches. |
70258 | 839 |
840 This command shares argument histories with \\[lgrep] and \\[grep-find]." | |
841 (interactive | |
842 (progn | |
843 (grep-compute-defaults) | |
844 (cond | |
845 ((and grep-find-command (equal current-prefix-arg '(16))) | |
846 (list (read-from-minibuffer "Run: " grep-find-command | |
847 nil nil 'grep-find-history) | |
848 nil)) | |
849 ((not grep-find-template) | |
850 (list nil nil | |
851 (read-string "grep.el: No `grep-find-template' available. Press RET."))) | |
852 (t (let* ((regexp (grep-read-regexp)) | |
853 (files (grep-read-files regexp)) | |
854 (dir (read-directory-name "Base directory: " | |
855 nil default-directory t))) | |
856 (list regexp files dir)))))) | |
857 (when (and (stringp regexp) (> (length regexp) 0)) | |
858 (if (null files) | |
859 (if (not (string= regexp grep-find-command)) | |
860 (compilation-start regexp 'grep-mode)) | |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
861 (setq dir (file-name-as-directory (expand-file-name dir))) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
862 (let ((command (grep-expand-template |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
863 grep-find-template |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
864 regexp |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
865 (concat (shell-quote-argument "(") |
79589
05774558f6e1
(rgrep): Use find-name-arg.
Jason Rumney <jasonr@gnu.org>
parents:
78234
diff
changeset
|
866 " " find-name-arg " " |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
867 (mapconcat #'shell-quote-argument |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
868 (split-string files) |
79643
078fe4baaf42
(rgrep): Fix last change.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79589
diff
changeset
|
869 (concat " -o " find-name-arg " ")) |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
870 " " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
871 (shell-quote-argument ")")) |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
872 dir |
70258 | 873 (and grep-find-ignored-directories |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
874 (concat (shell-quote-argument "(") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
875 ;; we should use shell-quote-argument here |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
876 " -path " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
877 (mapconcat #'(lambda (dir) |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
878 (shell-quote-argument |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
879 (concat "*/" dir))) |
70258 | 880 grep-find-ignored-directories |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
881 " -o -path ") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
882 " " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
883 (shell-quote-argument ")") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
884 " -prune -o "))))) |
70258 | 885 (when command |
886 (if current-prefix-arg | |
887 (setq command | |
888 (read-from-minibuffer "Confirm: " | |
889 command nil nil 'grep-find-history)) | |
70421
47fe68ac1971
(lgrep, rgrep): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
70340
diff
changeset
|
890 (add-to-history 'grep-find-history command)) |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
891 (let ((default-directory dir)) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
892 (compilation-start command 'grep-mode)) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
893 ;; Set default-directory if we started rgrep in the *grep* buffer. |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
894 (if (eq next-error-last-buffer (current-buffer)) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
895 (setq default-directory dir))))))) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
896 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
897 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
898 (provide 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
899 |
57043
cb013e5835b8
(grep-mode): Remove unnecessary autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57022
diff
changeset
|
900 ;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
901 ;;; grep.el ends here |