aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-04-12 15:38:06 -0400
committerStefan Monnier2014-04-12 15:38:06 -0400
commitf7993853c2512d2cb8067c37ea01db4175e37be3 (patch)
tree58202d1d1cc6b4211b25cec5f1a0153f79b48191
parent6c2453e03861069fc1d891ecd8957545a8044bd9 (diff)
downloademacs-f7993853c2512d2cb8067c37ea01db4175e37be3.tar.gz
emacs-f7993853c2512d2cb8067c37ea01db4175e37be3.zip
* lisp/progmodes/grep.el: Use lexical-binding.
(grep-expand-template): Pass explicit lexical env to `eval'. (zrgrep): Let-bind grep-find-template explicitly.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/grep.el24
2 files changed, 19 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5b221ed994c..fd433562d0e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12014-04-12 Stefan Monnier <monnier@iro.umontreal.ca> 12014-04-12 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/grep.el: Use lexical-binding.
4 (grep-expand-template): Pass explicit lexical env to `eval'.
5 (zrgrep): Let-bind grep-find-template explicitly.
6
3 * emacs-lisp/cl-lib.el (current-case-table): Remove setter. 7 * emacs-lisp/cl-lib.el (current-case-table): Remove setter.
4 * leim/quail/sisheng.el (sisheng-list): Use with-case-table. 8 * leim/quail/sisheng.el (sisheng-list): Use with-case-table.
5 9
@@ -29,8 +33,8 @@
29 33
302014-04-12 Matthias Dahl <matthias.dahl@binary-island.eu> 342014-04-12 Matthias Dahl <matthias.dahl@binary-island.eu>
31 35
32 * faces.el (make-face): Remove deprecated optional argument. The 36 * faces.el (make-face): Remove deprecated optional argument.
33 conditional application of X resources is handled directly by 37 The conditional application of X resources is handled directly by
34 make-face-x-resource-internal since Emacs 24.4. 38 make-face-x-resource-internal since Emacs 24.4.
35 (make-empty-face): Don't pass optional argument to make-face. 39 (make-empty-face): Don't pass optional argument to make-face.
36 40
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 99629450c1b..181c5e5dba5 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -1,4 +1,4 @@
1;;; grep.el --- run `grep' and display the results 1;;; grep.el --- run `grep' and display the results -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1985-1987, 1993-1999, 2001-2014 Free Software 3;; Copyright (C) 1985-1987, 1993-1999, 2001-2014 Free Software
4;; Foundation, Inc. 4;; Foundation, Inc.
@@ -805,16 +805,20 @@ substitution string. Note dynamic scoping of variables.")
805 805
806(defun grep-expand-template (template &optional regexp files dir excl) 806(defun grep-expand-template (template &optional regexp files dir excl)
807 "Patch grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>." 807 "Patch grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>."
808 (let ((command template) 808 (let* ((command template)
809 (cf case-fold-search) 809 (env `((cf . ,case-fold-search)
810 (case-fold-search nil)) 810 (excl . ,excl)
811 (dir . ,dir)
812 (files . ,files)
813 (regexp . ,regexp)))
814 (case-fold-search nil))
811 (dolist (kw grep-expand-keywords command) 815 (dolist (kw grep-expand-keywords command)
812 (if (string-match (car kw) command) 816 (if (string-match (car kw) command)
813 (setq command 817 (setq command
814 (replace-match 818 (replace-match
815 (or (if (symbolp (cdr kw)) 819 (or (if (symbolp (cdr kw))
816 (symbol-value (cdr kw)) 820 (eval (cdr kw) env)
817 (save-match-data (eval (cdr kw)))) 821 (save-match-data (eval (cdr kw) env)))
818 "") 822 "")
819 t t command)))))) 823 t t command))))))
820 824
@@ -1055,7 +1059,7 @@ to specify a command to run."
1055 (setq default-directory dir))))))) 1059 (setq default-directory dir)))))))
1056 1060
1057;;;###autoload 1061;;;###autoload
1058(defun zrgrep (regexp &optional files dir confirm grep-find-template) 1062(defun zrgrep (regexp &optional files dir confirm template)
1059 "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR. 1063 "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.
1060Like `rgrep' but uses `zgrep' for `grep-program', sets the default 1064Like `rgrep' but uses `zgrep' for `grep-program', sets the default
1061file name to `*.gz', and sets `grep-highlight-matches' to `always'." 1065file name to `*.gz', and sets `grep-highlight-matches' to `always'."
@@ -1090,10 +1094,8 @@ file name to `*.gz', and sets `grep-highlight-matches' to `always'."
1090 (list regexp files dir confirm grep-find-template))))))) 1094 (list regexp files dir confirm grep-find-template)))))))
1091 ;; Set `grep-highlight-matches' to `always' 1095 ;; Set `grep-highlight-matches' to `always'
1092 ;; since `zgrep' puts filters in the grep output. 1096 ;; since `zgrep' puts filters in the grep output.
1093 (let ((grep-highlight-matches 'always)) 1097 (let ((grep-find-template template)
1094 ;; `rgrep' uses the dynamically bound value `grep-find-template' 1098 (grep-highlight-matches 'always))
1095 ;; from the argument `grep-find-template' whose value is computed
1096 ;; in the `interactive' spec.
1097 (rgrep regexp files dir confirm))) 1099 (rgrep regexp files dir confirm)))
1098 1100
1099;;;###autoload 1101;;;###autoload