Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 624 lines (556 sloc) 24.567 kb
530d89f Thierry Volpiatto Enable lexical-binding in all files.
thierryvolpiatto authored
1 ;;; helm-regexp.el --- In buffer regexp searching and replacement for helm. -*- lexical-binding: t -*-
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
2
064302a Thierry Volpiatto Update copyrights.
thierryvolpiatto authored
3 ;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto <thierry.volpiatto@gmail.com>
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
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
b740a4b Thierry Volpiatto Finish replacing cl symbols and requiring cl-lib, no compile error.
thierryvolpiatto authored
20 (require 'cl-lib)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
21 (require 'helm)
ba17f09 Thierry Volpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
22 (require 'helm-utils)
7b73c42 Thierry Volpiatto * helm-regexp.el: Require helm-plugin (#644).
thierryvolpiatto authored
23 (require 'helm-plugin)
ba17f09 Thierry Volpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
24
25
26 (defgroup helm-regexp nil
27 "Regexp related Applications and libraries for Helm."
28 :group 'helm)
29
6e49004 Thierry Volpiatto * helm-regexp.el (helm-moccur-always-search-in-current): Default to nil.
thierryvolpiatto authored
30 (defcustom helm-moccur-always-search-in-current nil
c3fb0f0 Thierry Volpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
31 "Helm multi occur always search in current buffer when non--nil."
32 :group 'helm-regexp
33 :type 'boolean)
34
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
35 (defcustom helm-moccur-use-ioccur-style-keys t
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
36 "Similar to `helm-grep-use-ioccur-style-keys' but for multi occur."
f167a01 Thierry Volpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
37 :group 'helm-regexp
38 :type 'boolean)
39
db86112 Thierry Volpiatto * helm-regexp.el (helm-moccur-auto-update-on-resume): New.
thierryvolpiatto authored
40 (defcustom helm-moccur-auto-update-on-resume nil
41 "Allow auto updating helm-(m)occur buffer when outdated.
42 noask => Always update without asking
43 nil => Don't update but signal buffer needs update
44 never => Never update and do not signal buffer needs update
45 Any other non--nil value update after confirmation."
46 :group 'helm-regexp
47 :type '(radio :tag "Allow auto updating helm-(m)occur buffer when outdated."
48 (const :tag "Always update without asking" noask)
49 (const :tag "Never update and do not signal buffer needs update" never)
50 (const :tag "Don't update but signal buffer needs update" nil)
51 (const :tag "Update after confirmation" t)))
52
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
53
54 (defface helm-moccur-buffer
9bc2702 Thierry Volpiatto Reindent all again.
thierryvolpiatto authored
55 '((t (:foreground "DarkTurquoise" :underline t)))
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
56 "Face used to highlight moccur buffer names."
57 :group 'helm-regexp)
ba17f09 Thierry Volpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
58
db86112 Thierry Volpiatto * helm-regexp.el (helm-moccur-auto-update-on-resume): New.
thierryvolpiatto authored
59 (defface helm-resume-need-update
60 '((t (:background "red")))
61 "Face used to flash moccur buffer when it needs update."
62 :group 'helm-regexp)
63
ba17f09 Thierry Volpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
64
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
65 (defvar helm-moccur-map
b740a4b Thierry Volpiatto Finish replacing cl symbols and requiring cl-lib, no compile error.
thierryvolpiatto authored
66 (let ((map (make-sparse-keymap)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
67 (set-keymap-parent map helm-map)
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
68 (define-key map (kbd "M-<down>") 'helm-goto-next-file)
69 (define-key map (kbd "M-<up>") 'helm-goto-precedent-file)
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
70 (define-key map (kbd "C-w") 'helm-yank-text-at-point)
b3194af Thierry Volpiatto Add help for moccur.
thierryvolpiatto authored
71 (define-key map (kbd "C-c ?") 'helm-moccur-help)
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
72 (define-key map (kbd "C-c o") 'helm-moccur-run-goto-line-ow)
73 (define-key map (kbd "C-c C-o") 'helm-moccur-run-goto-line-of)
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
74 (define-key map (kbd "C-x C-s") 'helm-moccur-run-save-buffer)
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
75 (when helm-moccur-use-ioccur-style-keys
309c04d Thierry Volpiatto * helm.el (helm--follow-action): Go to next/previous line if previous co...
thierryvolpiatto authored
76 (define-key map (kbd "<right>") 'helm-execute-persistent-action)
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
77 (define-key map (kbd "<left>") 'helm-moccur-run-default-action))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
78 (delq nil map))
79 "Keymap used in Moccur source.")
e893ce3 Thierry Volpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
80
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
81
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
82 (defvar helm-build-regexp-history nil)
b83c4cf Thierry Volpiatto Start fixing unused vars.
thierryvolpiatto authored
83 (defun helm-query-replace-regexp (_candidate)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
84 "Query replace regexp from `helm-regexp'.
85 With a prefix arg replace only matches surrounded by word boundaries,
86 i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b."
87 (let ((regexp (funcall (helm-attr 'regexp))))
88 (apply 'query-replace-regexp
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
89 (helm-query-replace-args regexp))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
90
b83c4cf Thierry Volpiatto Start fixing unused vars.
thierryvolpiatto authored
91 (defun helm-kill-regexp-as-sexp (_candidate)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
92 "Kill regexp in a format usable in lisp code."
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
93 (helm-regexp-kill-new
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
94 (prin1-to-string (funcall (helm-attr 'regexp)))))
95
b83c4cf Thierry Volpiatto Start fixing unused vars.
thierryvolpiatto authored
96 (defun helm-kill-regexp (_candidate)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
97 "Kill regexp as it is in `helm-pattern'."
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
98 (helm-regexp-kill-new (funcall (helm-attr 'regexp))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
99
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
100 (defun helm-query-replace-args (regexp)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
101 "create arguments of `query-replace-regexp' action in `helm-regexp'."
102 (let ((region-only (helm-region-active-p)))
103 (list
104 regexp
105 (query-replace-read-to regexp
106 (format "Query replace %sregexp %s"
107 (if helm-current-prefix-arg "word " "")
108 (if region-only "in region " ""))
109 t)
110 helm-current-prefix-arg
111 (when region-only (region-beginning))
112 (when region-only (region-end)))))
113
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
114 (defvar helm-source-regexp
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
115 '((name . "Regexp Builder")
116 (init . (lambda ()
50dc4cd Thierry Volpiatto * helm-regexp.el (helm-c-source-regexp): Don't use current-buffer as hel...
thierryvolpiatto authored
117 (helm-init-candidates-in-buffer
1592c28 Thierry Volpiatto Reindent all files.
thierryvolpiatto authored
118 'global (with-temp-buffer
119 (insert-buffer-substring helm-current-buffer)
120 (buffer-string)))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
121 (candidates-in-buffer)
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
122 (get-line . helm-regexp-get-line)
123 (persistent-action . helm-regexp-persistent-action)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
124 (persistent-help . "Show this line")
125 (multiline)
a70f927 Thierry Volpiatto New attr no-matchplugin to disable match-plugin from sources.
thierryvolpiatto authored
126 (no-matchplugin)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
127 (requires-pattern . 2)
128 (mode-line . "Press TAB to select action.")
129 (regexp . (lambda () helm-input))
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
130 (action . (("Kill Regexp as sexp" . helm-kill-regexp-as-sexp)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
131 ("Query Replace Regexp (C-u Not inside word.)"
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
132 . helm-query-replace-regexp)
133 ("Kill Regexp" . helm-kill-regexp)))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
134
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
135 (defun helm-regexp-get-line (s e)
621b904 Thierry Volpiatto * helm-regexp.el (helm-c-regexp-get-line): Simplify.
thierryvolpiatto authored
136 (let ((matches (match-data))
e28313e Thierry Volpiatto * helm-regexp.el (helm-c-regexp-get-line): Don't use max.
thierryvolpiatto authored
137 (line (buffer-substring s e)))
621b904 Thierry Volpiatto * helm-regexp.el (helm-c-regexp-get-line): Simplify.
thierryvolpiatto authored
138 (propertize
b82caa8 Thierry Volpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
139 (cl-loop with ln = (format "%5d: %s" (line-number-at-pos (1- s)) line)
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
140 for i from 0 to (1- (/ (length matches) 2))
141 concat (format "\n %s'%s'" (format "Group %d: " i)
19f225f Thierry Volpiatto Fix indentation of "into" in some files.
thierryvolpiatto authored
142 (match-string i))
143 into ln1
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
144 finally return (concat ln ln1))
621b904 Thierry Volpiatto * helm-regexp.el (helm-c-regexp-get-line): Simplify.
thierryvolpiatto authored
145 ;; match beginning
146 ;; KLUDGE: point of helm-candidate-buffer is +1 than that of helm-current-buffer.
147 ;; It is implementation problem of candidates-in-buffer.
4cf64c4 Thierry Volpiatto * helm-regexp.el: Fix typo (#657).
thierryvolpiatto authored
148 'helm-realvalue (1- s))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
149
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
150 (defun helm-regexp-persistent-action (pt)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
151 (helm-goto-char pt)
3c9cdce Thierry Volpiatto (helm-match-line-color-current-line, helm-persistent-highlight-point): R...
thierryvolpiatto authored
152 (helm-highlight-current-line))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
153
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
154 (defun helm-regexp-kill-new (input)
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
155 (kill-new input)
156 (message "Killed: %s" input))
157
158 (defun helm-quote-whitespace (candidate)
159 "Quote whitespace, if some, in string CANDIDATE."
160 (replace-regexp-in-string " " "\\\\ " candidate))
161
e893ce3 Thierry Volpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
162
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
163 ;;; Occur
164 ;;
165 ;;
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
166 (defvar helm-source-occur nil)
75e2a0e Thierry Volpiatto * helm-regexp.el (helm-occur-init-source): new
thierryvolpiatto authored
167 (defun helm-occur-init-source ()
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
168 (unless helm-source-occur
ae0c716 Thierry Volpiatto * helm-source.el: Setup keymap in a primary method for helm-source.
thierryvolpiatto authored
169 (setq helm-source-occur
8cb7a9e Thierry Volpiatto * helm-source.el: Rename helm--make* to helm-make.
thierryvolpiatto authored
170 (helm-make-source "Occur" 'helm-source-multi-occur))))
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
171
f5d0706 Thierry Volpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
172
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
173 ;;; Multi occur
174 ;;
175 ;;
5d6f8c1 Thierry Volpiatto * helm-regexp.el: Fix force-update in resumed moccur sessions.
thierryvolpiatto authored
176
177 ;; Internal
178 (defvar helm-multi-occur-buffer-list nil)
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
179 (defvar helm-multi-occur-buffer-tick nil)
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
180 (defun helm-moccur-init ()
a784aac Thierry Volpiatto * helm-regexp.el (helm-moccur-init): No need to use a local var.
thierryvolpiatto authored
181 "Create the initial helm multi occur buffer."
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
182 (helm-init-candidates-in-buffer
1592c28 Thierry Volpiatto Reindent all files.
thierryvolpiatto authored
183 'global
6927000 Thierry Volpiatto Get rid of `helm-multi-occur-buffer-list' global value.
thierryvolpiatto authored
184 (cl-loop with buffers = (helm-attr 'moccur-buffers)
185 for buf in buffers
186 for bufstr = (with-current-buffer buf (buffer-string))
187 do (add-text-properties
188 0 (length bufstr)
189 `(buffer-name ,(buffer-name (get-buffer buf)))
190 bufstr)
191 concat bufstr)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
192
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
193 (defun helm-moccur-get-line (beg end)
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
194 "Format line for `helm-source-moccur'."
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
195 (format "%s:%d:%s"
aaa5027 Thierry Volpiatto * helm-regexp.el (helm-m-occur-get-line): Don't recompute point-at-bol.
thierryvolpiatto authored
196 (get-text-property beg 'buffer-name)
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
197 (save-restriction
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
198 (narrow-to-region (previous-single-property-change
199 (point) 'buffer-name)
200 (next-single-property-change
201 (point) 'buffer-name))
aaa5027 Thierry Volpiatto * helm-regexp.el (helm-m-occur-get-line): Don't recompute point-at-bol.
thierryvolpiatto authored
202 (line-number-at-pos beg))
203 (buffer-substring beg end)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
204
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
205 (cl-defun helm-moccur-action (candidate
e6c3ff1 Thierry Volpiatto Reindent all files again.
thierryvolpiatto authored
206 &optional (method (quote buffer)) mark)
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
207 "Jump to CANDIDATE with METHOD.
208 arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame."
c3fb0f0 Thierry Volpiatto * helm-grep.el (helm-c-goto-next-or-prec-file): always use helm-c-grep-s...
thierryvolpiatto authored
209 (require 'helm-grep)
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
210 (let* ((split (helm-grep-split-line candidate))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
211 (buf (car split))
d91593b Thierry Volpiatto * helm-regexp.el (helm-m-occur-action): Move point to the nearest matchi...
thierryvolpiatto authored
212 (lineno (string-to-number (nth 1 split)))
213 (split-pat (if helm-occur-match-plugin-mode
214 (helm-mp-split-pattern helm-pattern)
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
215 (list helm-pattern))))
b82caa8 Thierry Volpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
216 (cl-case method
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
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 Thierry Volpiatto * helm-regexp.el (helm-m-occur-action): Issue #113 Go to first occurence...
thierryvolpiatto authored
220 (helm-goto-line lineno)
d91593b Thierry Volpiatto * helm-regexp.el (helm-m-occur-action): Move point to the nearest matchi...
thierryvolpiatto authored
221 ;; Move point to the nearest matching regexp from bol.
b82caa8 Thierry Volpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
222 (cl-loop for reg in split-pat
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
223 when (save-excursion
224 (re-search-forward reg (point-at-eol) t))
225 collect (match-beginning 0) into pos-ls
37365ec Thierry Volpiatto * helm-regexp.el (helm-moccur-action): Use when instead of unless.
thierryvolpiatto authored
226 finally (when pos-ls (goto-char (apply #'min pos-ls))))
cbb649b Thierry Volpiatto * helm-regexp.el: occur/moccur action: Set mark with prefix arg.
thierryvolpiatto authored
227 (when mark
228 (set-marker (mark-marker) (point))
229 (push-mark (point) 'nomsg))))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
230
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
231 (defun helm-moccur-persistent-action (candidate)
232 (helm-moccur-goto-line candidate)
3c9cdce Thierry Volpiatto (helm-match-line-color-current-line, helm-persistent-highlight-point): R...
thierryvolpiatto authored
233 (helm-highlight-current-line))
f167a01 Thierry Volpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
234
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
235 (defun helm-moccur-goto-line (candidate)
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
236 "From multi occur, switch to buffer and go to nth 1 CANDIDATE line."
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
237 (helm-moccur-action
cbb649b Thierry Volpiatto * helm-regexp.el: occur/moccur action: Set mark with prefix arg.
thierryvolpiatto authored
238 candidate 'buffer (or current-prefix-arg ; persistent.
239 helm-current-prefix-arg))) ; exit.
798c81f Thierry Volpiatto reindent.
thierryvolpiatto authored
240
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
241 (defun helm-moccur-goto-line-ow (candidate)
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
242 "Go to CANDIDATE line in other window.
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
243 Same as `helm-moccur-goto-line' but go in other window."
244 (helm-moccur-action
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
245 candidate 'buffer-other-window
246 (or current-prefix-arg ; persistent.
247 helm-current-prefix-arg))) ; exit.
248
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
249 (defun helm-moccur-goto-line-of (candidate)
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
250 "Go to CANDIDATE line in new frame.
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
251 Same as `helm-moccur-goto-line' but go in new frame."
252 (helm-moccur-action
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
253 candidate 'buffer-other-frame
254 (or current-prefix-arg ; persistent.
255 helm-current-prefix-arg))) ; exit.
256
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
257 (defun helm-moccur-run-goto-line-ow ()
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
258 "Run goto line other window action from `helm-source-moccur'."
259 (interactive)
586425f Thierry Volpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
260 (with-helm-alive-p
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
261 (helm-quit-and-execute-action 'helm-moccur-goto-line-ow)))
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
262
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
263 (defun helm-moccur-run-goto-line-of ()
d8eb8a9 Thierry Volpiatto * helm-regexp.el: Add goto line other window/frame actions in moccur and...
thierryvolpiatto authored
264 "Run goto line new frame action from `helm-source-moccur'."
265 (interactive)
586425f Thierry Volpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
266 (with-helm-alive-p
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
267 (helm-quit-and-execute-action 'helm-moccur-goto-line-of)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
268
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
269 (defun helm-moccur-run-default-action ()
f167a01 Thierry Volpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
270 (interactive)
586425f Thierry Volpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
271 (with-helm-alive-p
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
272 (helm-quit-and-execute-action 'helm-moccur-goto-line)))
f167a01 Thierry Volpiatto * helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.
thierryvolpiatto authored
273
9c7ee9d Thierry Volpiatto * helm-regexp.el: Add autoload cookie.
thierryvolpiatto authored
274 ;;;###autoload
4f75296 Thierry Volpiatto * helm-regexp.el (helm-occur-match-plugin-mode): New minor-mode, enabled...
thierryvolpiatto authored
275 (define-minor-mode helm-occur-match-plugin-mode
9bc2702 Thierry Volpiatto Reindent all again.
thierryvolpiatto authored
276 "Turn On/Off `helm-match-plugin-mode' only for `helm-m/occur'."
4f75296 Thierry Volpiatto * helm-regexp.el (helm-occur-match-plugin-mode): New minor-mode, enabled...
thierryvolpiatto authored
277 :global t
278 :init-value t
279 (if helm-occur-match-plugin-mode
280 (setq helm-source-moccur
281 (remove (assoc 'no-matchplugin helm-source-moccur)
282 helm-source-moccur)
283 helm-source-occur helm-source-moccur)
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
284 (helm-attrset 'no-matchplugin nil helm-source-moccur)
285 (setq helm-source-occur helm-source-moccur)))
4f75296 Thierry Volpiatto * helm-regexp.el (helm-occur-match-plugin-mode): New minor-mode, enabled...
thierryvolpiatto authored
286
ae0c716 Thierry Volpiatto * helm-source.el: Setup keymap in a primary method for helm-source.
thierryvolpiatto authored
287 (defvar helm-source-moccur nil)
288 (defclass helm-source-multi-occur (helm-source-in-buffer)
289 ((init :initform (lambda ()
290 (require 'helm-grep)
291 (helm-moccur-init)))
292 (filter-one-by-one :initform 'helm-moccur-filter-one-by-one)
293 (get-line :initform helm-moccur-get-line)
294 (nohighlight :initform t)
295 (migemo :initform t)
296 (action :initform '(("Go to Line" . helm-moccur-goto-line)
297 ("Goto line other window" . helm-moccur-goto-line-ow)
298 ("Goto line new frame" . helm-moccur-goto-line-of)))
299 (persistent-action :initform 'helm-moccur-persistent-action)
300 (persistent-help :initform "Go to line")
301 (recenter :initform t)
302 (resume :initform 'helm-moccur-resume-fn)
303 (candidate-number-limit :initform 9999)
304 (mode-line :initform helm-moccur-mode-line)
305 (keymap :initform helm-moccur-map)
306 (history :initform 'helm-grep-history)
307 (requires-pattern :initform 2)))
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
308
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
309 (defun helm-moccur-resume-fn ()
21b38c3 Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): always save buffers.
thierryvolpiatto authored
310 (with-helm-buffer
86c76a7 Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Handle tick when killed buffer...
thierryvolpiatto authored
311 (let (new-tick-ls buffer-is-modified)
312 (set (make-local-variable 'helm-multi-occur-buffer-list)
313 (cl-loop for b in helm-multi-occur-buffer-list
314 when (buffer-live-p (get-buffer b))
315 collect b))
316 (setq buffer-is-modified (/= (length helm-multi-occur-buffer-list)
317 (length (helm-attr 'moccur-buffers))))
318 (helm-attrset 'moccur-buffers helm-multi-occur-buffer-list)
319 (setq new-tick-ls (cl-loop for b in helm-multi-occur-buffer-list
320 collect (buffer-chars-modified-tick (get-buffer b))))
321 (when buffer-is-modified
322 (setq helm-multi-occur-buffer-tick new-tick-ls))
323 (cl-assert (> (length helm-multi-occur-buffer-list) 0) nil
324 "helm-resume error: helm-(m)occur buffer list is empty")
325 (unless (eq helm-moccur-auto-update-on-resume 'never)
326 (when (or buffer-is-modified
327 (cl-loop for b in helm-multi-occur-buffer-list
328 for new-tick = (buffer-chars-modified-tick (get-buffer b))
329 for tick in helm-multi-occur-buffer-tick
330 thereis (/= tick new-tick)))
db86112 Thierry Volpiatto * helm-regexp.el (helm-moccur-auto-update-on-resume): New.
thierryvolpiatto authored
331 (helm-aif helm-moccur-auto-update-on-resume
332 (when (or (eq it 'noask)
333 (y-or-n-p "Helm (m)occur Buffer outdated, update? "))
334 (run-with-idle-timer 0.1 nil (lambda ()
335 (with-helm-buffer
336 (helm-force-update)
337 (message "Helm (m)occur Buffer have been udated")
338 (sit-for 1) (message nil))))
86c76a7 Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Handle tick when killed buffer...
thierryvolpiatto authored
339 (unless buffer-is-modified (setq helm-multi-occur-buffer-tick new-tick-ls)))
db86112 Thierry Volpiatto * helm-regexp.el (helm-moccur-auto-update-on-resume): New.
thierryvolpiatto authored
340 (run-with-idle-timer 0.1 nil (lambda ()
341 (with-helm-buffer
8d719ac Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Don't highlight header line.
thierryvolpiatto authored
342 (let ((ov (make-overlay (save-excursion
343 (goto-char (point-min))
344 (forward-line 1)
345 (point))
346 (point-max))))
db86112 Thierry Volpiatto * helm-regexp.el (helm-moccur-auto-update-on-resume): New.
thierryvolpiatto authored
347 (overlay-put ov 'face 'helm-resume-need-update)
348 (sit-for 0.3) (delete-overlay ov)
349 (message "[Helm occur Buffer outdated (C-c C-u to update)]")))))
86c76a7 Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Handle tick when killed buffer...
thierryvolpiatto authored
350 (unless buffer-is-modified
351 (with-helm-after-update-hook
352 (setq helm-multi-occur-buffer-tick new-tick-ls)
353 (message "Helm (m)occur Buffer have been udated")))))))))
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
354
85a970c Thierry Volpiatto * helm-regexp.el: Fix helm-m-occur prefixes to helm-moccur.
thierryvolpiatto authored
355 (defun helm-moccur-filter-one-by-one (candidate)
813a632 Thierry Volpiatto * helm-regexp.el (helm-m-occur-filter-one-by-one): Fix docstring.
thierryvolpiatto authored
356 "`filter-one-by-one' function for `helm-source-moccur'."
9f15d07 Thierry Volpiatto Add transformer function to multi occur.
thierryvolpiatto authored
357 (require 'helm-grep)
2bf8807 Thierry Volpiatto * helm.el (helm-match-from-candidates): No need to check cand in hash as...
thierryvolpiatto authored
358 (let* ((split (helm-grep-split-line candidate))
359 (buf (car split))
7d662de Thierry Volpiatto * helm.el (helm-search-from-candidate-buffer): Allow using `filter-one-b...
thierryvolpiatto authored
360 (lineno (nth 1 split))
2bf8807 Thierry Volpiatto * helm.el (helm-match-from-candidates): No need to check cand in hash as...
thierryvolpiatto authored
361 (str (nth 2 split)))
7d662de Thierry Volpiatto * helm.el (helm-search-from-candidate-buffer): Allow using `filter-one-b...
thierryvolpiatto authored
362 (cons (concat (propertize
363 buf
364 'face 'helm-moccur-buffer
365 'help-echo (buffer-file-name
366 (get-buffer buf))
367 'buffer-name buf)
368 ":"
369 (propertize lineno 'face 'helm-grep-lineno)
370 ":"
371 (helm-grep-highlight-match
372 str helm-occur-match-plugin-mode))
373 candidate)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
374
39c674b Thierry Volpiatto * helm-buffers.el (helm-multi-occur-as-action): Issue #103 Use @ input a...
thierryvolpiatto authored
375 (defun helm-multi-occur-1 (buffers &optional input)
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
376 "Main function to call `helm-source-moccur' with BUFFERS list."
6927000 Thierry Volpiatto Get rid of `helm-multi-occur-buffer-list' global value.
thierryvolpiatto authored
377 (let ((bufs (if helm-moccur-always-search-in-current
378 (cons
379 ;; will become helm-current-buffer later.
380 (buffer-name (current-buffer))
eb83d96 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-1): Fix buffers list with prefix arg.
thierryvolpiatto authored
381 (remove helm-current-buffer buffers))
6927000 Thierry Volpiatto Get rid of `helm-multi-occur-buffer-list' global value.
thierryvolpiatto authored
382 buffers)))
ae0c716 Thierry Volpiatto * helm-source.el: Setup keymap in a primary method for helm-source.
thierryvolpiatto authored
383 (unless helm-source-moccur
384 (setq helm-source-moccur
8cb7a9e Thierry Volpiatto * helm-source.el: Rename helm--make* to helm-make.
thierryvolpiatto authored
385 (helm-make-source "Moccur" 'helm-source-multi-occur)))
6927000 Thierry Volpiatto Get rid of `helm-multi-occur-buffer-list' global value.
thierryvolpiatto authored
386 (helm-attrset 'moccur-buffers bufs helm-source-moccur)
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
387 (helm-set-local-variable 'helm-multi-occur-buffer-list bufs)
388 (helm-set-local-variable
389 'helm-multi-occur-buffer-tick
390 (cl-loop for b in bufs
066cdef Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Update buffer list.
thierryvolpiatto authored
391 collect (buffer-chars-modified-tick (get-buffer b)))))
a70f927 Thierry Volpiatto New attr no-matchplugin to disable match-plugin from sources.
thierryvolpiatto authored
392 (helm :sources 'helm-source-moccur
393 :buffer "*helm multi occur*"
394 :history 'helm-grep-history
a336ea1 Thierry Volpiatto * helm-grep.el: Use truncate-lines in some places
thierryvolpiatto authored
395 :input input
396 :truncate-lines t))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
397
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
398 ;;;###autoload
399 (defun helm-moccur-run-save-buffer ()
400 "Run grep save results action from `helm-do-grep-1'."
401 (interactive)
402 (with-helm-alive-p
403 (helm-quit-and-execute-action 'helm-moccur-save-results)))
404
405
406 ;;; helm-moccur-mode
407 ;;
408 ;;
ee61ae1 Thierry Volpiatto * helm-grep.el (helm-goto-next-or-prec-file): Handle moccur-mode.
thierryvolpiatto authored
409 (defvar helm-moccur-mode-map
410 (let ((map (make-sparse-keymap)))
411 (define-key map (kbd "RET") 'helm-moccur-mode-goto-line)
412 (define-key map (kbd "C-o") 'helm-moccur-mode-goto-line-ow)
413 (define-key map (kbd "<C-down>") 'undefined)
414 (define-key map (kbd "<C-up>") 'undefined)
415 (define-key map (kbd "<M-down>") 'helm-gm-next-file)
416 (define-key map (kbd "<M-up>") 'helm-gm-precedent-file)
417 map))
418
419 (defun helm-moccur-mode-goto-line ()
420 (interactive)
421 (helm-moccur-goto-line
422 (buffer-substring (point-at-bol) (point-at-eol))))
423
424 (defun helm-moccur-mode-goto-line-ow ()
425 (interactive)
426 (helm-moccur-goto-line-ow
427 (buffer-substring (point-at-bol) (point-at-eol))))
428
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
429 (defun helm-moccur-save-results (_candidate)
430 "Save helm moccur results in a `helm-moccur-mode' buffer."
431 (let ((buf "*hmoccur*")
432 new-buf)
433 (when (get-buffer buf)
094a9c2 Thierry Volpiatto Bind `helm--reading-passwd-or-string' when reading-string during helm se...
thierryvolpiatto authored
434 (setq new-buf (helm-read-string "OccurBufferName: " buf))
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
435 (cl-loop for b in (helm-buffer-list)
436 when (and (string= new-buf b)
437 (not (y-or-n-p
438 (format "Buffer `%s' already exists overwrite? "
439 new-buf))))
094a9c2 Thierry Volpiatto Bind `helm--reading-passwd-or-string' when reading-string during helm se...
thierryvolpiatto authored
440 do (setq new-buf (helm-read-string "OccurBufferName: " "*hmoccur ")))
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
441 (setq buf new-buf))
442 (with-current-buffer (get-buffer-create buf)
443 (setq buffer-read-only t)
444 (let ((inhibit-read-only t))
445 (erase-buffer)
446 (insert "-*- mode: helm-moccur -*-\n\n"
447 (format "Moccur Results for `%s':\n\n" helm-pattern))
448 (save-excursion
449 (insert (with-current-buffer helm-buffer
450 (goto-char (point-min)) (forward-line 1)
451 (buffer-substring (point) (point-max))))))
452 (helm-moccur-mode) (pop-to-buffer buf))
453 (message "Helm Moccur Results saved in `%s' buffer" buf)))
454
455 ;;;###autoload
456 (define-derived-mode helm-moccur-mode
457 special-mode "helm-moccur"
458 "Major mode to provide actions in helm moccur saved buffer.
459
460 Special commands:
461 \\{helm-moccur-mode-map}"
0efbacd Thierry Volpiatto * helm-regexp.el (helm-moccur-save-results-1): Save helm-multi-occur-buf...
thierryvolpiatto authored
462 (set (make-local-variable 'helm-multi-occur-buffer-list)
463 (with-helm-buffer helm-multi-occur-buffer-list))
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
464 (set (make-local-variable 'revert-buffer-function)
465 #'helm-moccur-mode--revert-buffer-function))
466
467 (defun helm-moccur-mode--revert-buffer-function (&optional _ignore-auto _noconfirm)
468 (goto-char (point-min))
469 (let (pattern)
470 (when (re-search-forward "^Moccur Results for `\\(.*\\)'" nil t)
471 (setq pattern (match-string 1))
472 (forward-line 0)
473 (when (re-search-forward "^$" nil t)
474 (forward-line 1))
475 (let ((inhibit-read-only t)
476 (buffer (current-buffer))
45321f1 Thierry Volpiatto * helm-regexp.el (helm-moccur-mode--revert-buffer-function): Fix local v...
thierryvolpiatto authored
477 (buflst helm-multi-occur-buffer-list))
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
478 (delete-region (point) (point-max))
479 (message "Reverting buffer...")
45321f1 Thierry Volpiatto * helm-regexp.el (helm-moccur-mode--revert-buffer-function): Fix local v...
thierryvolpiatto authored
480 (save-excursion
481 (with-temp-buffer
482 (insert
483 "\n"
484 (cl-loop for buf in buflst
bef4335 Thierry Volpiatto * helm-regexp.el (helm-moccur-mode--revert-buffer-function): Fix when on...
thierryvolpiatto authored
485 for bufstr = (or (and (buffer-live-p (get-buffer buf))
486 (with-current-buffer buf
487 (buffer-string)))
488 "")
489 unless (string= bufstr "")
45321f1 Thierry Volpiatto * helm-regexp.el (helm-moccur-mode--revert-buffer-function): Fix local v...
thierryvolpiatto authored
490 do (add-text-properties
491 0 (length bufstr)
492 `(buffer-name ,(buffer-name (get-buffer buf)))
493 bufstr)
494 concat bufstr)
495 "\n")
496 (goto-char (point-min))
497 (cl-loop while (re-search-forward pattern nil t)
498 for line = (helm-moccur-get-line (point-at-bol) (point-at-eol))
499 when line
500 do (with-current-buffer buffer
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
501 (insert
f893097 Thierry Volpiatto * helm-regexp.el (helm-moccur-mode--revert-buffer-function): Add helm-re...
thierryvolpiatto authored
502 (propertize
503 (car (helm-moccur-filter-one-by-one line))
504 'helm-real-value line)
9b94476 Thierry Volpiatto * helm-regexp.el: Introduce helm-moccur-mode to save moccur results. Not...
thierryvolpiatto authored
505 "\n")))))
506 (message "Reverting buffer done")))))
507
508
4f639c1 Thierry Volpiatto * helm-regexp.el: Move unused code to helm-plugin.el (#531).
thierryvolpiatto authored
509 ;;; Predefined commands
7974fc5 Thierry Volpiatto Create autoload system in helm-config.
thierryvolpiatto authored
510 ;;
511 ;;
512
f97a20c Thierry Volpiatto * helm-config.el: Move *find-files and related to helm-files.el
thierryvolpiatto authored
513 ;;;###autoload
514 (defun helm-regexp ()
515 "Preconfigured helm to build regexps.
516 `query-replace-regexp' can be run from there against found regexp."
517 (interactive)
518 (save-restriction
a70f927 Thierry Volpiatto New attr no-matchplugin to disable match-plugin from sources.
thierryvolpiatto authored
519 (when (and (helm-region-active-p)
520 ;; Don't narrow to region if buffer is already narrowed.
521 (not (helm-current-buffer-narrowed-p (current-buffer))))
522 (narrow-to-region (region-beginning) (region-end)))
523 (helm :sources helm-source-regexp
524 :buffer "*helm regexp*"
525 :prompt "Regexp: "
526 :history 'helm-build-regexp-history)))
f97a20c Thierry Volpiatto * helm-config.el: Move *find-files and related to helm-files.el
thierryvolpiatto authored
527
e21f4c8 Thierry Volpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
528 ;;;###autoload
529 (defun helm-occur ()
e893ce3 Thierry Volpiatto * helm-regexp.el: Now Occur inherit source from multi-occur.
thierryvolpiatto authored
530 "Preconfigured helm for Occur."
e21f4c8 Thierry Volpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
531 (interactive)
a70f927 Thierry Volpiatto New attr no-matchplugin to disable match-plugin from sources.
thierryvolpiatto authored
532 (helm-occur-init-source)
6927000 Thierry Volpiatto Get rid of `helm-multi-occur-buffer-list' global value.
thierryvolpiatto authored
533 (let ((bufs (list (buffer-name (current-buffer)))))
534 (helm-attrset 'moccur-buffers bufs helm-source-occur)
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
535 (helm-set-local-variable 'helm-multi-occur-buffer-list bufs)
536 (helm-set-local-variable
537 'helm-multi-occur-buffer-tick
538 (cl-loop for b in bufs
066cdef Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Update buffer list.
thierryvolpiatto authored
539 collect (buffer-chars-modified-tick (get-buffer b)))))
a70f927 Thierry Volpiatto New attr no-matchplugin to disable match-plugin from sources.
thierryvolpiatto authored
540 (helm :sources 'helm-source-occur
541 :buffer "*helm occur*"
a336ea1 Thierry Volpiatto * helm-grep.el: Use truncate-lines in some places
thierryvolpiatto authored
542 :history 'helm-grep-history
dcb7869 Yasuyuki Oka * helm-regexp.el (helm-occur): Support preselect
yasuyk authored
543 :preselect (and (memq 'helm-source-occur helm-sources-using-default-as-input)
544 (format "%s:%d:" (buffer-name) (line-number-at-pos (point))))
a336ea1 Thierry Volpiatto * helm-grep.el: Use truncate-lines in some places
thierryvolpiatto authored
545 :truncate-lines t))
e21f4c8 Thierry Volpiatto * helm-config.el: Move lisp completion code to helm-elisp.el
thierryvolpiatto authored
546
f5d0706 Thierry Volpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
547 ;;;###autoload
a39abf1 Yasuyuki Oka helm-regexp.el: Add command to invoke occur form isearch.
yasuyk authored
548 (defun helm-occur-from-isearch ()
549 "Invoke `helm-occur' from isearch."
550 (interactive)
551 (let ((input (if isearch-regexp
552 isearch-string
9cc0aa4 Thierry Volpiatto * helm-regexp.el (helm-occur-from-isearch): Get rid of buffers global va...
thierryvolpiatto authored
553 (regexp-quote isearch-string)))
554 (bufs (list (buffer-name (current-buffer)))))
a39abf1 Yasuyuki Oka helm-regexp.el: Add command to invoke occur form isearch.
yasuyk authored
555 (isearch-exit)
556 (helm-occur-init-source)
9cc0aa4 Thierry Volpiatto * helm-regexp.el (helm-occur-from-isearch): Get rid of buffers global va...
thierryvolpiatto authored
557 (helm-attrset 'moccur-buffers bufs helm-source-occur)
558 (helm-set-local-variable 'helm-multi-occur-buffer-list bufs)
e0d2da5 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-buffer-tick): New store tick list.
thierryvolpiatto authored
559 (helm-set-local-variable
560 'helm-multi-occur-buffer-tick
561 (cl-loop for b in bufs
066cdef Thierry Volpiatto * helm-regexp.el (helm-moccur-resume-fn): Update buffer list.
thierryvolpiatto authored
562 collect (buffer-chars-modified-tick (get-buffer b))))
a39abf1 Yasuyuki Oka helm-regexp.el: Add command to invoke occur form isearch.
yasuyk authored
563 (helm :sources 'helm-source-occur
564 :buffer "*helm occur*"
565 :history 'helm-grep-history
a336ea1 Thierry Volpiatto * helm-grep.el: Use truncate-lines in some places
thierryvolpiatto authored
566 :input input
567 :truncate-lines t)))
a39abf1 Yasuyuki Oka helm-regexp.el: Add command to invoke occur form isearch.
yasuyk authored
568
569 ;;;###autoload
eddcd47 helm-multi-occur process interactive args in interactive form
Le Wang authored
570 (defun helm-multi-occur (buffers)
571 "Preconfigured helm for multi occur.
572
3211573 Thierry Volpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
573 BUFFERS is a list of buffers to search through.
4eb4b2b Thierry Volpiatto Fix toggling value of `helm-moccur-always-search-in-current'.
thierryvolpiatto authored
574 With a prefix arg, reverse the behavior of
575 `helm-moccur-always-search-in-current'.
3211573 Thierry Volpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
576 The prefix arg can be set before calling `helm-multi-occur'
577 or during the buffer selection."
eddcd47 helm-multi-occur process interactive args in interactive form
Le Wang authored
578 (interactive (list (helm-comp-read
4166d8a Thierry Volpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
579 "Buffers: " (helm-buffer-list)
eddcd47 helm-multi-occur process interactive args in interactive form
Le Wang authored
580 :marked-candidates t)))
3211573 Thierry Volpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
581 (let ((helm-moccur-always-search-in-current
4eb4b2b Thierry Volpiatto Fix toggling value of `helm-moccur-always-search-in-current'.
thierryvolpiatto authored
582 (if (or current-prefix-arg
583 helm-current-prefix-arg)
584 (not helm-moccur-always-search-in-current)
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
585 helm-moccur-always-search-in-current)))
3211573 Thierry Volpiatto * helm-buffers.el (helm-multi-occur-as-action): Force searching in curre...
thierryvolpiatto authored
586 (helm-multi-occur-1 buffers)))
7288a9a Thierry Volpiatto Introduce multi occur.
thierryvolpiatto authored
587
588 ;;;###autoload
b83c4cf Thierry Volpiatto Start fixing unused vars.
thierryvolpiatto authored
589 (defun helm-multi-occur-from-isearch (&optional _arg)
975eaf1 Yasuyuki Oka helm-regexp.el: Add command to invoke multi occur form isearch.
yasuyk authored
590 "Invoke `helm-multi-occur' from isearch.
591
592 With a prefix arg, reverse the behavior of
593 `helm-moccur-always-search-in-current'.
594 The prefix arg can be set before calling
595 `helm-multi-occur-from-isearch' or during the buffer selection."
596 (interactive "p")
321c6a6 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-from-isearch): Fix prefix-arg invocat...
thierryvolpiatto authored
597 (let (buf-list
598 helm-moccur-always-search-in-current
975eaf1 Yasuyuki Oka helm-regexp.el: Add command to invoke multi occur form isearch.
yasuyk authored
599 (input (if isearch-regexp
600 isearch-string
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
601 (regexp-quote isearch-string))))
975eaf1 Yasuyuki Oka helm-regexp.el: Add command to invoke multi occur form isearch.
yasuyk authored
602 (isearch-exit)
321c6a6 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-from-isearch): Fix prefix-arg invocat...
thierryvolpiatto authored
603 (setq buf-list (helm-comp-read "Buffers: "
604 (helm-buffer-list)
605 :name "Occur in buffer(s)"
606 :marked-candidates t))
607 (setq helm-moccur-always-search-in-current
608 (if (or current-prefix-arg
1592c28 Thierry Volpiatto Reindent all files.
thierryvolpiatto authored
609 helm-current-prefix-arg)
321c6a6 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-from-isearch): Fix prefix-arg invocat...
thierryvolpiatto authored
610 (not helm-moccur-always-search-in-current)
bc4fb13 Thierry Volpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
611 helm-moccur-always-search-in-current))
321c6a6 Thierry Volpiatto * helm-regexp.el (helm-multi-occur-from-isearch): Fix prefix-arg invocat...
thierryvolpiatto authored
612 (helm-multi-occur-1 buf-list input)))
975eaf1 Yasuyuki Oka helm-regexp.el: Add command to invoke multi occur form isearch.
yasuyk authored
613
f5d0706 Thierry Volpiatto * helm-config.el: Move browse-code to helm-regexp.el
thierryvolpiatto authored
614
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
615 (provide 'helm-regexp)
616
37b4201 Thierry Volpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
617 ;; Local Variables:
a7ee65b Thierry Volpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
618 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 Thierry Volpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
619 ;; coding: utf-8
620 ;; indent-tabs-mode: nil
621 ;; End:
622
3d768cc Thierry Volpiatto * helm-config.el: Move regexp and occur code to helm-regexp.el.
thierryvolpiatto authored
623 ;;; helm-regexp.el ends here
Something went wrong with that request. Please try again.