Mercurial > emacs
annotate lisp/progmodes/grep.el @ 88055:9ea2c2750268
src/macterm.c (XTset_vertical_scroll_bar): Fix merge mistake
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1020
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 29 Jan 2008 05:12:00 +0000 |
parents | 62e8690b9f1a |
children | 0fa30755c209 606f2d163a64 |
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 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
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 |
78234
c1ec1c8a8d2e
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77033
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
16 ;; any later version. |
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 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
53139
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 ;;; Commentary: |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
30 ;; 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
|
31 ;; user's manual. |
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 ;;; Code: |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
34 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
35 (require 'compile) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
36 |
65232
6b7109ed93a0
(font-lock-lines-before): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
65126
diff
changeset
|
37 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
38 (defgroup grep nil |
70258 | 39 "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
|
40 :group 'tools |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 :group 'processes) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
43 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 ;;;###autoload |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 (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
|
46 "*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
|
47 :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
|
48 integer) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
49 :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
|
50 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
51 |
56948
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
52 (defcustom grep-highlight-matches 'auto-detect |
56960
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
53 "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
|
54 |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
55 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
|
56 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
|
57 matches in grep mode. |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
58 |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 the grep. |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
63 |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
64 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
|
65 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
|
66 :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
|
67 (const :tag "Highlight matches with grep markers" t) |
f6f74981c4b0
(grep-highlight-matches): Change default from
Juri Linkov <juri@jurta.org>
parents:
56921
diff
changeset
|
68 (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
|
69 :version "22.1" |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
70 :group 'grep) |
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
71 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
72 (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
|
73 "*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
|
74 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
75 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
|
76 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
|
77 than the begining." |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
78 :type 'boolean |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59991
diff
changeset
|
79 :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
|
80 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
81 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
82 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
83 (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
|
84 "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
|
85 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
|
86 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
|
87 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
|
88 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
89 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
|
90 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
|
91 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
92 (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
|
93 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
94 |
70258 | 95 (defcustom grep-template nil |
96 "The default command to run for \\[lgrep]. | |
97 The default value of this variable is set up by `grep-compute-defaults'; | |
98 call that function before using this variable in your program. | |
99 The following place holders should be present in the string: | |
100 <C> - place to put -i if case insensitive grep. | |
101 <F> - file names and wildcards to search. | |
102 <R> - the regular expression searched for. | |
103 <N> - place to insert null-device." | |
104 :type '(choice string | |
105 (const :tag "Not Set" nil)) | |
106 :version "22.1" | |
107 :group 'grep) | |
108 | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
109 (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
|
110 "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
|
111 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
|
112 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
|
113 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
|
114 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
115 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
|
116 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
|
117 :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
|
118 (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
|
119 (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
|
120 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
121 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
122 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
123 (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
|
124 "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
|
125 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
|
126 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
|
127 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
128 (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
|
129 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
130 |
70258 | 131 (defcustom grep-find-template nil |
132 "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
|
133 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
|
134 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
|
135 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
|
136 <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
|
137 <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
|
138 <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
|
139 <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
|
140 <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
|
141 :type '(choice string |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
142 (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
|
143 :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
|
144 :group 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
145 |
83780
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
146 (defcustom grep-files-aliases |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
147 '(("asm" . "*.[sS]") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
148 ("c" . "*.c") |
d1d369daf8dd
(grep-files-aliases): Add cc alias.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
83778
diff
changeset
|
149 ("cc" . "*.cc") |
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 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
182 (let ((map (cons 'keymap compilation-minor-mode-map))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
183 (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
|
184 (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
|
185 (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
|
186 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
187 (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
|
188 (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
|
189 (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
|
190 (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
|
191 (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
|
192 (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
|
193 (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
|
194 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
195 ;; 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
|
196 (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
|
197 (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
|
198 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
199 (define-key map [menu-bar grep compilation-kill-compilation] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
200 '("Kill Grep" . kill-compilation)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
201 (define-key map [menu-bar grep compilation-separator2] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
202 '("----" . nil)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
203 (define-key map [menu-bar grep compilation-compile] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 '("Compile..." . compile)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
205 (define-key map [menu-bar grep compilation-grep] |
64944
c845f6151d83
(grep-mode-map): Add ellipsis to "Another grep".
Juri Linkov <juri@jurta.org>
parents:
64864
diff
changeset
|
206 '("Another grep..." . grep)) |
70258 | 207 (define-key map [menu-bar grep compilation-grep-find] |
208 '("Recursive grep..." . grep-find)) | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
209 (define-key map [menu-bar grep compilation-recompile] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
210 '("Repeat grep" . recompile)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
211 (define-key map [menu-bar grep compilation-separator2] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
212 '("----" . nil)) |
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-first-error] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
214 '("First Match" . first-error)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
215 (define-key map [menu-bar grep compilation-previous-error] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
216 '("Previous Match" . previous-error)) |
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-next-error] |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
218 '("Next Match" . next-error)) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
219 map) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
220 "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
|
221 `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
|
222 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
223 (defalias 'kill-grep 'kill-compilation) |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
224 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
225 ;;;; TODO --- refine this!! |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
226 |
53145
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
227 ;;; (defcustom grep-use-compilation-buffer t |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
228 ;;; "When non-nil, grep specific commands update `compilation-last-buffer'. |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
229 ;;; This means that standard compile commands like \\[next-error] and \\[compile-goto-error] |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
230 ;;; can be used to navigate between grep matches (the default). |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
231 ;;; Otherwise, the grep specific commands like \\[grep-next-match] must |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
232 ;;; be used to navigate between grep matches." |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
233 ;;; :type 'boolean |
a0151f86f01e
Remove grep-use-compilation-buffer defcustom.
Kim F. Storm <storm@cua.dk>
parents:
53139
diff
changeset
|
234 ;;; :group 'grep) |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
235 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
236 ;; 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
|
237 (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
|
238 "The most recent grep buffer. |
71854
a4944423be59
(grep-last-buffer): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
71422
diff
changeset
|
239 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
|
240 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
|
241 `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
|
242 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
243 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
244 (defvar grep-regexp-alist |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
245 '(("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2" |
64725
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
246 1 3) |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
247 ;; 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
|
248 ;; produces them |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
249 ;; ("^\\(.+?\\)\\(:[ \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
|
250 ;; 1 3 (4 . 5)) |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
251 ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\ |
64509 | 252 \\(\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
|
253 2 3 |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
254 ;; 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
|
255 ((lambda () |
64509 | 256 (setq compilation-error-screen-columns nil) |
257 (- (match-beginning 4) (match-end 1))) | |
56881
4be25baf31b5
(grep-highlight-matches): New defcustom.
Juri Linkov <juri@jurta.org>
parents:
56828
diff
changeset
|
258 . |
64509 | 259 (lambda () (- (match-end 5) (match-end 1) |
260 (- (match-end 4) (match-beginning 4))))) | |
63576
7c3d537469b0
(grep-regexp-alist): Use backreference at the
Juri Linkov <juri@jurta.org>
parents:
62160
diff
changeset
|
261 nil 1) |
64740
eeed7a7c1afa
(grep-regexp-alist): Set 5th arg `TYPE' to
Juri Linkov <juri@jurta.org>
parents:
64728
diff
changeset
|
262 ("^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
|
263 "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
|
264 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
265 (defvar grep-error "grep hit" |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
266 "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
|
267 |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
268 ;; 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
|
269 ;; 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
|
270 (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
|
271 "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
|
272 |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
273 (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
|
274 "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
|
275 |
58988
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
276 (defvar grep-match-face 'match |
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
277 "Face name to use for grep matches.") |
067d5dcfe531
(grep-match-face): New defvar.
Juri Linkov <juri@jurta.org>
parents:
58493
diff
changeset
|
278 |
64725
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
279 (defvar grep-context-face 'shadow |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
280 "Face name to use for grep context lines.") |
0344b299e9e6
(grep-regexp-alist): Replace complex regexp
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
281 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
282 (defvar grep-mode-font-lock-keywords |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
283 '(;; Command output lines. |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
284 ("^\\([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
|
285 (": \\(.+\\): \\(?: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
|
286 1 grep-error-face) |
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
287 ;; 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
|
288 ("^Grep[/a-zA-z]* started.*" |
65126
559a37c2f306
(grep, grep-mode): Make buffer-local variables
Juri Linkov <juri@jurta.org>
parents:
65056
diff
changeset
|
289 (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
|
290 ("^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
|
291 (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
|
292 (1 compilation-info-face nil t) |
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
293 (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
|
294 ("^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
|
295 (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
|
296 (1 grep-error-face) |
64944
c845f6151d83
(grep-mode-map): Add ellipsis to "Another grep".
Juri Linkov <juri@jurta.org>
parents:
64864
diff
changeset
|
297 (2 grep-error-face nil t)) |
64864
c474b6f22449
(grep-regexp-alist): Use `.+?' instead of `[^:\n]+'.
Juri Linkov <juri@jurta.org>
parents:
64740
diff
changeset
|
298 ("^.+?-[0-9]+-.*\n" (0 grep-context-face)) |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
299 ;; Highlight grep matches and delete markers |
64509 | 300 ("\\(\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
|
301 ;; 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
|
302 ;; 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
|
303 ;; 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
|
304 (2 (list 'face nil 'font-lock-face grep-match-face)) |
64509 | 305 ((lambda (bound)) |
57769
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
306 (progn |
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
307 ;; Delete markers with `replace-match' because it updates |
e663f6b659a6
(grep-regexp-alist): Move match highlighting
Juri Linkov <juri@jurta.org>
parents:
57043
diff
changeset
|
308 ;; 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
|
309 (replace-match "" t t nil 3) |
64509 | 310 (replace-match "" t t nil 1)))) |
311 ("\\(\033\\[[0-9;]*[mK]\\)" | |
312 ;; Delete all remaining escape sequences | |
313 ((lambda (bound)) | |
314 (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
|
315 "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
|
316 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
|
317 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
318 ;;;###autoload |
76966
e1190fd4a1f2
(grep-program): Remove commentary about zgrep.
Kim F. Storm <storm@cua.dk>
parents:
76455
diff
changeset
|
319 (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
|
320 "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
|
321 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
|
322 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
323 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
324 (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
|
325 "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
|
326 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
|
327 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
328 ;;;###autoload |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
329 (defvar xargs-program "xargs" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
330 "The default xargs program for `grep-find-command'. |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
331 See `grep-find-use-xargs'. |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
332 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
|
333 |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
334 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
335 (defvar grep-find-use-xargs nil |
77033
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
336 "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
|
337 If `exec', use `find -exec'. |
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
338 If `gnu', use `find -print0' and `xargs -0'. |
25b4502cd0b4
(grep-find-use-xargs): Rewrite docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
76966
diff
changeset
|
339 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
|
340 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
341 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
|
342 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
343 ;; History of grep commands. |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
344 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
345 (defvar grep-history nil) |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
346 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
347 (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
|
348 |
70258 | 349 ;; History of lgrep and rgrep regexp and files args. |
350 (defvar grep-regexp-history nil) | |
351 (defvar grep-files-history '("ch" "el")) | |
352 | |
81972
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
353 (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
|
354 "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
|
355 `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
|
356 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
|
357 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
|
358 to avoid computing them again.") |
70258 | 359 |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
360 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
361 (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
|
362 "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
|
363 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
|
364 (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
|
365 (grep-compute-defaults)) |
84482ed458f2
(grep-highlight-matches): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
56948
diff
changeset
|
366 (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
|
367 ;; `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
|
368 ;; 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
|
369 (setenv "TERM" "emacs-grep") |
29047758dd89
(grep-process-setup): Set envvar "TERM" to "emacs-grep".
Juri Linkov <juri@jurta.org>
parents:
86249
diff
changeset
|
370 ;; `--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
|
371 ;; 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
|
372 ;; 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
|
373 (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
|
374 ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions |
64509 | 375 (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
|
376 ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions |
64509 | 377 (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
|
378 (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
|
379 (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
|
380 (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
|
381 (cond ((zerop code) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
382 '("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
|
383 ((= code 1) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
384 '("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
|
385 (t |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
386 (cons msg code))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
387 (cons msg code)))) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
388 (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
|
389 |
70258 | 390 (defun grep-probe (command args &optional func result) |
391 (equal (condition-case nil | |
81936
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
392 (apply (or func 'process-file) command args) |
70258 | 393 (error nil)) |
394 (or result 0))) | |
395 | |
56333
eb4bc9a65835
(grep-compute-defaults, grep-command)
Eli Zaretskii <eliz@gnu.org>
parents:
56226
diff
changeset
|
396 ;;;###autoload |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
397 (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
|
398 ;; Keep default values. |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
399 (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
|
400 (add-to-list |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
401 'grep-host-defaults-alist |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
402 (cons nil |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
403 `((grep-command ,grep-command) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
404 (grep-template ,grep-template) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
405 (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
|
406 (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
|
407 (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
|
408 (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
|
409 (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
|
410 (let* ((host-id |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
411 (intern (or (file-remote-p default-directory 'host) "localhost"))) |
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
412 (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
|
413 (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
|
414 ;; 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
|
415 ;; 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
|
416 (setq grep-command |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
417 (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
|
418 (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
|
419 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
420 grep-template |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
421 (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
|
422 (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
|
423 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
424 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
|
425 (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
|
426 (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
|
427 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
428 grep-find-command |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
429 (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
|
430 (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
|
431 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
432 grep-find-template |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
433 (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
|
434 (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
|
435 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
436 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
|
437 (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
|
438 (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
|
439 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
440 grep-highlight-matches |
82031
73ba7647c960
* progmodes/grep.el (grep-compute-defaults): Keep default values.
Michael Albinus <michael.albinus@gmx.de>
parents:
81972
diff
changeset
|
441 (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
|
442 (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
|
443 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
444 (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
|
445 (setq grep-use-null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
446 (with-temp-buffer |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
447 (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
|
448 (not |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
449 (and (if grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
450 ;; `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
|
451 ;; use that for testing. |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
452 (grep-probe grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
453 `(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
|
454 #'call-process-shell-command) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
455 ;; otherwise use `grep-program' |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
456 (grep-probe grep-program |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
457 `(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
|
458 (progn |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
459 (goto-char (point-min)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
460 (looking-at |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
461 (concat (regexp-quote hello-file) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
462 ":[0-9]+:English"))))))))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
463 (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
|
464 grep-template grep-find-template) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
465 (let ((grep-options |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
466 (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
|
467 (if (grep-probe grep-program |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
468 `(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
|
469 nil 1) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
470 " -e")))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
471 (unless grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
472 (setq grep-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
473 (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
|
474 (unless grep-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
475 (setq grep-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
476 (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
|
477 (unless grep-find-use-xargs |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
478 (setq grep-find-use-xargs |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
479 (cond |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
480 ((and |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
481 (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
|
482 (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
|
483 'gnu) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
484 (t |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
485 'exec)))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
486 (unless grep-find-command |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
487 (setq grep-find-command |
70258 | 488 (cond ((eq grep-find-use-xargs 'gnu) |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
489 (format "%s . -type f -print0 | %s -0 -e %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
490 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
|
491 ((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
|
492 (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
|
493 find-program grep-command))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
494 (cons |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
495 (format "%s {} %s %s" |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
496 cmd0 null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
497 (shell-quote-argument ";")) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
498 (1+ (length cmd0))))) |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
499 (t |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
500 (format "%s . -type f -print | %s %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
501 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
|
502 (unless grep-find-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
503 (setq grep-find-template |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
504 (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
|
505 grep-program grep-options))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
506 (cond ((eq grep-find-use-xargs 'gnu) |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
507 (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
|
508 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
|
509 ((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
|
510 (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
|
511 find-program gcmd null-device |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
512 (shell-quote-argument ";"))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
513 (t |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
514 (format "%s . <X> -type f <F> -print | %s %s" |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
515 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
|
516 (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
|
517 (setq grep-highlight-matches |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
518 (with-temp-buffer |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
519 (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
|
520 (progn |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
521 (goto-char (point-min)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
522 (search-forward "--color" nil t)) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
523 t)))) |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
524 |
64c6efb87c40
* progmodes/grep.el (grep-probe): Use `process-file'.
Michael Albinus <michael.albinus@gmx.de>
parents:
77033
diff
changeset
|
525 ;; 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
|
526 (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
|
527 (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
|
528 grep-host-defaults-alist)) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
529 (add-to-list |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
530 'grep-host-defaults-alist |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
531 (cons host-id |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
532 `((grep-command ,grep-command) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
533 (grep-template ,grep-template) |
7447c9b7efeb
* progmodes/grep.el (grep-host-defaults-alist): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
81936
diff
changeset
|
534 (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
|
535 (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
|
536 (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
|
537 (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
|
538 (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
|
539 |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
540 (defun grep-tag-default () |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
541 (or (and transient-mark-mode mark-active |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
542 (/= (point) (mark)) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
543 (buffer-substring-no-properties (point) (mark))) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
544 (funcall (or find-tag-default-function |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
545 (get major-mode 'find-tag-default-function) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
546 'find-tag-default)) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
547 "")) |
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
548 |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
549 (defun grep-default-command () |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
550 "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
|
551 (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
|
552 ;; 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
|
553 ;; 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
|
554 (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
|
555 (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
|
556 ;; 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
|
557 (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
|
558 (concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*" |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
559 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
|
560 grep-default) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
561 ;; 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
|
562 (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
|
563 ;; 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
|
564 ;; 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
|
565 (condition-case nil |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
566 (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
|
567 (when (match-beginning 2) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
568 (save-match-data |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
569 (string-match |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
570 (wildcard-to-regexp |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
571 (file-name-nondirectory |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
572 (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
|
573 (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
|
574 (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
|
575 0 (match-beginning 2)) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
576 " *." |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
577 (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
|
578 ;; 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
|
579 ;; from invalid data. |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
580 (error nil)) |
691a901b4418
(grep-default-command): Catch errors from wildcard-to-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
72165
diff
changeset
|
581 ;; 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
|
582 (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
|
583 |
54372
a4d3c17f991f
(kill-grep): Move here from compile.el
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54012
diff
changeset
|
584 |
64509 | 585 ;;;###autoload |
55018 | 586 (define-compilation-mode grep-mode "Grep" |
587 "Sets `grep-last-buffer' and `compilation-window-height'." | |
588 (setq grep-last-buffer (current-buffer)) | |
589 (set (make-local-variable 'compilation-error-face) | |
590 grep-hit-face) | |
591 (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
|
592 grep-regexp-alist) |
65126
559a37c2f306
(grep, grep-mode): Make buffer-local variables
Juri Linkov <juri@jurta.org>
parents:
65056
diff
changeset
|
593 (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
|
594 '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
|
595 (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
|
596 |
70258 | 597 |
598 ;;;###autoload | |
599 (defun grep (command-args) | |
600 "Run grep, with user-specified args, and collect output in a buffer. | |
601 While grep runs asynchronously, you can use \\[next-error] (M-x next-error), | |
602 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
|
603 output buffer, to go to the lines where grep |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
604 found matches. |
70258 | 605 |
75803
81c369551691
(grep): Mention lgrep and rgrep in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
75347
diff
changeset
|
606 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
|
607 `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
|
608 |
86249
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
609 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
|
610 can easily repeat a grep command. |
70258 | 611 |
612 A prefix argument says to default the argument based upon the current | |
613 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
|
614 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
|
615 list is empty)." |
70258 | 616 (interactive |
617 (progn | |
618 (grep-compute-defaults) | |
619 (let ((default (grep-default-command))) | |
620 (list (read-from-minibuffer "Run grep (like this): " | |
621 (if current-prefix-arg | |
622 default grep-command) | |
623 nil nil 'grep-history | |
624 (if current-prefix-arg nil default)))))) | |
625 | |
626 ;; Setting process-setup-function makes exit-message-function work | |
627 ;; even when async processes aren't supported. | |
628 (compilation-start (if (and grep-use-null-device null-device) | |
629 (concat command-args " " null-device) | |
630 command-args) | |
631 'grep-mode)) | |
632 | |
633 | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
634 ;;;###autoload |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
635 (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
|
636 "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
|
637 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
|
638 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
|
639 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
|
640 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
641 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
|
642 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
|
643 (interactive |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
644 (progn |
70258 | 645 (grep-compute-defaults) |
53750
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
646 (if grep-find-command |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
647 (list (read-from-minibuffer "Run find (like this): " |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
648 grep-find-command nil nil |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
649 'grep-find-history)) |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
650 ;; No default was set |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
651 (read-string |
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
652 "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
|
653 (list nil)))) |
70712
070ab453b31f
(grep-find): Don't check grep-find-command
Kim F. Storm <storm@cua.dk>
parents:
70534
diff
changeset
|
654 (when command-args |
53750
4deb14fde58c
(grep-compute-defaults): Use executable-command-find-posix-p.
Richard M. Stallman <rms@gnu.org>
parents:
53486
diff
changeset
|
655 (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
|
656 (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
|
657 |
59688
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
658 ;;;###autoload |
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
659 (defalias 'find-grep 'grep-find) |
3761d1e2619d
* NEWS: Mention alias `find-grep' for `grep-find'.
David Kastrup <dak@gnu.org>
parents:
59605
diff
changeset
|
660 |
70258 | 661 |
662 ;; User-friendly interactive API. | |
663 | |
664 (defconst grep-expand-keywords | |
665 '(("<C>" . (and cf (isearch-no-upper-case-p regexp t) "-i")) | |
666 ("<D>" . dir) | |
667 ("<F>" . files) | |
668 ("<N>" . null-device) | |
669 ("<X>" . excl) | |
670 ("<R>" . (shell-quote-argument (or regexp "")))) | |
671 "List of substitutions performed by `grep-expand-template'. | |
672 If car of an element matches, the cdr is evalled in to get the | |
673 substitution string. Note dynamic scoping of variables.") | |
674 | |
675 (defun grep-expand-template (template &optional regexp files dir excl) | |
676 "Patch grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>." | |
677 (let ((command template) | |
678 (cf case-fold-search) | |
679 (case-fold-search nil)) | |
680 (dolist (kw grep-expand-keywords command) | |
681 (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
|
682 (setq command |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
683 (replace-match |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
684 (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
|
685 (symbol-value (cdr kw)) |
70315
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
686 (save-match-data (eval (cdr kw)))) |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
687 "") |
cf0d76a2f0c7
(grep-expand-template): Use save-match-data.
Kim F. Storm <storm@cua.dk>
parents:
70259
diff
changeset
|
688 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
|
689 |
70258 | 690 (defun grep-read-regexp () |
691 "Read regexp arg for interactive grep." | |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
692 (let ((default (grep-tag-default))) |
70258 | 693 (read-string |
694 (concat "Search for" | |
695 (if (and default (> (length default) 0)) | |
72163
bca9d3121eef
(grep-tag-default): New function.
Kim F. Storm <storm@cua.dk>
parents:
72024
diff
changeset
|
696 (format " (default \"%s\"): " default) ": ")) |
70258 | 697 nil 'grep-regexp-history default))) |
698 | |
699 (defun grep-read-files (regexp) | |
700 "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
|
701 (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
|
702 (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
|
703 (stringp bn) |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
704 (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
|
705 (default |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
706 (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
|
707 (let ((aliases grep-files-aliases) |
70258 | 708 alias) |
709 (while aliases | |
710 (setq alias (car aliases) | |
711 aliases (cdr aliases)) | |
712 (if (string-match (wildcard-to-regexp (cdr alias)) fn) | |
713 (setq aliases nil) | |
714 (setq alias nil))) | |
715 (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
|
716 (and fn |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
717 (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
|
718 (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
|
719 (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
|
720 (car (car grep-files-aliases)))) |
70258 | 721 (files (read-string |
722 (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
|
723 "\" in files" |
58edc69a1813
(grep-read-files): Use buffer-name if no buffer-file-name.
Kim F. Storm <storm@cua.dk>
parents:
70258
diff
changeset
|
724 (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
|
725 ": ") |
70258 | 726 nil 'grep-files-history default))) |
727 (and files | |
728 (or (cdr (assoc files grep-files-aliases)) | |
729 files)))) | |
53139
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
730 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
731 ;;;###autoload |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
732 (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
|
733 "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
|
734 The search is limited to file names matching shell pattern FILES. |
70258 | 735 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
|
736 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
|
737 |
70526 | 738 With \\[universal-argument] prefix, you can edit the constructed shell command line |
739 before it is executed. | |
740 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
|
741 |
70258 | 742 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
|
743 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
|
744 in the grep output buffer, |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
745 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
|
746 |
70258 | 747 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
|
748 (interactive |
70258 | 749 (progn |
750 (grep-compute-defaults) | |
751 (cond | |
752 ((and grep-command (equal current-prefix-arg '(16))) | |
753 (list (read-from-minibuffer "Run: " grep-command | |
754 nil nil 'grep-history) | |
755 nil)) | |
756 ((not grep-template) | |
757 (list nil | |
758 (read-string "grep.el: No `grep-template' available. Press RET."))) | |
759 (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
|
760 (files (grep-read-files regexp)) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
761 (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
|
762 nil default-directory t))) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
763 (list regexp files dir)))))) |
70258 | 764 (when (and (stringp regexp) (> (length regexp) 0)) |
765 (let ((command regexp)) | |
766 (if (null files) | |
767 (if (string= command grep-command) | |
768 (setq command nil)) | |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
769 (setq dir (file-name-as-directory (expand-file-name dir))) |
70258 | 770 (setq command (grep-expand-template |
771 grep-template | |
772 regexp | |
773 files)) | |
774 (when command | |
775 (if (equal current-prefix-arg '(4)) | |
776 (setq command | |
777 (read-from-minibuffer "Confirm: " | |
778 command nil nil 'grep-history)) | |
70421
47fe68ac1971
(lgrep, rgrep): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
70340
diff
changeset
|
779 (add-to-history 'grep-history command)))) |
70258 | 780 (when command |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
781 (let ((default-directory dir)) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
782 ;; 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
|
783 ;; 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
|
784 (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
|
785 (concat command " " null-device) |
82421 | 786 command) |
787 'grep-mode)) | |
75877
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
788 (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
|
789 (setq default-directory dir)))))) |
9ba96fd63815
(grep-files-aliases): Add tex and texi aliases.
Kim F. Storm <storm@cua.dk>
parents:
75803
diff
changeset
|
790 |
70258 | 791 |
87560
62e8690b9f1a
(find-name-arg): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87523
diff
changeset
|
792 (defvar find-name-arg) ; autoloaded |
70258 | 793 |
794 ;;;###autoload | |
795 (defun rgrep (regexp &optional files dir) | |
70526 | 796 "Recursively grep for REGEXP in FILES in directory tree rooted at DIR. |
70258 | 797 The search is limited to file names matching shell pattern FILES. |
798 FILES may use abbreviations defined in `grep-files-aliases', e.g. | |
799 entering `ch' is equivalent to `*.[ch]'. | |
800 | |
70526 | 801 With \\[universal-argument] prefix, you can edit the constructed shell command line |
802 before it is executed. | |
803 With two \\[universal-argument] prefixes, directly edit and run `grep-find-command'. | |
70258 | 804 |
805 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
|
806 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
|
807 in the grep output buffer, |
ef17406635fe
(xargs-program): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
83780
diff
changeset
|
808 to go to the lines where grep found matches. |
70258 | 809 |
810 This command shares argument histories with \\[lgrep] and \\[grep-find]." | |
811 (interactive | |
812 (progn | |
813 (grep-compute-defaults) | |
814 (cond | |
815 ((and grep-find-command (equal current-prefix-arg '(16))) | |
816 (list (read-from-minibuffer "Run: " grep-find-command | |
817 nil nil 'grep-find-history) | |
818 nil)) | |
819 ((not grep-find-template) | |
820 (list nil nil | |
821 (read-string "grep.el: No `grep-find-template' available. Press RET."))) | |
822 (t (let* ((regexp (grep-read-regexp)) | |
823 (files (grep-read-files regexp)) | |
824 (dir (read-directory-name "Base directory: " | |
825 nil default-directory t))) | |
826 (list regexp files dir)))))) | |
827 (when (and (stringp regexp) (> (length regexp) 0)) | |
828 (if (null files) | |
829 (if (not (string= regexp grep-find-command)) | |
830 (compilation-start regexp 'grep-mode)) | |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
831 (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
|
832 (let ((command (grep-expand-template |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
833 grep-find-template |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
834 regexp |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
835 (concat (shell-quote-argument "(") |
79589
05774558f6e1
(rgrep): Use find-name-arg.
Jason Rumney <jasonr@gnu.org>
parents:
78234
diff
changeset
|
836 " " find-name-arg " " |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
837 (mapconcat #'shell-quote-argument |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
838 (split-string files) |
79643
078fe4baaf42
(rgrep): Fix last change.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79589
diff
changeset
|
839 (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
|
840 " " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
841 (shell-quote-argument ")")) |
70534
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
842 dir |
70258 | 843 (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
|
844 (concat (shell-quote-argument "(") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
845 ;; 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
|
846 " -path " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
847 (mapconcat #'(lambda (dir) |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
848 (shell-quote-argument |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
849 (concat "*/" dir))) |
70258 | 850 grep-find-ignored-directories |
72500
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
851 " -o -path ") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
852 " " |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
853 (shell-quote-argument ")") |
35e43fe3d8ef
(grep-find-use-xargs): Use explicit value `exec'
Kim F. Storm <storm@cua.dk>
parents:
72173
diff
changeset
|
854 " -prune -o "))))) |
70258 | 855 (when command |
856 (if current-prefix-arg | |
857 (setq command | |
858 (read-from-minibuffer "Confirm: " | |
859 command nil nil 'grep-find-history)) | |
70421
47fe68ac1971
(lgrep, rgrep): Use add-to-history.
Kim F. Storm <storm@cua.dk>
parents:
70340
diff
changeset
|
860 (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
|
861 (let ((default-directory dir)) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
862 (compilation-start command 'grep-mode)) |
afe3317800c2
(rgrep): Set default directory of *grep*
Kim F. Storm <storm@cua.dk>
parents:
70526
diff
changeset
|
863 ;; 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
|
864 (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
|
865 (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
|
866 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
867 |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
868 (provide 'grep) |
df3033332097
* progmodes/grep.el: New file with grep code from compile.el.
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
869 |
57043
cb013e5835b8
(grep-mode): Remove unnecessary autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57022
diff
changeset
|
870 ;; 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
|
871 ;;; grep.el ends here |