7
7
; ; Description: Incremental search through the whole project.
8
8
; ; Keyword: convenience, search
9
9
; ; Version: 0.2.3
10
- ; ; Package-Requires: ((emacs "26.1") (cl-lib "0.6") ( f "0.20.0"))
10
+ ; ; Package-Requires: ((emacs "26.1") (f "0.20.0"))
11
11
; ; URL: https://github.com/jcs090218/isearch-project
12
12
13
13
; ; This file is NOT part of GNU Emacs.
71
71
(defvar isearch-project--thing-at-point " "
72
72
" Record down the symbol while executing `isearch-project-forward-symbol-at-point' command." )
73
73
74
+ ; ;; Util
74
75
75
76
(defun isearch-project--flatten-list (l )
76
77
" Flatten the multiple dimensional array, L to one dimensonal array.
@@ -81,36 +82,29 @@ For instance,
81
82
(t (loop for a in l appending (isearch-project--flatten-list a)))))
82
83
83
84
(defun isearch-project--is-contain-list-string (in-list in-str )
84
- " Check if a string contain in any string in the string list.
85
- IN-LIST : list of string use to check if IN-STR in contain one of
86
- the string.
87
- IN-STR : string using to check if is contain one of the IN-LIST."
85
+ " Check if IN-STR contain in any string in the IN-LIST."
88
86
(cl-some #' (lambda (lb-sub-str ) (string-match-p (regexp-quote lb-sub-str) in-str)) in-list))
89
87
90
- (defun isearch-project--remove-nth-element (n lst )
91
- " Remove nth element from the list.
92
- N : nth element you want to remove from the list.
93
- LST : List you want to modified."
94
- (if (zerop n)
88
+ (defun isearch-project--remove-nth-element (nth lst )
89
+ " Remove NTH element from the LST and return the list."
90
+ (if (zerop nth )
95
91
(cdr lst)
96
- (let ((last (nthcdr (1- n ) lst)))
92
+ (let ((last (nthcdr (1- nth ) lst)))
97
93
(setcdr last (cddr last ))
98
94
lst)))
99
95
100
96
(defun isearch-project--contain-string (in-sub-str in-str )
101
- " Check if a string is a substring of another string.
102
- Return true if contain, else return false.
103
- IN-SUB-STR : substring to see if contain in the IN-STR.
104
- IN-STR : string to check by the IN-SUB-STR."
97
+ " Check if the IN-SUB-STR is a string in IN-STR."
105
98
(string-match-p in-sub-str in-str))
106
99
107
- (defun isearch-project--get-string-from-file (filePath )
108
- " Return filePath's file content.
109
- FILEPATH : file path."
100
+ (defun isearch-project--get-string-from-file (path )
101
+ " Return PATH file content."
110
102
(with-temp-buffer
111
- (insert-file-contents filePath )
103
+ (insert-file-contents path )
112
104
(buffer-string )))
113
105
106
+ ; ;; Core
107
+
114
108
(defun isearch-project--f-directories-ignore-directories (path &optional rec )
115
109
" Find all directories in PATH by ignored common directories with FN and REC."
116
110
(let ((dirs (f-directories path))
@@ -139,7 +133,7 @@ FILEPATH : file path."
139
133
(push (f-files dir fn) files ))
140
134
(isearch-project--flatten-list (reverse files ))))
141
135
142
- (defun isearch-project-prepare ()
136
+ (defun isearch-project-- prepare ()
143
137
" Incremental search preparation."
144
138
(let ((prepare-success nil ))
145
139
(setq isearch-project--project-dir (cdr (project-current )))
@@ -167,7 +161,7 @@ FILEPATH : file path."
167
161
(defun isearch-project-forward ()
168
162
" Incremental search forward in the project."
169
163
(interactive )
170
- (if (isearch-project-prepare)
164
+ (if (isearch-project-- prepare)
171
165
(progn
172
166
(isearch-project--add-advices)
173
167
(isearch-forward )
@@ -176,13 +170,13 @@ FILEPATH : file path."
176
170
177
171
(defun isearch-project--add-advices ()
178
172
" Add all needed advices."
179
- (advice-add 'isearch-repeat :after #'isearch-project-advice-isearch-repeat-after ))
173
+ (advice-add 'isearch-repeat :after #'isearch-project-- advice-isearch-repeat-after ))
180
174
181
175
(defun isearch-project--remove-advices ()
182
176
" Remove all needed advices."
183
- (advice-remove 'isearch-repeat #'isearch-project-advice-isearch-repeat-after ))
177
+ (advice-remove 'isearch-repeat #'isearch-project-- advice-isearch-repeat-after ))
184
178
185
- (defun isearch-project-find-file-search (fn dt )
179
+ (defun isearch-project-- find-file-search (fn dt )
186
180
" Open a file and isearch.
187
181
If found, leave it. If not found, try find the next file.
188
182
FN : file to search.
@@ -197,8 +191,7 @@ DT : search direction."
197
191
('forward (isearch-repeat-forward ))
198
192
('backward (isearch-repeat-backward )))))
199
193
200
-
201
- (defun isearch-project-advice-isearch-repeat-after (dt &optional cnt )
194
+ (defun isearch-project--advice-isearch-repeat-after (dt &optional cnt )
202
195
" Advice for `isearch-repeat-backward' and `isearch-repeat-forward' command.
203
196
DT : search direction.
204
197
CNT : search count."
@@ -246,7 +239,7 @@ CNT : search count."
246
239
(when (<= search-cnt 0 ) (setq break-it t )))))
247
240
248
241
; ; Open the file.
249
- (isearch-project-find-file-search next-fn dt)
242
+ (isearch-project-- find-file-search next-fn dt)
250
243
251
244
; ; Update current file index.
252
245
(setq isearch-project--files-current-index next-file-index))))
@@ -269,6 +262,7 @@ SEARCH-STR : Search string."
269
262
(forward-char 1 ))
270
263
(forward-symbol -1 )
271
264
(isearch-project--isearch-yank-string isearch-project--thing-at-point)))))
265
+
272
266
(add-hook 'isearch-mode-hook #'isearch-project--isearch-mode-hook )
273
267
274
268
(provide 'isearch-project )
0 commit comments