forked from lexdene/grep-at-point
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grep-at-point.el
44 lines (39 loc) · 977 Bytes
/
grep-at-point.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
; 在工作目录下的所有文件中搜索当前光标下的单词
; 其原理只是将grep和thingatpt简单地结合一下
(provide 'grep-at-point)
(require 'thingatpt)
(defun grep-at-point (directory word extname)
"grep the current word"
(interactive
(let (
(origin-word (thing-at-point 'symbol)))
(list
(read-file-name "grep directory: " default-directory default-directory)
(read-from-minibuffer "grep word: " origin-word)
(read-from-minibuffer
"file ext: "
(default-file-pattern)
)
)
)
)
(grep
(format
"cd %s && grep -nH -r '%s' . --include=\"%s\""
directory
word
extname
)
))
(defun nopromp-grep-at-point ()
"grep the current word without promp"
(interactive)
(grep-at-point
(getenv "PWD")
(thing-at-point 'symbol)
(default-file-pattern)
)
)
(defun default-file-pattern ()
"*.ext"
(concat "*." (file-name-extension (buffer-file-name))))