Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 444 lines (377 sloc) 16.115 kb
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
1 ;;; helm-regexp.el --- In buffer regexp searching and replacement for helm.
2
3 ;; Copyright (C) 2012 Thierry Volpiatto <thierry.volpiatto@gmail.com>
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Code:
19
20 (require 'cl)
21 (require 'helm)
ba17f09 @thierryvolpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
22 (require 'helm-utils)
23
24
25 (defgroup helm-regexp nil
26 "Regexp related Applications and libraries for Helm."
27 :group 'helm)
28
29 (defcustom helm-c-browse-code-regexp-lisp
30 "^ *\(def\\(un\\|subst\\|macro\\|face\\|alias\\|advice\\|struct\\|\
31 type\\|theme\\|var\\|group\\|custom\\|const\\|method\\|class\\)"
32 "Regexp used to parse lisp buffer when browsing code."
33 :type 'string
34 :group 'helm-regexp)
35
36 (defcustom helm-c-browse-code-regexp-python
37 "\\<def\\>\\|\\<class\\>"
38 "Regexp used to parse python buffer when browsing code."
39 :type 'string
40 :group 'helm-regexp)
41
42 (defcustom helm-c-browse-code-regexp-alist
43 `((lisp-interaction-mode . ,helm-c-browse-code-regexp-lisp)
44 (emacs-lisp-mode . ,helm-c-browse-code-regexp-lisp)
45 (lisp-mode . ,helm-c-browse-code-regexp-lisp)
46 (python-mode . ,helm-c-browse-code-regexp-python))
47 "Alist to store regexps for browsing code corresponding \
48 to a specific `major-mode'."
d079fc3 @thierryvolpiatto Issue #95 Fix defcustoms in various places.
thierryvolpiatto authored
49 :type '(alist :key-type symbol :value-type regexp)
ba17f09 @thierryvolpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
50 :group 'helm-regexp)
c3fb0f0 @thierryvolpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
51
6e49004 @thierryvolpiatto * helm-regexp.el (helm-moccur-always-search-in-current): Default to nil.
thierryvolpiatto authored
52 (defcustom helm-moccur-always-search-in-current nil
c3fb0f0 @thierryvolpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
53 "Helm multi occur always search in current buffer when non--nil."
54 :group 'helm-regexp
55 :type 'boolean)
56
2ae89f4 helm-m-occur-idle-delay inherits from helm-idle-delay
Le Wang authored
57 (defcustom helm-m-occur-idle-delay helm-idle-delay
fb3195d @thierryvolpiatto * helm.el (helm-update): Allow giving an in-source value to delayed attr...
thierryvolpiatto authored
58 "Delay before updating display in `helm-c-source-moccur'.
75e2a0e @thierryvolpiatto * helm-regexp.el (helm-occur-init-source): new
thierryvolpiatto authored
59 It is similar to `helm-idle-delay' but local to `helm-c-source-moccur'.
60 This setting apply also to `helm-c-source-occur'."
fb3195d @thierryvolpiatto * helm.el (helm-update): Allow giving an in-source value to delayed attr...
thierryvolpiatto authored
61 :group 'helm-regexp
62 :type 'float)
63
f167a01 @thierryvolpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
64 (defcustom helm-m-occur-use-ioccur-style-keys t
65 "Similar to `helm-c-grep-use-ioccur-style-keys' but for multi occur."
66 :group 'helm-regexp
67 :type 'boolean)
68
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
69
70 (defface helm-moccur-buffer
71 '((t (:foreground "DarkTurquoise" :underline t)))
72 "Face used to highlight moccur buffer names."
73 :group 'helm-regexp)
ba17f09 @thierryvolpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
74
75
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
76 (defvar helm-c-moccur-map
77 (let ((map (make-sparse-keymap)))
78 (set-keymap-parent map helm-map)
79 (define-key map (kbd "M-<down>") 'helm-c-goto-next-file)
80 (define-key map (kbd "M-<up>") 'helm-c-goto-precedent-file)
81 (define-key map (kbd "C-w") 'helm-yank-text-at-point)
b3194af @thierryvolpiatto Add help for moccur.
thierryvolpiatto authored
82 (define-key map (kbd "C-c ?") 'helm-moccur-help)
f167a01 @thierryvolpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
83 (when helm-m-occur-use-ioccur-style-keys
84 (define-key map (kbd "<right>") 'helm-m-occur-run-persistent-action)
85 (define-key map (kbd "<left>") 'helm-m-occur-run-default-action))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
86 (delq nil map))
87 "Keymap used in Moccur source.")
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
88
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
89
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
90 (defvar helm-build-regexp-history nil)
91 (defun helm-c-query-replace-regexp (candidate)
92 "Query replace regexp from `helm-regexp'.
93 With a prefix arg replace only matches surrounded by word boundaries,
94 i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b."
95 (let ((regexp (funcall (helm-attr 'regexp))))
96 (apply 'query-replace-regexp
97 (helm-c-query-replace-args regexp))))
98
99 (defun helm-c-kill-regexp-as-sexp (candidate)
100 "Kill regexp in a format usable in lisp code."
101 (helm-c-regexp-kill-new
102 (prin1-to-string (funcall (helm-attr 'regexp)))))
103
104 (defun helm-c-kill-regexp (candidate)
105 "Kill regexp as it is in `helm-pattern'."
106 (helm-c-regexp-kill-new (funcall (helm-attr 'regexp))))
107
108 (defun helm-c-query-replace-args (regexp)
109 "create arguments of `query-replace-regexp' action in `helm-regexp'."
110 (let ((region-only (helm-region-active-p)))
111 (list
112 regexp
113 (query-replace-read-to regexp
114 (format "Query replace %sregexp %s"
115 (if helm-current-prefix-arg "word " "")
116 (if region-only "in region " ""))
117 t)
118 helm-current-prefix-arg
119 (when region-only (region-beginning))
120 (when region-only (region-end)))))
121
122 (defvar helm-c-source-regexp
123 '((name . "Regexp Builder")
124 (init . (lambda ()
125 (helm-candidate-buffer helm-current-buffer)))
126 (candidates-in-buffer)
127 (get-line . helm-c-regexp-get-line)
128 (persistent-action . helm-c-regexp-persistent-action)
129 (persistent-help . "Show this line")
130 (multiline)
131 (delayed)
132 (requires-pattern . 2)
133 (mode-line . "Press TAB to select action.")
134 (regexp . (lambda () helm-input))
135 (action . (("Kill Regexp as sexp" . helm-c-kill-regexp-as-sexp)
136 ("Query Replace Regexp (C-u Not inside word.)"
137 . helm-c-query-replace-regexp)
138 ("Kill Regexp" . helm-c-kill-regexp)))))
139
140 (defun helm-c-regexp-get-line (s e)
141 (propertize
142 (apply 'concat
143 ;; Line contents
144 (format "%5d: %s" (line-number-at-pos (1- s)) (buffer-substring s e))
145 ;; subexps
146 (loop for i from 0 to (1- (/ (length (match-data)) 2))
147 collect (format "\n %s'%s'"
148 (if (zerop i) "Group 0: " (format "Group %d: " i))
149 (match-string i))))
150 ;; match beginning
151 ;; KLUDGE: point of helm-candidate-buffer is +1 than that of helm-current-buffer.
152 ;; It is implementation problem of candidates-in-buffer.
153 'helm-realvalue
154 (1- s)))
155
156 (defun helm-c-regexp-persistent-action (pt)
157 (helm-goto-char pt)
158 (helm-persistent-highlight-point))
159
160 (defun helm-c-regexp-kill-new (input)
161 (kill-new input)
162 (message "Killed: %s" input))
163
164 (defun helm-quote-whitespace (candidate)
165 "Quote whitespace, if some, in string CANDIDATE."
166 (replace-regexp-in-string " " "\\\\ " candidate))
167
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
168
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
169 ;;; Occur
170 ;;
171 ;;
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
172 (defvar helm-c-source-occur nil)
75e2a0e @thierryvolpiatto * helm-regexp.el (helm-occur-init-source): new
thierryvolpiatto authored
173 (defun helm-occur-init-source ()
174 (unless helm-c-source-occur
175 (setq helm-c-source-occur (copy-alist helm-c-source-moccur))))
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
176
f5d0706 @thierryvolpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
177
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
178 ;;; Multi occur
179 ;;
180 ;;
181 (defun helm-m-occur-init (buffers)
c3fb0f0 @thierryvolpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
182 "Create the initial helm multi occur buffer with BUFFERS list."
183 (when helm-moccur-always-search-in-current
184 (setq buffers (cons helm-current-buffer
185 (remove helm-current-buffer buffers))))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
186 (helm-init-candidates-in-buffer
c23a0af @thierryvolpiatto * helm.el (helm-init-candidates-in-buffer): Allow a symbol for BUFFER ar...
thierryvolpiatto authored
187 'global
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
188 (loop for buf in buffers
189 for bufstr = (with-current-buffer buf (buffer-string))
190 do (add-text-properties
191 0 (length bufstr)
192 `(buffer-name ,(buffer-name (get-buffer buf)))
193 bufstr)
194 concat bufstr)))
195
aaa5027 @thierryvolpiatto * helm-regexp.el (helm-m-occur-get-line): Don't recompute point-at-bol.
thierryvolpiatto authored
196 (defun helm-m-occur-get-line (beg end)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
197 "Format line for `helm-c-source-moccur'."
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
198 (format "%s:%d:%s"
aaa5027 @thierryvolpiatto * helm-regexp.el (helm-m-occur-get-line): Don't recompute point-at-bol.
thierryvolpiatto authored
199 (get-text-property beg 'buffer-name)
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
200 (save-restriction
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
201 (narrow-to-region (previous-single-property-change
202 (point) 'buffer-name)
203 (next-single-property-change
204 (point) 'buffer-name))
aaa5027 @thierryvolpiatto * helm-regexp.el (helm-m-occur-get-line): Don't recompute point-at-bol.
thierryvolpiatto authored
205 (line-number-at-pos beg))
206 (buffer-substring beg end)))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
207
208 (defun* helm-m-occur-action (candidate
209 &optional (method (quote buffer)))
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
210 "Jump to CANDIDATE with METHOD.
211 arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame."
c3fb0f0 @thierryvolpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
212 (require 'helm-grep)
213 (let* ((split (helm-c-grep-split-line candidate))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
214 (buf (car split))
215 (lineno (string-to-number (nth 1 split))))
216 (case method
217 (buffer (switch-to-buffer buf))
218 (buffer-other-window (switch-to-buffer-other-window buf))
219 (buffer-other-frame (switch-to-buffer-other-frame buf)))
e74a82f @thierryvolpiatto * helm-regexp.el (helm-m-occur-action): Issue #113 Go to first occurence...
thierryvolpiatto authored
220 (helm-goto-line lineno)
221 (when (re-search-forward helm-pattern (point-at-eol) t)
222 (goto-char (match-beginning 0)))))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
223
f167a01 @thierryvolpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
224 (defun helm-m-occur-persistent-action (candidate)
225 (helm-m-occur-goto-line candidate)
226 (helm-match-line-color-current-line))
227
228 (defun helm-m-occur-run-persistent-action ()
229 (interactive)
230 (when helm-alive-p
231 (helm-execute-persistent-action)))
232
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
233 (defun helm-m-occur-goto-line (candidate)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
234 "From multi occur, switch to buffer and go to nth 1 CANDIDATE line."
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
235 (helm-m-occur-action candidate))
236
f167a01 @thierryvolpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
237 (defun helm-m-occur-run-default-action ()
238 (interactive)
239 (helm-c-quit-and-execute-action 'helm-m-occur-goto-line))
240
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
241 (defvar helm-c-source-moccur
242 `((name . "Moccur")
243 (init . (lambda ()
2019cde @thierryvolpiatto * helm-regexp.el (helm-c-source-moccur): Require grep at init for keymap...
thierryvolpiatto authored
244 (require 'helm-grep)
517b729 @thierryvolpiatto * helm-regexp.el (helm-c-source-moccur): Update delayed attr when modify...
thierryvolpiatto authored
245 (helm-m-occur-init buffers)
246 (helm-attrset 'delayed helm-m-occur-idle-delay)))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
247 (candidates-in-buffer)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
248 (filtered-candidate-transformer . helm-m-occur-transformer)
249 (nohighlight)
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
250 (get-line . helm-m-occur-get-line)
bec9d22 @thierryvolpiatto Revert changes for migemo, add migemo attr to multi-occur.
thierryvolpiatto authored
251 (migemo)
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
252 (action . (("Go to Line" . helm-m-occur-goto-line)))
f167a01 @thierryvolpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
253 (persistent-action . helm-m-occur-persistent-action)
34b84d3 @thierryvolpiatto * helm-regexp.el (helm-c-source-moccur): Add persistent action.
thierryvolpiatto authored
254 (persistent-help . "Go to line")
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
255 (recenter)
256 (candidate-number-limit . 9999)
b3194af @thierryvolpiatto Add help for moccur.
thierryvolpiatto authored
257 (mode-line . helm-moccur-mode-line)
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
258 (keymap . ,helm-c-moccur-map)
5d07ff9 @thierryvolpiatto * helm-regexp.el: Add history to multi occur.
thierryvolpiatto authored
259 (history . ,'helm-c-grep-history)
fb3195d @thierryvolpiatto * helm.el (helm-update): Allow giving an in-source value to delayed attr...
thierryvolpiatto authored
260 (requires-pattern . 3)
261 (delayed . ,helm-m-occur-idle-delay))
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
262 "Helm source for multi occur.")
263
264 (defun helm-m-occur-transformer (candidates source)
265 "Transformer function for `helm-c-source-moccur'."
266 (require 'helm-grep)
267 (loop for i in candidates
c3fb0f0 @thierryvolpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
268 for split = (helm-c-grep-split-line i)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
269 for buf = (car split)
270 for lineno = (nth 1 split)
271 for str = (nth 2 split)
52f4fff @thierryvolpiatto * helm-regexp.el (helm-m-occur-transformer): Add an help-echo.
thierryvolpiatto authored
272 collect (cons (concat (propertize
273 buf
274 'face 'helm-moccur-buffer
275 'help-echo (buffer-file-name
276 (get-buffer buf))
277 'buffer-name buf)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
278 ":"
279 (propertize lineno 'face 'helm-grep-lineno)
280 ":"
281 (helm-c-grep-highlight-match str))
282 i)))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
283
39c674b @thierryvolpiatto * helm-buffers.el (helm-multi-occur-as-action): Issue #103 Use @ input a...
thierryvolpiatto authored
284 (defun helm-multi-occur-1 (buffers &optional input)
9f15d07 @thierryvolpiatto Add transformer function to multi occur.
thierryvolpiatto authored
285 "Main function to call `helm-c-source-moccur' with BUFFERS list."
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
286 (declare (special buffers))
f16ddf3 @thierryvolpiatto * helm-regexp.el (helm-multi-occur-1): Unbind match plugin here.
thierryvolpiatto authored
287 (let ((helm-compile-source-functions
288 ;; rule out helm-match-plugin because the input is one regexp.
289 (delq 'helm-compile-source--match-plugin
290 (copy-sequence helm-compile-source-functions))))
291 (helm :sources 'helm-c-source-moccur
292 :buffer "*helm multi occur*"
39c674b @thierryvolpiatto * helm-buffers.el (helm-multi-occur-as-action): Issue #103 Use @ input a...
thierryvolpiatto authored
293 :history 'helm-c-grep-history
294 :input input)))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
295
296
f5d0706 @thierryvolpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
297 ;;; Helm browse code.
298 (defun helm-c-browse-code-get-line (beg end)
299 "Select line if it match the regexp corresponding to current `major-mode'.
300 Line is parsed for BEG position to END position."
301 (let ((str-line (buffer-substring beg end))
302 (regexp (assoc-default major-mode
303 helm-c-browse-code-regexp-alist))
304 (num-line (if (string= helm-pattern "") beg (1- beg))))
305 (when (and regexp (string-match regexp str-line))
306 (format "%4d:%s" (line-number-at-pos num-line) str-line))))
307
308 (defvar helm-c-source-browse-code
309 '((name . "Browse code")
310 (init . (lambda ()
311 (helm-candidate-buffer helm-current-buffer)
312 (with-helm-current-buffer
313 (jit-lock-fontify-now))))
314 (candidate-number-limit . 9999)
315 (candidates-in-buffer)
316 (get-line . helm-c-browse-code-get-line)
317 (type . line)
318 (recenter)))
319
0ea6be6 @thierryvolpiatto * helm-regexp.el (helm-c-display-to-real-numbered-line): Renamed from he...
thierryvolpiatto authored
320 (defun helm-c-display-to-real-numbered-line (candidate)
321 "This is used to display a line in occur style in helm sources.
322 e.g \" 12:some_text\".
323 It is used with type attribute 'line'."
324 (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate)
325 (list (string-to-number (match-string 1 candidate))
326 (match-string 2 candidate))
327 (error "Line number not found")))
328
7974fc5 @thierryvolpiatto Create autoload system in helm-config.
thierryvolpiatto authored
329 ;;; Type attributes
330 ;;
331 ;;
332 (define-helm-type-attribute 'line
0ea6be6 @thierryvolpiatto * helm-regexp.el (helm-c-display-to-real-numbered-line): Renamed from he...
thierryvolpiatto authored
333 '((display-to-real . helm-c-display-to-real-numbered-line)
7974fc5 @thierryvolpiatto Create autoload system in helm-config.
thierryvolpiatto authored
334 (action ("Go to Line" . helm-c-action-line-goto)))
335 "LINENO:CONTENT string, eg. \" 16:foo\".
336
337 Optional `target-file' attribute is a name of target file.
338
339 Optional `before-jump-hook' attribute is a function with no
340 arguments which is called before jumping to position.
341
342 Optional `after-jump-hook' attribute is a function with no
343 arguments which is called after jumping to position.
344
345 If `adjust' attribute is specified, searches the line whose
346 content is CONTENT near the LINENO.
347
348 If `recenter' attribute is specified, the line is displayed at
349 the center of window, otherwise at the top of window.")
350
351 (define-helm-type-attribute 'file-line
352 `((filtered-candidate-transformer helm-c-filtered-candidate-transformer-file-line)
353 (multiline)
354 (action ("Go to" . helm-c-action-file-line-goto)))
355 "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\".
356
357 Optional `default-directory' attribute is a default-directory
358 FILENAME is interpreted.
359
360 Optional `before-jump-hook' attribute is a function with no
361 arguments which is called before jumping to position.
362
363 Optional `after-jump-hook' attribute is a function with no
364 arguments which is called after jumping to position.
365
366 If `adjust' attribute is specified, searches the line whose
367 content is CONTENT near the LINENO.
368
369 If `recenter' attribute is specified, the line is displayed at
370 the center of window, otherwise at the top of window.")
371
f97a20c @thierryvolpiatto * helm-config.el: Move *find-files and related to helm-files.el
thierryvolpiatto authored
372 ;;;###autoload
373 (defun helm-regexp ()
374 "Preconfigured helm to build regexps.
375 `query-replace-regexp' can be run from there against found regexp."
376 (interactive)
377 (save-restriction
378 (let ((helm-compile-source-functions
379 ;; rule out helm-match-plugin because the input is one regexp.
380 (delq 'helm-compile-source--match-plugin
381 (copy-sequence helm-compile-source-functions))))
382 (when (and (helm-region-active-p)
383 ;; Don't narrow to region if buffer is already narrowed.
384 (not (helm-current-buffer-narrowed-p)))
385 (narrow-to-region (region-beginning) (region-end)))
386 (helm :sources helm-c-source-regexp
387 :buffer "*helm regexp*"
388 :prompt "Regexp: "
389 :history 'helm-build-regexp-history))))
390
e21f4c8 @thierryvolpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
391 ;;;###autoload
392 (defun helm-occur ()
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
393 "Preconfigured helm for Occur."
e21f4c8 @thierryvolpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
394 (interactive)
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
395 (declare (special buffers))
396 (let ((buffers (list (buffer-name (current-buffer))))
397 (helm-compile-source-functions
e21f4c8 @thierryvolpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
398 ;; rule out helm-match-plugin because the input is one regexp.
399 (delq 'helm-compile-source--match-plugin
400 (copy-sequence helm-compile-source-functions))))
75e2a0e @thierryvolpiatto * helm-regexp.el (helm-occur-init-source): new
thierryvolpiatto authored
401 (helm-occur-init-source)
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
402 (helm-attrset 'name "Occur" helm-c-source-occur)
e21f4c8 @thierryvolpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
403 (helm :sources 'helm-c-source-occur
e893ce3 @thierryvolpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
404 :buffer "*helm occur*"
e21f4c8 @thierryvolpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
405 :history 'helm-c-grep-history)))
406
f5d0706 @thierryvolpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
407 ;;;###autoload
eddcd47 helm-multi-occur process interactive args in interactive form
Le Wang authored
408 (defun helm-multi-occur (buffers)
409 "Preconfigured helm for multi occur.
410
3211573 @thierryvolpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
411 BUFFERS is a list of buffers to search through.
412 With a prefix arg, force searching in current buffer
413 even if `helm-moccur-always-search-in-current' is nil.
414 The prefix arg can be set before calling `helm-multi-occur'
415 or during the buffer selection."
eddcd47 helm-multi-occur process interactive args in interactive form
Le Wang authored
416 (interactive (list (helm-comp-read
417 "Buffers: " (helm-c-buffer-list)
418 :marked-candidates t)))
3211573 @thierryvolpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
419 (let ((helm-moccur-always-search-in-current
420 (or helm-moccur-always-search-in-current
421 (or current-prefix-arg
422 helm-current-prefix-arg))))
423 (helm-multi-occur-1 buffers)))
7288a9a @thierryvolpiatto Introduce multi occur.
thierryvolpiatto authored
424
425 ;;;###autoload
f5d0706 @thierryvolpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
426 (defun helm-browse-code ()
427 "Preconfigured helm to browse code."
428 (interactive)
429 (helm :sources 'helm-c-source-browse-code
430 :buffer "*helm browse code*"
431 :default (thing-at-point 'symbol)))
432
433
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
434 (provide 'helm-regexp)
435
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
436 ;; Local Variables:
a7ee65b @thierryvolpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
437 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
438 ;; coding: utf-8
439 ;; indent-tabs-mode: nil
440 ;; byte-compile-dynamic: t
441 ;; End:
442
3d768cc @thierryvolpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
443 ;;; helm-regexp.el ends here
Something went wrong with that request. Please try again.