├── .github
└── workflows
│ └── test.yml
├── .gitignore
├── Cask
├── LICENSE
├── Makefile
├── README.md
├── helm-swoop.el
└── tests
└── helm-swoop-test.el
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Main workflow
2 | on: [push, pull_request]
3 |
4 | jobs:
5 | build:
6 | runs-on: ubuntu-latest
7 | strategy:
8 | matrix:
9 | emacs_version:
10 | - '25.1'
11 | - '25.2'
12 | - '25.3'
13 | - '26.1'
14 | - '26.2'
15 | - '26.3'
16 | - 'snapshot'
17 | include:
18 | - emacs_version: 'snapshot'
19 | allow_failure: true
20 | steps:
21 | - uses: actions/checkout@v1
22 | - uses: actions/setup-python@v1.1.1
23 | - uses: purcell/setup-emacs@master
24 | with:
25 | version: ${{ matrix.emacs_version }}
26 | - uses: conao3/setup-cask@master
27 |
28 | - name: Run tests
29 | if: matrix.allow_failure != true
30 | run: 'make test'
31 |
32 | - name: Run tests (allow failure)
33 | if: matrix.allow_failure == true
34 | run: 'make test || true'
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## .gitignore
2 |
3 | *-autoloads.el
4 | *.elc
5 | /.cask
6 |
--------------------------------------------------------------------------------
/Cask:
--------------------------------------------------------------------------------
1 | ;; -*- mode:lisp -*-
2 |
3 | (source gnu)
4 | (source melpa)
5 |
6 | (package-file "helm-swoop.el")
7 |
8 | (development
9 | (depends-on "buttercup"))
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ## Makefile
2 |
3 | # Copyright (C) 2019 Naoya Yamashita
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 .
17 |
18 | all:
19 |
20 | REPO_USER := emacsorphanage
21 | PACKAGE_NAME := helm-swoop
22 | REPO_NAME := helm-swoop
23 |
24 | EMACS ?= emacs
25 | ELS := $(shell cask files)
26 |
27 | GIT_HOOKS := pre-commit
28 |
29 | ##################################################
30 |
31 | .PHONY: all help build test clean
32 |
33 | all: help
34 |
35 | help:
36 | $(info )
37 | $(info Commands)
38 | $(info ========)
39 | $(info - make # Show this message)
40 | $(info - make build # Compile Elisp files)
41 | $(info - make test # Compile Elisp files and test $(PACKAGE_NAME))
42 | $(info )
43 | $(info Cleaning)
44 | $(info ========)
45 | $(info - make clean # Clean compiled files)
46 | $(info )
47 | $(info This Makefile required `cask`)
48 | $(info See https://github.com/$(REPO_USER)/$(REPO_NAME)#contribution)
49 | $(info )
50 |
51 | ##############################
52 |
53 | %.elc: %.el .cask
54 | cask exec $(EMACS) -Q --batch -f batch-byte-compile $<
55 |
56 | .cask: Cask
57 | cask install
58 | touch $@
59 |
60 | ##############################
61 |
62 | build: $(ELS:%.el=%.elc)
63 |
64 | test: build
65 | cask exec buttercup -L .
66 |
67 | clean:
68 | rm -rf $(ELS:%.el=%.elc) .cask
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![melpa badge][melpa-badge]][melpa-link]
2 | [![melpa stable badge][melpa-stable-badge]][melpa-stable-link]
3 | [![github actions badge][github-actions-badge]][github-actions-link]
4 |
5 | List match lines to another buffer, which is able to squeeze by any words you input. At the same time, the original buffer's cursor is jumping line to line according to moving up and down the line list.
6 |
7 | 
8 |
9 | ### Feature
10 |
11 | * Culling all lines in buffer with your input
12 | * Highlight multiple matched pattern
13 | * Jumping line to line according to list buffer's move
14 | * Cache result until modifies the buffer
15 | * Go back to the last line
16 | * Multi separated line culling
17 | * Culling lines are editable
18 |
19 | ### Usage
20 |
21 | #### Now helm-swoop has several ways.
22 |
23 | * `M-x helm-swoop` when region active
24 | * `M-x helm-swoop` when the cursor is at any symbol
25 | * `M-x helm-swoop` when the cursor is not at any symbol
26 | * `M-3 M-x helm-swoop` or `C-u 5 M-x helm-swoop` multi separated line culling
27 | * `M-x helm-multi-swoop` multi-occur like feature
28 | * `M-x helm-multi-swoop-all` apply all buffers
29 | * `C-u M-x helm-multi-swoop` apply last selected buffers from the second time
30 | * `M-x helm-multi-swoop-org` apply to all org-mode buffers
31 | * `M-x helm-multi-swoop-current-mode` apply to all buffers with the same major-mode as the current buffer
32 | * `M-x helm-multi-swoop-projectile` Apply to all opened buffers of the current project
33 | * `M-x helm-swoop-same-face-at-point` list lines have the same face at the cursor is on
34 | * During isearch `M-i` to hand the word over to helm-swoop
35 | * During helm-swoop `M-i` to hand the word over to helm-multi-swoop-all
36 | * While doing `helm-swoop` press `C-c C-e` to edit mode, apply changes to original buffer by `C-x C-s`
37 |
38 | It's able to use words within a region or a word at symbol as search query when it called. Also use a keybind you set just type like M-i instead of `M-x helm-swoop`.
39 |
40 | #### Edit mode
41 | While doing `helm-swoop` type `C-c C-e` to enter the edit mode.
42 | Before enter the edit mode, you can choose some lines marked by `C-SPC` or `M-SPC` to edit.
43 | Apply changes to original buffer type `C-x C-s`.
44 |
45 | #### Across multiple buffers
46 |
47 | ##### `M-x helm-multi-swoop`
48 | 1. Select any buffers by [C-SPC] or [M-SPC]
49 | 2. Press [RET] to start helm-multi-swoop
50 |
51 | 
52 |
53 | ##### `M-x helm-multi-swoop-all`
54 | Skip select phase and apply all buffers.
55 |
56 | ##### `C-u M-x helm-multi-swoop`
57 | Skip select phase and apply last selected buffers, if you have done helm-multi-swoop before.
58 |
59 | #### `M-x helm-multi-swoop-org`
60 | Skip the select phase and apply to all org-mode buffers
61 |
62 | #### `M-x helm-multi-swoop-current-mode`
63 | Skip the select phase and apply to all buffers with the same major mode as the current buffer
64 |
65 | #### `M-x helm-multi-swoop-projectile`
66 | Skip the select phase and apply to all opened buffers of the current project.
67 | It requires projectile to be installed.
68 | You may specify a filter that will be used for buffers
69 | by setting variable `helm-multi-swoop-projectile-buffers-filter`.
70 | By default its value is `projectile-buffers-with-file-or-process`.
71 |
72 | #### Multiline behavior
73 | `M-4 M-x helm-swoop` or `C-u 4 M-x helm-swoop`
74 |
75 | 
76 |
77 | ### Config
78 |
79 | ```elisp
80 | ;; helm from https://github.com/emacs-helm/helm
81 | (require 'helm)
82 |
83 | ;; Locate the helm-swoop folder to your path
84 | (add-to-list 'load-path "~/.emacs.d/elisp/helm-swoop")
85 | (require 'helm-swoop)
86 |
87 | ;; Change the keybinds to whatever you like :)
88 | (global-set-key (kbd "M-i") 'helm-swoop)
89 | (global-set-key (kbd "M-I") 'helm-swoop-back-to-last-point)
90 | (global-set-key (kbd "C-c M-i") 'helm-multi-swoop)
91 | (global-set-key (kbd "C-x M-i") 'helm-multi-swoop-all)
92 |
93 | ;; When doing isearch, hand the word over to helm-swoop
94 | (define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)
95 | ;; From helm-swoop to helm-multi-swoop-all
96 | (define-key helm-swoop-map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop)
97 | ;; When doing evil-search, hand the word over to helm-swoop
98 | ;; (define-key evil-motion-state-map (kbd "M-i") 'helm-swoop-from-evil-search)
99 |
100 | ;; Instead of helm-multi-swoop-all, you can also use helm-multi-swoop-current-mode
101 | (define-key helm-swoop-map (kbd "M-m") 'helm-multi-swoop-current-mode-from-helm-swoop)
102 |
103 | ;; Move up and down like isearch
104 | (define-key helm-swoop-map (kbd "C-r") 'helm-previous-line)
105 | (define-key helm-swoop-map (kbd "C-s") 'helm-next-line)
106 | (define-key helm-multi-swoop-map (kbd "C-r") 'helm-previous-line)
107 | (define-key helm-multi-swoop-map (kbd "C-s") 'helm-next-line)
108 |
109 | ;; Save buffer when helm-multi-swoop-edit complete
110 | (setq helm-multi-swoop-edit-save t)
111 |
112 | ;; If this value is t, split window inside the current window
113 | (setq helm-swoop-split-with-multiple-windows nil)
114 |
115 | ;; Split direcion. 'split-window-vertically or 'split-window-horizontally
116 | (setq helm-swoop-split-direction 'split-window-vertically)
117 |
118 | ;; If nil, you can slightly boost invoke speed in exchange for text color
119 | (setq helm-swoop-speed-or-color nil)
120 |
121 | ;; ;; Go to the opposite side of line from the end or beginning of line
122 | (setq helm-swoop-move-to-line-cycle t)
123 |
124 | ;; Optional face for line numbers
125 | ;; Face name is `helm-swoop-line-number-face`
126 | (setq helm-swoop-use-line-number-face t)
127 |
128 | ;; If you prefer fuzzy matching
129 | (setq helm-swoop-use-fuzzy-match t)
130 |
131 | ;; If you would like to use migemo, enable helm's migemo feature
132 | (helm-migemo-mode 1)
133 | ```
134 |
135 | #### Configure pre-input search query
136 |
137 | By default, helm-swoop uses search query at the cursor.
138 | You can configure this behavior by setting `helm-swoop-pre-input-function` on your own.
139 |
140 | i.e.
141 |
142 | ```elisp
143 | ;; Use search query at the cursor (default)
144 | (setq helm-swoop-pre-input-function
145 | (lambda () (thing-at-point 'symbol)))
146 |
147 | ;; Disable pre-input
148 | (setq helm-swoop-pre-input-function
149 | (lambda () ""))
150 | ;; Or, just use M-x helm-swoop-without-pre-input
151 |
152 | ;; Match only for symbol
153 | (setq helm-swoop-pre-input-function
154 | (lambda () (format "\\_<%s\\_> " (thing-at-point 'symbol))))
155 |
156 | ;; Always use the previous search for helm. Remember C- will delete entire line
157 | (setq helm-swoop-pre-input-function
158 | (lambda () (if (boundp 'helm-swoop-pattern)
159 | helm-swoop-pattern "")))
160 |
161 | ;; If there is no symbol at the cursor, use the last used words instead.
162 | (setq helm-swoop-pre-input-function
163 | (lambda ()
164 | (let (($pre-input (thing-at-point 'symbol)))
165 | (if (eq (length $pre-input) 0)
166 | helm-swoop-pattern ;; this variable keeps the last used words
167 | $pre-input))))
168 |
169 | ;; If a symbol or phrase is selected, use it as the initial query.
170 | (setq helm-swoop-pre-input-function
171 | (lambda ()
172 | (if mark-active
173 | (buffer-substring-no-properties (mark) (point))
174 | "")))
175 | ```
176 |
177 | ### Require
178 |
179 | [helm.el](https://github.com/emacs-helm/helm)
180 |
181 | ### Contribution
182 | We welcome PR!
183 |
184 | #### Require tools for testing
185 | - cask
186 | - install via brew
187 | ```
188 | brew install cask
189 | ```
190 |
191 | - manual install
192 | ```
193 | cd ~/
194 | hub clone cask/cask
195 | export PATH="$HOME/.cask/bin:$PATH"
196 | ```
197 |
198 | ### License
199 | > General Public License Version 3 (GPLv3)
200 | > Copyright (c) Emacsorphanage - https://github.com/emacsorphanage
201 | > https://www.gnu.org/licenses/gpl-3.0.html
202 |
203 | [melpa-link]: http://melpa.org/#/helm-swoop
204 | [melpa-badge]: http://melpa.org/packages/helm-swoop-badge.svg
205 | [melpa-stable-link]: http://stable.melpa.org/#/helm-swoop
206 | [melpa-stable-badge]: http://stable.melpa.org/packages/helm-swoop-badge.svg
207 | [github-actions-link]: https://github.com/emacsorphanage/helm-swoop/actions
208 | [github-actions-badge]: https://github.com/emacsorphanage/helm-swoop/workflows/Main%20workflow/badge.svg
209 |
--------------------------------------------------------------------------------
/helm-swoop.el:
--------------------------------------------------------------------------------
1 | ;;; helm-swoop.el --- Efficiently hopping squeezed lines powered by helm interface -*- lexical-binding: t -*-
2 |
3 | ;; Copyright (C) 2019 Emacsorphanage Community
4 | ;; Copyright (C) 2013-2018 Shingo Fukuyama
5 |
6 | ;; Version: 3.0.0
7 | ;; Author: Shingo Fukuyama - http://fukuyama.co
8 | ;; URL: https://github.com/emacsorphanage/helm-swoop
9 | ;; Created: Oct 24 2013
10 | ;; Keywords: convenience, helm, swoop, inner, buffer, search
11 | ;; Package-Requires: ((emacs "25.1") (helm "3.6"))
12 |
13 | ;; This program is free software: you can redistribute it and/or modify
14 | ;; it under the terms of the GNU General Public License as published by
15 | ;; the Free Software Foundation, either version 3 of the License, or
16 | ;; (at your option) any later version.
17 |
18 | ;; This program is distributed in the hope that it will be useful,
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 | ;; See the GNU General Public License for more details.
22 |
23 | ;; You should have received a copy of the GNU General Public License
24 | ;; along with this program. If not, see .
25 |
26 | ;;; Commentary:
27 |
28 | ;; List the all lines to another buffer, which is able to squeeze
29 | ;; by any words you input. At the same time, the original buffer's
30 | ;; cursor is jumping line to line according to moving up and down
31 | ;; the list.
32 |
33 | ;; Example config
34 | ;; ----------------------------------------------------------------
35 | ;; ;; helm from https://github.com/emacs-helm/helm
36 | ;; (require 'helm)
37 |
38 | ;; ;; Locate the helm-swoop folder to your path
39 | ;; ;; This line is unnecessary if you get this program from MELPA
40 | ;; (add-to-list 'load-path "~/.emacs.d/elisp/helm-swoop")
41 |
42 | ;; (require 'helm-swoop)
43 |
44 | ;; ;; Change keybinds to whatever you like :)
45 | ;; (global-set-key (kbd "M-i") 'helm-swoop)
46 | ;; (global-set-key (kbd "M-I") 'helm-swoop-back-to-last-point)
47 | ;; (global-set-key (kbd "C-c M-i") 'helm-multi-swoop)
48 | ;; (global-set-key (kbd "C-x M-i") 'helm-multi-swoop-all)
49 |
50 | ;; ;; When doing isearch, hand the word over to helm-swoop
51 | ;; (define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)
52 | ;; (define-key helm-swoop-map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop)
53 |
54 | ;; ;; Save buffer when helm-multi-swoop-edit complete
55 | ;; (setq helm-multi-swoop-edit-save t)
56 |
57 | ;; ;; If this value is t, split window inside the current window
58 | ;; (setq helm-swoop-split-with-multiple-windows nil)
59 |
60 | ;; ;; Split direction. 'split-window-vertically or 'split-window-horizontally
61 | ;; (setq helm-swoop-split-direction 'split-window-vertically)
62 |
63 | ;; ;; If nil, you can slightly boost invoke speed in exchange for text color
64 | ;; (setq helm-swoop-speed-or-color nil)
65 |
66 | ;; ;; Go to the opposite side of line from the end or beginning of line
67 | ;; (setq helm-swoop-move-to-line-cycle t)
68 |
69 | ;; ;; Optional face for line numbers
70 | ;; ;; Face name is `helm-swoop-line-number-face`
71 | ;; (setq helm-swoop-use-line-number-face t)
72 |
73 | ;; ----------------------------------------------------------------
74 |
75 | ;; * `M-x helm-swoop` when region active
76 | ;; * `M-x helm-swoop` when the cursor is at any symbol
77 | ;; * `M-x helm-swoop` when the cursor is not at any symbol
78 | ;; * `M-3 M-x helm-swoop` or `C-u 5 M-x helm-swoop` multi separated line culling
79 | ;; * `M-x helm-multi-swoop` multi-occur like feature
80 | ;; * `M-x helm-multi-swoop-all` apply all buffers
81 | ;; * `C-u M-x helm-multi-swoop` apply last selected buffers from the second time
82 | ;; * `M-x helm-swoop-same-face-at-point` list lines have the same face at the cursor is on
83 | ;; * During isearch `M-i` to hand the word over to helm-swoop
84 | ;; * During helm-swoop `M-i` to hand the word over to helm-multi-swoop-all
85 | ;; * While doing `helm-swoop` press `C-c C-e` to edit mode, apply changes to original buffer by `C-x C-s`
86 |
87 | ;; Helm Swoop Edit
88 | ;; While doing helm-swoop, press keybind [C-c C-e] to move to edit buffer.
89 | ;; Edit the list and apply by [C-x C-s]. If you'd like to cancel, [C-c C-g]
90 |
91 | ;;; Code:
92 |
93 | (require 'cl-lib)
94 | (require 'helm)
95 | (require 'helm-utils)
96 | (require 'helm-grep)
97 |
98 | (declare-function migemo-search-pattern-get "ext:migemo")
99 | (declare-function migemo-forward "ext:migemo")
100 | (declare-function projectile-buffers-with-file-or-process "ext:projectile")
101 | (declare-function projectile-project-buffers "ext:projectile")
102 | (defvar projectile-buffers-filter-function)
103 |
104 | ;;; @ helm-swoop ----------------------------------------------
105 |
106 | (defgroup helm-swoop nil
107 | "Open helm-swoop."
108 | :prefix "helm-swoop-" :group 'helm)
109 |
110 | (defface helm-swoop-target-line-face
111 | '((t (:background "#e3e300" :foreground "#222222")))
112 | "Face for helm-swoop target line"
113 | :group 'helm-swoop)
114 | (defface helm-swoop-target-line-block-face
115 | '((t (:background "#cccc00" :foreground "#222222")))
116 | "Face for target line"
117 | :group 'helm-swoop)
118 | (defface helm-swoop-target-word-face
119 | '((t (:background "#7700ff" :foreground "#ffffff")))
120 | "Face for target word"
121 | :group 'helm-swoop)
122 | (defface helm-swoop-line-number-face
123 | '((t (:foreground "#999999")))
124 | "Face for line numbers"
125 | :group 'helm-swoop)
126 |
127 | (defcustom helm-swoop-speed-or-color nil
128 | "If nil, you can slightly boost invoke speed in exchange for text color."
129 | :group 'helm-swoop :type 'boolean)
130 | (defcustom helm-swoop-use-line-number-face nil
131 | "Use face to line numbers on helm-swoop buffer."
132 | :group 'helm-swoop :type 'boolean)
133 | (defcustom helm-swoop-split-with-multiple-windows nil
134 | "Split window when having multiple windows open."
135 | :group 'helm-swoop :type 'boolean)
136 | (defcustom helm-swoop-move-to-line-cycle t
137 | "Return to the opposite side of line."
138 | :group 'helm-swoop :type 'boolean)
139 | (defcustom helm-swoop-split-direction 'split-window-vertically
140 | "Split direction."
141 | :type '(choice (const :tag "vertically" split-window-vertically)
142 | (const :tag "horizontally" split-window-horizontally))
143 | :group 'helm-swoop)
144 | (defcustom helm-swoop-use-fuzzy-match nil
145 | "If t, use fuzzy matching functions as well as exact matches."
146 | :group 'helm-swoop :type 'boolean)
147 | (defcustom helm-swoop-min-overlay-length 2
148 | "Minimum pattern length before applying the overlay on the matched word."
149 | :group 'helm-swoop :type 'integer)
150 |
151 | (defvar helm-swoop-split-window-function
152 | (lambda (buf &rest _args)
153 | (if helm-swoop-split-with-multiple-windows
154 | (funcall helm-swoop-split-direction)
155 | (when (one-window-p)
156 | (funcall helm-swoop-split-direction)))
157 | (other-window 1)
158 | (switch-to-buffer buf))
159 | "Change the way to split window only when `helm-swoop' is calling.")
160 |
161 | (defcustom helm-swoop-after-goto-line-action-hook nil
162 | "The hook run after `helm-swoop--goto-line."
163 | :group 'helm-swoop
164 | :type 'hook)
165 | (defcustom helm-swoop-before-goto-line-action-hook nil
166 | "The hook run before `helm-swoop--goto-line."
167 | :group 'helm-swoop
168 | :type 'hook)
169 |
170 | (defcustom helm-swoop-flash-region-function 'helm-swoop-flash-word
171 | "The function used to flash the result when a search done."
172 | :group 'helm-swoop
173 | :type '(choice
174 | (const :tag "Default highlight function" helm-swoop-flash-word)
175 | (const :tag "Pulse highlight function" pulse-momentary-highlight-region)
176 | function))
177 |
178 | (defcustom helm-swoop-fontify-buffer-size-limit 100000
179 | "If buffer size smaller than value, do fontify to make buffer highlighted.
180 |
181 | If value is symbol `always', always do fontify."
182 | :group 'helm-swoop
183 | :type '(choice
184 | integer
185 | (const :tag "Always Fontify" always)))
186 |
187 | (defvar helm-swoop-candidate-number-limit 19999)
188 | (defvar helm-swoop-buffer "*Helm Swoop*")
189 | (defvar helm-swoop-prompt "Swoop: ")
190 | (defvar helm-swoop-last-point nil)
191 | (defvar helm-swoop-invisible-targets nil)
192 | (defvar helm-swoop-last-line-info nil)
193 |
194 | ;; Buffer local variables
195 | (defvar helm-swoop-list-cache)
196 | (defvar helm-swoop-pattern nil) ; Keep helm-pattern value
197 | (defvar helm-swoop-last-query nil) ; Last search query for resume
198 | (defvar-local helm-swoop-last-prefix-number 1) ; For multiline highlight
199 |
200 | ;; Global variables
201 | (defvar helm-swoop-synchronizing-window nil
202 | "Window object where `helm-swoop' called from.")
203 | (defvar helm-swoop-target-buffer nil
204 | "Buffer object where `helm-swoop' called from.")
205 | (defvar helm-swoop-line-overlay nil
206 | "Overlay object to indicate other window's line.")
207 |
208 | (defvar helm-swoop--basic-map
209 | (let ((map (make-sparse-keymap)))
210 | (set-keymap-parent map helm-map)
211 | (dolist (action '(next-line previous-line next-page previous-page
212 | beginning-of-buffer end-of-buffer toggle-visible-mark))
213 | (let ((orig-fn (intern (format "helm-%s" action)))
214 | (new-fn (intern (format "helm-swoop-%s" action))))
215 | (defalias new-fn `(lambda (&optional arg)
216 | (interactive "p")
217 | (call-interactively ',orig-fn)
218 | (helm-swoop--move-line-action))
219 | (format "Replacement of `%s' action for `helm-swoop'.
220 |
221 | \(fn ARG)" orig-fn))
222 | (define-key map `[remap ,orig-fn] new-fn)))
223 | map))
224 |
225 | (defvar helm-swoop-map
226 | (let ((map (make-sparse-keymap)))
227 | (set-keymap-parent map helm-swoop--basic-map)
228 | (define-key map (kbd "C-c C-e") 'helm-swoop-edit)
229 | (define-key map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop)
230 | (define-key map (kbd "C-w") 'helm-swoop-yank-thing-at-point)
231 | map)
232 | "Keymap for helm-swoop.")
233 |
234 | (defvar helm-multi-swoop--basic-map
235 | (let ((map (make-sparse-keymap)))
236 | (set-keymap-parent map helm-map)
237 | (dolist (action '(next-line previous-line next-page previous-page
238 | beginning-of-buffer end-of-buffer toggle-visible-mark))
239 | (let ((orig-fn (intern (format "helm-%s" action)))
240 | (new-fn (intern (format "helm-multi-swoop-%s" action))))
241 | (defalias new-fn `(lambda (&optional arg)
242 | (interactive "p")
243 | (call-interactively ',orig-fn)
244 | (helm-multi-swoop--move-line-action))
245 | (format "Replacement of `%s' action for `helm-multi-swoop'.
246 |
247 | \(fn ARG)" orig-fn))
248 | (define-key map `[remap ,orig-fn] new-fn)))
249 | map))
250 |
251 | (defvar helm-multi-swoop-map
252 | (let ((map (make-sparse-keymap)))
253 | (set-keymap-parent map helm-multi-swoop--basic-map)
254 | (define-key map (kbd "C-c C-e") 'helm-multi-swoop-edit)
255 | map))
256 |
257 | (defvar helm-c-source-swoop-match-functions
258 | '(helm-mm-exact-match
259 | helm-mm-match
260 | helm-mm-3-migemo-match))
261 |
262 | (defvar helm-c-source-swoop-search-functions
263 | '(helm-mm-exact-search
264 | helm-mm-search
265 | helm-candidates-in-buffer-search-default-fn
266 | helm-mm-3-migemo-search))
267 |
268 | (defvar helm-swoop-font-lock-exclude
269 | '(Man-mode
270 | adoc-mode
271 | bbdb-mode
272 | bongo-library-mode
273 | bongo-mode
274 | bongo-playlist-mode
275 | bookmark-bmenu-mode
276 | circe-channel-mode
277 | circe-query-mode
278 | circe-server-mode
279 | deadgrep-mode
280 | debbugs-gnu-mode
281 | dired-mode
282 | elfeed-search-mode
283 | elfeed-show-mode
284 | emms-playlist-mode
285 | emms-stream-mode
286 | erc-mode
287 | eshell-mode
288 | eww-mode
289 | forth-block-mode
290 | forth-mode
291 | fundamental-mode
292 | gnus-article-mode
293 | gnus-group-mode
294 | gnus-summary-mode
295 | help-mode
296 | helpful-mode
297 | jabber-chat-mode
298 | magit-popup-mode
299 | matrix-client-mode
300 | matrix-client-room-list-mode
301 | mu4e-headers-mode
302 | mu4e-view-mode
303 | nix-mode
304 | notmuch-search-mode
305 | notmuch-tree-mode
306 | occur-edit-mode
307 | occur-mode
308 | org-agenda-mode
309 | package-menu-mode
310 | rcirc-mode
311 | sauron-mode
312 | treemacs-mode
313 | twittering-mode
314 | vc-dir-mode
315 | w3m-mode
316 | woman-mode
317 | xref--xref-buffer-mode)
318 | "List of major-modes that are incompatible with `font-lock-ensure'.")
319 |
320 | (defun helm-swoop-match-functions ()
321 | "Return match functions."
322 | (if helm-swoop-use-fuzzy-match
323 | (append helm-c-source-swoop-match-functions '(helm-fuzzy-match))
324 | helm-c-source-swoop-match-functions))
325 |
326 | (defun helm-swoop-search-functions ()
327 | "Return search functions."
328 | (if helm-swoop-use-fuzzy-match
329 | (append helm-c-source-swoop-search-functions '(helm-fuzzy-search))
330 | helm-c-source-swoop-search-functions))
331 |
332 | (defcustom helm-swoop-pre-input-function
333 | (lambda () (thing-at-point 'symbol))
334 | "This function can pre-input keywords when helm-swoop invoked."
335 | :group 'helm-swoop :type 'function)
336 |
337 | (defun helm-swoop-pre-input-optimize (query)
338 | "Return QUERY processed by `regexp-quote'."
339 | (when query (regexp-quote query)))
340 |
341 | (defsubst helm-swoop--goto-line (line)
342 | "Go to LINE concider narrowing."
343 | (goto-char (point-min))
344 | (forward-line (1- line)))
345 |
346 | (defsubst helm-swoop--recenter ()
347 | "Recenter."
348 | (recenter (/ (window-height) 2)))
349 |
350 | (defsubst helm-swoop--delete-overlay (identity &optional beg end)
351 | "Delete overlay if IDENTITY has in BEG to END."
352 | (overlay-recenter (or end (point-max)))
353 | (mapc (lambda (ov)
354 | (if (overlay-get ov identity)
355 | (delete-overlay ov)))
356 | (overlays-in (or beg (point-min)) (or end (point-max)))))
357 |
358 | (defsubst helm-swoop--get-string-at-line ()
359 | "Get line string with no properties."
360 | (buffer-substring-no-properties (line-beginning-position)
361 | (line-end-position)))
362 |
363 | (defun helm-swoop--buffer-substring (beg end)
364 | "Get buffer substring BEG to END."
365 | (if helm-swoop-speed-or-color
366 | (let ((content (buffer-substring beg end)))
367 | (propertize content 'read-only nil))
368 | (buffer-substring-no-properties beg end)))
369 |
370 | ;;;###autoload
371 | (defun helm-swoop-back-to-last-point (&optional cancel)
372 | "Go back to last position where `helm-swoop' was called.
373 | If CANCEL is non-nil, store `helm-swoop-last-point'."
374 | (interactive)
375 | (if helm-swoop-last-point
376 | (let ((po (point)))
377 | (switch-to-buffer (cdr helm-swoop-last-point))
378 | (goto-char (car helm-swoop-last-point))
379 | (unless cancel
380 | (setq helm-swoop-last-point
381 | (cons po (buffer-name (current-buffer))))))))
382 |
383 | (defun helm-swoop--split-lines-by (string regexp step)
384 | "Return STRING processed by `split-string' with REGEXP by STEP for multiline."
385 | (or step (setq step 1))
386 | (let ((from1 0) ;; last match point
387 | (from2 0) ;; last substring point
388 | list
389 | (i 1)) ;; from line 1
390 | (while (string-match regexp string from1)
391 | (setq i (1+ i))
392 | (if (eq 0 (% i step))
393 | (progn
394 | (setq list (cons (substring string from2 (match-beginning 0))
395 | list))
396 | (setq from2 (match-end 0))
397 | (setq from1 (match-end 0)))
398 | (setq from1 (match-end 0))))
399 | (setq list (cons (substring string from2) list))
400 | (nreverse list)))
401 |
402 | (defun helm-swoop--target-line-overlay-move (&optional buf)
403 | "Add color to the target line in BUF."
404 | (move-overlay
405 | helm-swoop-line-overlay
406 | (progn
407 | (search-backward
408 | "\n" nil t (% (line-number-at-pos) helm-swoop-last-prefix-number))
409 | (goto-char (line-beginning-position)))
410 | ;; For multiline highlight
411 | (save-excursion
412 | (goto-char (line-beginning-position))
413 | (or (re-search-forward "\n" nil t helm-swoop-last-prefix-number)
414 | ;; For the end of buffer error
415 | (point-max)))
416 | buf)
417 | (helm-swoop--unveil-invisible-overlay))
418 |
419 | (defun helm-swoop--validate-regexp (regexp)
420 | "Validate REGEXP."
421 | (condition-case _err
422 | (progn
423 | (string-match-p regexp "")
424 | t)
425 | (invalid-regexp nil)))
426 |
427 | (defun helm-swoop--target-word-overlay (identity &optional threshold)
428 | "Target ward overlay to IDENTITY with THRESHOLD."
429 | (interactive)
430 | (save-excursion
431 | (let ((pattern (split-string helm-pattern " "))
432 | (threshold (or threshold 2))
433 | ov)
434 | (mapc (lambda (wd)
435 | (when (and (helm-swoop--validate-regexp wd) (< threshold (length wd)))
436 | (goto-char (point-min))
437 | ;; Optional require migemo.el
438 | (if (and (featurep 'migemo) helm-migemo-mode)
439 | (setq wd (migemo-search-pattern-get wd)))
440 | ;; For caret begging match
441 | (if (string-match "^\\^\\[0\\-9\\]\\+\\.\\(.+\\)" wd)
442 | (setq wd (concat "^" (match-string 1 wd))))
443 | (overlay-recenter (point-max))
444 | (while (and (not (eobp)) (re-search-forward wd nil t))
445 | (if (= (match-beginning 0) (match-end 0))
446 | (forward-char 1)
447 | (setq ov (make-overlay (match-beginning 0) (match-end 0)))
448 | (overlay-put ov 'face 'helm-swoop-target-word-face)
449 | (overlay-put ov identity t)))))
450 | pattern))))
451 |
452 | (defun helm-swoop--restore-unveiled-overlay ()
453 | "Restore unveiled overlay."
454 | (when helm-swoop-invisible-targets
455 | (mapc (lambda (ov) (overlay-put (car ov) 'invisible (cdr ov)))
456 | helm-swoop-invisible-targets)
457 | (setq helm-swoop-invisible-targets nil)))
458 |
459 | (defun helm-swoop--unveil-invisible-overlay ()
460 | "Show hidden text temporarily to view it during helm-swoop.
461 | This function needs to call after latest helm-swoop-line-overlay set."
462 | (helm-swoop--restore-unveiled-overlay)
463 | (mapc (lambda (ov)
464 | (let ((type (overlay-get ov 'invisible)))
465 | (when type
466 | (overlay-put ov 'invisible nil)
467 | (setq helm-swoop-invisible-targets
468 | (cons (cons ov type) helm-swoop-invisible-targets)))))
469 | (overlays-in (overlay-start helm-swoop-line-overlay)
470 | (overlay-end helm-swoop-line-overlay))))
471 |
472 | ;; helm action ------------------------------------------------
473 |
474 | (defun helm-swoop--move-line-action ()
475 | "Move line action."
476 | (with-helm-window
477 | (let* ((key (helm-swoop--get-string-at-line))
478 | (num (when (string-match "^[0-9]+" key)
479 | (string-to-number (match-string 0 key)))))
480 | ;; Synchronizing line position
481 | (when (and key num)
482 | (with-selected-window helm-swoop-synchronizing-window
483 | (helm-swoop--goto-line num)
484 | (with-current-buffer helm-swoop-target-buffer
485 | (delete-overlay helm-swoop-line-overlay)
486 | (helm-swoop--target-line-overlay-move))
487 | (helm-swoop--recenter))
488 | (setq helm-swoop-last-line-info
489 | (cons helm-swoop-target-buffer num))))))
490 |
491 | (defun helm-swoop--nearest-line (target list)
492 | "Return the nearest number of TARGET out of LIST."
493 | (when (and target list)
494 | (let (res)
495 | (cl-labels ((filter (fn elm list)
496 | (let (r)
497 | (mapc (lambda (e)
498 | (if (funcall fn elm e)
499 | (setq r (cons e r))))
500 | list) r)))
501 | (if (eq 1 (length list))
502 | (setq res (car list))
503 | (let* ((lts (filter '> target list))
504 | (gts (filter '< target list))
505 | (lt (if lts (apply 'max lts)))
506 | (gt (if gts (apply 'min gts)))
507 | (ltg (if lt (- target lt)))
508 | (gtg (if gt (- gt target))))
509 | (setq res
510 | (cond ((memq target list) target)
511 | ((and (not lt) (not gt)) nil)
512 | ((not gtg) lt)
513 | ((not ltg) gt)
514 | ((eq ltg gtg) gt)
515 | ((< ltg gtg) lt)
516 | ((> ltg gtg) gt)
517 | (t 1))))))
518 | res)))
519 |
520 | (defun helm-swoop--keep-nearest-position ()
521 | "Keep nearest position."
522 | (with-helm-window
523 | (let ((p (point-min))
524 | (buf (rx-to-string (buffer-name (car helm-swoop-last-line-info)) t))
525 | list bound nearest-line target-point)
526 | (save-excursion
527 | (goto-char p)
528 | (while (if p (setq p (re-search-forward (concat "^" buf "$") nil t)))
529 | (when (get-text-property (line-beginning-position) 'helm-header)
530 | (forward-char 1)
531 | (setq bound (next-single-property-change (point) 'helm-header))
532 | (while (re-search-forward "^[0-9]+" bound t)
533 | (setq list (cons
534 | (string-to-number (match-string 0))
535 | list)))
536 | (setq nearest-line (helm-swoop--nearest-line
537 | (cdr helm-swoop-last-line-info)
538 | list))
539 | (goto-char p)
540 | (re-search-forward (concat "^"
541 | (number-to-string nearest-line)
542 | "\\s-") bound t)
543 | (setq target-point (point))
544 | (setq p nil))))
545 | (when target-point
546 | (goto-char target-point)
547 | (helm-mark-current-line)
548 | (if (equal helm-swoop-buffer (buffer-name (current-buffer)))
549 | (helm-swoop--move-line-action)
550 | (helm-multi-swoop--move-line-action))))))
551 |
552 | (defun helm-swoop--pattern-match ()
553 | "Overlay target words."
554 | (with-helm-window
555 | (setq helm-swoop-pattern helm-pattern)
556 | (when (< helm-swoop-min-overlay-length (length helm-pattern))
557 | (helm-swoop--delete-overlay 'target-buffer)
558 | (helm-swoop--target-word-overlay 'target-buffer helm-swoop-min-overlay-length)
559 | (with-selected-window helm-swoop-synchronizing-window
560 | (helm-swoop--delete-overlay 'target-buffer)
561 | (helm-swoop--target-word-overlay 'target-buffer helm-swoop-min-overlay-length)))))
562 |
563 | (defun helm-swoop-flash-word (match-beg match-end)
564 | "Flash ward in MATCH-BEG to MATCH-END."
565 | (interactive)
566 | (unwind-protect
567 | (let ((ov (make-overlay match-beg match-end)))
568 | (when ov
569 | (overlay-put ov 'face 'helm-swoop-target-word-face)
570 | (overlay-put ov 'helm-swoop-overlay-word-frash t)))
571 | (run-with-idle-timer
572 | 0.6 nil (lambda () (helm-swoop--delete-overlay 'helm-swoop-overlay-word-frash)))))
573 |
574 | ;; core ------------------------------------------------
575 |
576 | (defun helm-swoop--match-part (candidate)
577 | "Extract the proper part of CANDIDATE."
578 | (replace-regexp-in-string (rx bol (+? digit) " ") "" candidate))
579 |
580 | (defun helm-swoop--maybe-fontify! ()
581 | "Ensure the entired buffer is highlighted."
582 | (let ((fontify-safe-p (not (or (derived-mode-p 'magit-mode)
583 | (bound-and-true-p magit-blame-mode)
584 | (memq major-mode helm-swoop-font-lock-exclude)
585 | (not (derived-mode-p 'prog-mode))))))
586 | (when (and helm-swoop-speed-or-color
587 | font-lock-mode
588 | fontify-safe-p
589 | (or (eq 'always helm-swoop-fontify-buffer-size-limit)
590 | (< (buffer-size) helm-swoop-fontify-buffer-size-limit)))
591 | (if (fboundp 'font-lock-ensure)
592 | (font-lock-ensure)
593 | (with-no-warnings (font-lock-fontify-buffer))))))
594 |
595 | (defun helm-swoop--get-content (buffer &optional linum)
596 | "Get the whole content in BUFFER and add line number at the head.
597 | If LINUM is number, lines are separated by LINUM."
598 | (let ((buf (get-buffer buffer)))
599 | (when buf
600 | (with-current-buffer buf
601 | (helm-swoop--maybe-fontify!)
602 | (let ((bufstr (helm-swoop--buffer-substring (point-min) (point-max))))
603 | (with-temp-buffer
604 | (insert bufstr)
605 | (goto-char (point-min))
606 | (let ((i 1))
607 | (insert (format "%s " i))
608 | (while (re-search-forward "\n" nil t)
609 | (setq i (1+ i))
610 | (if helm-swoop-use-line-number-face
611 | (insert (propertize (format "%s" i) 'font-lock-face 'helm-swoop-line-number-face) " ")
612 | (insert (format "%s " i))))
613 | ;; Delete empty lines
614 | (unless linum
615 | (goto-char (point-min))
616 | (while (re-search-forward "^[0-9]+\\s-*$" nil t)
617 | (replace-match ""))))
618 | (helm-swoop--buffer-substring (point-min) (point-max))))))))
619 |
620 | (defun helm-swoop--goto-line-action (line &optional other-window)
621 | "Goto LINE action. If OTHER-WINDOW is non-nil, a new window will be open."
622 | (run-hooks 'helm-swoop-before-goto-line-action-hook)
623 | (when other-window
624 | (switch-to-buffer-other-window (current-buffer)))
625 | (helm-swoop--goto-line
626 | (when (string-match "^[0-9]+" line)
627 | (string-to-number (match-string 0 line))))
628 | (let ((regex (mapconcat 'identity (split-string helm-pattern " ") "\\|")))
629 | (when (or (and (featurep 'migemo) helm-migemo-mode (migemo-forward regex nil t))
630 | (re-search-forward regex nil t))
631 | (funcall helm-swoop-flash-region-function
632 | (match-beginning 0) (match-end 0))
633 | (goto-char (match-beginning 0))
634 | (run-hooks 'helm-swoop-after-goto-line-action-hook)))
635 | (helm-swoop--recenter))
636 |
637 | (defun helm-c-source-swoop ()
638 | "C source swoop."
639 | `((name . ,(buffer-name helm-swoop-target-buffer))
640 | (candidates . ,(if helm-swoop-list-cache
641 | (progn
642 | (helm-swoop--split-lines-by
643 | helm-swoop-list-cache "\n" helm-swoop-last-prefix-number))
644 | (helm-swoop--split-lines-by
645 | (setq helm-swoop-list-cache
646 | (helm-swoop--get-content helm-swoop-target-buffer t))
647 | "\n" helm-swoop-last-prefix-number)))
648 | (get-line . ,#'helm-swoop--buffer-substring)
649 | (keymap . ,helm-swoop-map)
650 | (header-line . ,(substitute-command-keys
651 | "[\\\\[helm-swoop-edit]] Edit mode, \
652 | [\\\\[helm-multi-swoop-all-from-helm-swoop]] apply all buffers"))
653 | (action . (("Go to Line" . helm-swoop--goto-line-action)
654 | ("Edit" . helm-swoop--edit)
655 | ("Go to Line in Other Window" . (lambda (line) (helm-swoop--goto-line-action line t)))))
656 | ,(if (and helm-swoop-last-prefix-number
657 | (> helm-swoop-last-prefix-number 1))
658 | '(multiline))
659 | (match . ,(helm-swoop-match-functions))
660 | (match-part . ,#'helm-swoop--match-part)
661 | ;; (search . ,(helm-swoop-search-functions))
662 | ))
663 |
664 | (defun helm-c-source-multi-swoop (buf func action multiline)
665 | "C source multi swoop in BUF for FUNC, ACTION, MULTILINE."
666 | `((name . ,buf)
667 | (candidates . ,(funcall func))
668 | (action . ,action)
669 | (header-line . ,(concat buf
670 | (substitute-command-keys
671 | " [\\\\[helm-multi-swoop-edit]] Edit mode")))
672 | (keymap . ,helm-multi-swoop-map)
673 | (requires-pattern . 2)
674 | ,(if (and multiline
675 | (> multiline 1))
676 | '(multiline))
677 | (match . ,(helm-swoop-match-functions))
678 | (match-part . ,#'helm-swoop--match-part)
679 | ;; (search . ,(helm-swoop-search-functions))
680 | ))
681 |
682 | (defun helm-swoop--set-prefix (multiline)
683 | "Set prefix MULTILINE."
684 | ;; Enable scrolling margin
685 | (setq helm-swoop-last-prefix-number
686 | (or multiline 1))) ;; multiline is for resume
687 |
688 | ;; Delete cache when buffer is saved or file changes on disk
689 | (defun helm-swoop--clear-cache ()
690 | "Delete cache when buffer is saved or file change on disk."
691 | (if (boundp 'helm-swoop-list-cache) (setq helm-swoop-list-cache nil)))
692 | (add-hook 'after-save-hook 'helm-swoop--clear-cache)
693 | (add-hook 'after-revert-hook 'helm-swoop--clear-cache)
694 |
695 | (defadvice narrow-to-region (around helm-swoop-advice-narrow-to-region activate)
696 | "Advice for `narrow-to-region'."
697 | (helm-swoop--clear-cache)
698 | ad-do-it)
699 | (defadvice narrow-to-defun (around helm-swoop-advice-narrow-to-defun activate)
700 | "Advice for `narrow-to-defun'."
701 | (helm-swoop--clear-cache)
702 | ad-do-it)
703 | (defadvice narrow-to-page (around helm-swoop-advice-narrow-to-page activate)
704 | "Advice for `narrow-to-page'."
705 | (helm-swoop--clear-cache)
706 | ad-do-it)
707 | (defadvice widen (around helm-swoop-advice-widen activate)
708 | "Advice for `widen'."
709 | (helm-swoop--clear-cache)
710 | ad-do-it)
711 |
712 | (defun helm-swoop--restore ()
713 | "Restore."
714 | (when (= 1 helm-exit-status)
715 | (helm-swoop-back-to-last-point t)
716 | (helm-swoop--restore-unveiled-overlay))
717 | (setq helm-swoop-invisible-targets nil)
718 | (remove-hook 'helm-after-update-hook 'helm-swoop--pattern-match)
719 | (remove-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position)
720 | (setq helm-swoop-last-query helm-swoop-pattern)
721 | (mapc (lambda (ov)
722 | (when (or (eq 'helm-swoop-target-line-face (overlay-get ov 'face))
723 | (eq 'helm-swoop-target-line-block-face
724 | (overlay-get ov 'face)))
725 | (delete-overlay ov)))
726 | (overlays-in (point-min) (point-max)))
727 | (helm-swoop--delete-overlay 'target-buffer)
728 | (deactivate-mark t))
729 |
730 | ;;;###autoload
731 | (cl-defun helm-swoop (&key query source (multiline current-prefix-arg))
732 | "List the all lines to another buffer, which is able to squeeze by
733 | any words you input. At the same time, the original buffer's cursor
734 | is jumping line to line according to moving up and down the list."
735 | (interactive)
736 | (setq helm-swoop-synchronizing-window (selected-window))
737 | (setq helm-swoop-last-point (cons (point) (buffer-name (current-buffer))))
738 | (setq helm-swoop-last-line-info
739 | (cons (current-buffer) (line-number-at-pos)))
740 | (unless (boundp 'helm-swoop-last-query)
741 | (set (make-local-variable 'helm-swoop-last-query) ""))
742 | (setq helm-swoop-target-buffer (current-buffer))
743 | (helm-swoop--set-prefix (prefix-numeric-value multiline))
744 | ;; Overlay
745 | (setq helm-swoop-line-overlay (make-overlay (point) (point)))
746 | (overlay-put helm-swoop-line-overlay
747 | 'face (if (< 1 helm-swoop-last-prefix-number)
748 | 'helm-swoop-target-line-block-face
749 | 'helm-swoop-target-line-face))
750 | ;; Cache
751 | (cond ((not (boundp 'helm-swoop-list-cache))
752 | (set (make-local-variable 'helm-swoop-list-cache) nil))
753 | ((buffer-modified-p)
754 | (setq helm-swoop-list-cache nil)))
755 | (unwind-protect
756 | (progn
757 | ;; For synchronizing line position
758 | (add-hook 'helm-after-update-hook 'helm-swoop--pattern-match)
759 | (add-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position t)
760 | (cond (query
761 | (if (string-match
762 | "\\(\\^\\[0\\-9\\]\\+\\.\\)\\(.*\\)" query)
763 | query ;; NEED FIX #1 to appear as a "^"
764 | query))
765 | (mark-active
766 | (let ((st (buffer-substring-no-properties
767 | (region-beginning) (region-end))))
768 | (if (string-match "\n" st)
769 | (message "Multi line region is not allowed")
770 | (setq query (helm-swoop-pre-input-optimize st)))))
771 | ((setq query (helm-swoop-pre-input-optimize
772 | (funcall helm-swoop-pre-input-function))))
773 | (t (setq query "")))
774 | ;; First behavior
775 | (helm-swoop--recenter)
776 | (move-beginning-of-line 1)
777 | (helm-swoop--target-line-overlay-move)
778 | ;; Execute helm
779 | (let ((helm-display-function helm-swoop-split-window-function)
780 | (helm-display-source-at-screen-top nil)
781 | (helm-completion-window-scroll-margin 5))
782 | (helm :sources
783 | (or source
784 | (helm-c-source-swoop))
785 | :buffer helm-swoop-buffer
786 | :input query
787 | :prompt helm-swoop-prompt
788 | :preselect
789 | ;; Get current line has content or else near one
790 | (if (string-match "^[\t\n\s]*$" (helm-swoop--get-string-at-line))
791 | (save-excursion
792 | (if (re-search-forward "[^\t\n\s]" nil t)
793 | (format "^%s\s" (line-number-at-pos))
794 | (re-search-backward "[^\t\n\s]" nil t)
795 | (format "^%s\s" (line-number-at-pos))))
796 | (format "^%s\s" (line-number-at-pos)))
797 | :candidate-number-limit helm-swoop-candidate-number-limit)))
798 | ;; Restore helm's hook and window function etc
799 | (helm-swoop--restore)))
800 |
801 | ;; Receive word from isearch ---------------
802 | ;;;###autoload
803 | (defun helm-swoop-from-isearch ()
804 | "Invoke `helm-swoop' from isearch."
805 | (interactive)
806 | (let ((query (if isearch-regexp
807 | isearch-string
808 | (regexp-quote isearch-string))))
809 | (let (search-nonincremental-instead)
810 | (isearch-exit))
811 | (helm-swoop :query query)))
812 | ;; When doing isearch, hand the word over to helm-swoop
813 | ;; (define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)
814 |
815 | ;; Receive word from evil search ---------------
816 | (defun helm-swoop-from-evil-search ()
817 | "Invoke `helm-swoop' from evil isearch."
818 | (interactive)
819 | (if (string-match "\\(isearch-\\|evil.*search\\)" (symbol-name real-last-command))
820 | (helm-swoop :query (if isearch-regexp
821 | isearch-string
822 | (regexp-quote isearch-string)))
823 | (helm-swoop)))
824 | ;; When doing evil-search, hand the word over to helm-swoop
825 | ;; (define-key evil-motion-state-map (kbd "M-i") 'helm-swoop-from-evil-search)
826 |
827 | ;; Receive word from evil search ---------------
828 | (defun helm-swoop-yank-thing-at-point ()
829 | "Insert string at which the point helm-swoop started."
830 | (interactive)
831 | (let (amend buf)
832 | (with-selected-window helm-swoop-synchronizing-window
833 | (setq buf (get-buffer (cdr helm-swoop-last-point)))
834 | (when buf
835 | (with-current-buffer buf
836 | (save-excursion
837 | (goto-char (car helm-swoop-last-point))
838 | (setq amend (thing-at-point 'symbol))))))
839 | (when amend
840 | (with-selected-window (minibuffer-window)
841 | (insert amend)))))
842 |
843 | ;; For helm-resume ------------------------
844 | (defadvice helm-resume-select-buffer
845 | (around helm-swoop-if-selected-as-resume activate)
846 | "Resume if *Helm Swoop* buffer selected when helm-resume with prefix."
847 | (if (boundp 'helm-swoop-last-query)
848 | ad-do-it
849 | ;; If the buffer hasn't called helm-swoop, just hide from options
850 | (let ((helm-buffers (delete helm-swoop-buffer helm-buffers)))
851 | ad-do-it))
852 | (when (and (equal ad-return-value helm-swoop-buffer)
853 | (boundp 'helm-swoop-last-query))
854 | (helm-swoop :query helm-swoop-last-query
855 | :multiline helm-swoop-last-prefix-number)
856 | (setq ad-return-value nil)))
857 |
858 | (defadvice helm-resume (around helm-swoop-resume activate)
859 | "Resume if the last used helm buffer is helm-swoop-buffer."
860 | (if (equal helm-last-buffer helm-swoop-buffer)
861 | (if (boundp 'helm-swoop-last-query)
862 | (if (not (ad-get-arg 0))
863 | (helm-swoop :query helm-swoop-last-query
864 | :multiline helm-swoop-last-prefix-number))
865 | ;; Temporary apply second last buffer
866 | (let ((helm-last-buffer (cadr helm-buffers))) ad-do-it))
867 | ad-do-it))
868 |
869 | ;;; @ helm-swoop-edit -----------------------------------------
870 |
871 | (defvar helm-swoop-edit-target-buffer)
872 | (defvar helm-swoop-edit-buffer "*Helm Swoop Edit*")
873 | (defvar helm-swoop-edit-map
874 | (let ((map (make-sparse-keymap)))
875 | (define-key map (kbd "C-x C-s") 'helm-swoop--edit-complete)
876 | (define-key map (kbd "C-c C-g") 'helm-swoop--edit-cancel)
877 | (define-key map (kbd "C-c C-q C-k") 'helm-swoop--edit-delete-all-lines)
878 | map))
879 |
880 | (defun helm-swoop--clear-edit-buffer (prop)
881 | "Clear edit buffer with PROP."
882 | (let ((inhibit-read-only t))
883 | (mapc (lambda (ov)
884 | (when (overlay-get ov prop)
885 | (delete-overlay ov)))
886 | (overlays-in (point-min) (point-max)))
887 | (set-text-properties (point-min) (point-max) nil)
888 | (goto-char (point-min))
889 | (erase-buffer)))
890 |
891 | (defun helm-swoop--collect-edited-lines ()
892 | "Create a list of edited lines with each its own line number."
893 | (interactive)
894 | (let (res)
895 | (goto-char (point-min))
896 | (while (re-search-forward "^\\([0-9]+\\)\s" nil t)
897 | (setq res
898 | (cons (cons (string-to-number (match-string 1))
899 | (buffer-substring-no-properties
900 | (point)
901 | (save-excursion
902 | (if (re-search-forward
903 | "^\\([0-9]+\\)\s\\|^\\(\\-+\\)" nil t)
904 | (1- (match-beginning 0))
905 | (goto-char (point-max))
906 | (re-search-backward "\n" nil t)))))
907 | res)))
908 | res))
909 |
910 | (defun helm-swoop--edit (candidate)
911 | "This function will only be called from `helm-swoop-edit' with CANDIDATE."
912 | (interactive)
913 | (setq helm-swoop-edit-target-buffer helm-swoop-target-buffer)
914 | (delete-overlay helm-swoop-line-overlay)
915 | (helm-swoop--delete-overlay 'target-buffer)
916 | (with-current-buffer (get-buffer-create helm-swoop-edit-buffer)
917 |
918 | (helm-swoop--clear-edit-buffer 'helm-swoop-edit)
919 | (let ((bufstr ""))
920 | ;; Get target line number to edit
921 | (with-current-buffer helm-swoop-buffer
922 | ;; Use selected line by [C-SPC] or [M-SPC]
923 | (mapc (lambda (ov)
924 | (when (eq 'helm-visible-mark (overlay-get ov 'face))
925 | (setq bufstr (concat (buffer-substring-no-properties
926 | (overlay-start ov) (overlay-end ov))
927 | bufstr))))
928 | (overlays-in (point-min) (point-max)))
929 | (if (equal "" bufstr)
930 | ;; Not found selected line
931 | (setq bufstr (buffer-substring-no-properties
932 | (point-min) (point-max)))
933 | ;; Attach title
934 | (setq bufstr (concat "Helm Swoop\n" bufstr))))
935 |
936 | ;; Set for edit buffer
937 | (insert bufstr)
938 | (add-text-properties (point-min) (point-max)
939 | '(read-only t rear-nonsticky t front-sticky t))
940 |
941 | ;; Set for editable context
942 | (let ((inhibit-read-only t))
943 | ;; Title and explanation
944 | (goto-char (point-min))
945 | (let ((ov (make-overlay (point) (line-end-position))))
946 | (overlay-put ov 'helm-swoop-edit t)
947 | (overlay-put ov 'face 'font-lock-function-name-face)
948 | (overlay-put ov 'after-string
949 | (propertize
950 | (substitute-command-keys
951 | (concat
952 | " [\\\\[helm-swoop--edit-complete]] Complete"
953 | ", [\\\\[helm-swoop--edit-cancel]] Cancel"
954 | ", [\\\\[helm-swoop--edit-delete-all-lines]] Delete All"))
955 | 'face 'helm-bookmark-addressbook)))
956 | ;; Line number and editable area
957 | (while (re-search-forward "^\\([0-9]+\s\\)\\(.*\\)$" nil t)
958 | (let* ((bol1 (match-beginning 1))
959 | (eol1 (match-end 1))
960 | (bol2 (match-beginning 2))
961 | (eol2 (match-end 2)))
962 | ;; Line number
963 | (add-text-properties bol1 eol1
964 | '(face font-lock-function-name-face
965 | intangible t))
966 | ;; Editable area
967 | (remove-text-properties bol2 eol2 '(read-only t))
968 | ;; For line tail
969 | (set-text-properties eol2 (or (1+ eol2) (point-max))
970 | '(read-only t rear-nonsticky t))))
971 | (helm-swoop--target-word-overlay 'edit-buffer 0))))
972 |
973 | (other-window 1)
974 | (switch-to-buffer helm-swoop-edit-buffer)
975 | (goto-char (point-min))
976 | (if (string-match "^[0-9]+" candidate)
977 | (re-search-forward
978 | (concat "^" (match-string 0 candidate)) nil t))
979 | (use-local-map helm-swoop-edit-map))
980 |
981 | (defun helm-swoop--edit-complete ()
982 | "Apply change and kill temporary edit buffer."
983 | (interactive)
984 | (let ((lines (helm-swoop--collect-edited-lines)))
985 | (with-current-buffer helm-swoop-edit-target-buffer
986 | ;; Replace from the end of buffer
987 | (save-excursion
988 | (mapc (lambda (cell)
989 | (let ((k (car cell))
990 | (v (cdr cell)))
991 | (goto-char (point-min))
992 | (delete-region (line-beginning-position k)
993 | (line-end-position k))
994 | (goto-char (line-beginning-position k))
995 | (insert v)))
996 | lines)))
997 | (select-window helm-swoop-synchronizing-window)
998 | (kill-buffer (get-buffer helm-swoop-edit-buffer)))
999 | (message "Successfully helm-swoop-edit applied to original buffer"))
1000 |
1001 | (defun helm-swoop--edit-delete-all-lines ()
1002 | "Apply change and kill temporary edit buffer."
1003 | (interactive)
1004 | (let ((lines (helm-swoop--collect-edited-lines)))
1005 | (with-current-buffer helm-swoop-edit-target-buffer
1006 | ;; Replace from the end of buffer
1007 | (save-excursion
1008 | (mapc (lambda (cell)
1009 | (let ((k (car cell)))
1010 | (goto-char (point-min))
1011 | (delete-region (line-beginning-position k)
1012 | (if (eq (line-end-position k) (point-max))
1013 | (line-end-position k)
1014 | (1+ (line-end-position k))))))
1015 | lines)))
1016 | (select-window helm-swoop-synchronizing-window)
1017 | (kill-buffer (get-buffer helm-swoop-edit-buffer)))
1018 | (message "Successfully helm-swoop-edit applied to original buffer"))
1019 |
1020 | (defun helm-swoop--edit-cancel ()
1021 | "Cancel edit and kill temporary buffer."
1022 | (interactive)
1023 | (select-window helm-swoop-synchronizing-window)
1024 | (kill-buffer (get-buffer helm-swoop-edit-buffer))
1025 | (message "helm-swoop-edit canceled"))
1026 |
1027 | (defun helm-swoop-edit ()
1028 | "Execute `helm-swoop--edit'."
1029 | (interactive)
1030 | (helm-exit-and-execute-action 'helm-swoop--edit))
1031 |
1032 | ;;; @ helm-multi-swoop ----------------------------------------
1033 | (defvar helm-multi-swoop-buffer-list "*helm-multi-swoop buffers list*"
1034 | "Buffer name.")
1035 | (defvar helm-multi-swoop-ignore-buffers-match "^\\*"
1036 | "Regexp to eliminate buffers you don't want to see.")
1037 | (defvar helm-multi-swoop-candidate-number-limit 250)
1038 | (defvar helm-multi-swoop-last-selected-buffers nil)
1039 | (defvar helm-multi-swoop-last-query nil)
1040 | (defvar helm-multi-swoop-query nil)
1041 | (defvar helm-multi-swoop-buffer "*Helm Multi Swoop*")
1042 | (defvar helm-multi-swoop-all-from-helm-swoop-last-point nil
1043 | "For the last position, when helm-multi-swoop-all-from-helm-swoop canceled.")
1044 | (defvar helm-multi-swoop-move-line-action-last-buffer nil)
1045 |
1046 | (defvar helm-multi-swoop-buffers-map
1047 | (let ((map (make-sparse-keymap)))
1048 | (set-keymap-parent map helm-map)
1049 | (define-key map (kbd "RET")
1050 | (lambda () (interactive)
1051 | (helm-exit-and-execute-action 'helm-multi-swoop--exec)))
1052 | (delq nil map)))
1053 |
1054 | (defvar helm-multi-swoop-projectile-buffers-filter
1055 | #'projectile-buffers-with-file-or-process)
1056 | ;; action -----------------------------------------------------
1057 |
1058 | (defun helm-multi-swoop--move-line-action ()
1059 | "Move line action."
1060 | (with-helm-window
1061 | (let* ((key (buffer-substring (line-beginning-position)
1062 | (line-end-position)))
1063 | (num (when (string-match "^[0-9]+" key)
1064 | (string-to-number (match-string 0 key))))
1065 | (source (helm-get-current-source))
1066 | (buf (let ((name (assoc-default 'name source)))
1067 | (when name (get-buffer name)))))
1068 | (when buf
1069 | ;; Synchronizing line position
1070 | (with-selected-window helm-swoop-synchronizing-window
1071 | (with-current-buffer buf
1072 | (when (not (eq buf helm-multi-swoop-move-line-action-last-buffer))
1073 | (set-window-buffer nil buf)
1074 | (helm-swoop--pattern-match))
1075 | (helm-swoop--goto-line num)
1076 | (helm-swoop--target-line-overlay-move buf)
1077 | (helm-swoop--recenter))
1078 | (setq helm-multi-swoop-move-line-action-last-buffer buf))
1079 | (setq helm-swoop-last-line-info (cons buf num))))))
1080 |
1081 | (defun helm-multi-swoop--get-marked-buffers ()
1082 | "Get marked buffers."
1083 | (let ((buf (get-buffer helm-multi-swoop-buffer-list))
1084 | lst)
1085 | (when (buffer-live-p buf)
1086 | (with-current-buffer buf
1087 | (dolist (ov (cl-delete-if-not
1088 | (lambda (o)
1089 | (eq 'helm-visible-mark (overlay-get o 'face)))
1090 | (overlays-in (point-min) (point-max))))
1091 | (let ((word (string-trim
1092 | (buffer-substring-no-properties
1093 | (overlay-start ov) (overlay-end ov)))))
1094 | (unless (string-empty-p word)
1095 | (push word lst)))))
1096 | (nreverse (sort lst #'string<)))))
1097 |
1098 | ;; core --------------------------------------------------------
1099 |
1100 | (cl-defun helm-multi-swoop--exec (ignored &key query buflist func action)
1101 | "Multi swoop exec with IGNORED QUERY BUFLIST FUNC ACTION."
1102 | (interactive)
1103 | (setq helm-swoop-synchronizing-window (selected-window))
1104 | (setq helm-swoop-last-point
1105 | (or helm-multi-swoop-all-from-helm-swoop-last-point
1106 | (cons (point) (buffer-name (current-buffer)))))
1107 | (setq helm-swoop-last-line-info
1108 | (cons (current-buffer) (line-number-at-pos)))
1109 | (unless (get-buffer helm-multi-swoop-buffer-list)
1110 | (get-buffer-create helm-multi-swoop-buffer-list))
1111 | (helm-swoop--set-prefix (prefix-numeric-value current-prefix-arg))
1112 | (let ((buffs (or buflist
1113 | (helm-multi-swoop--get-marked-buffers)
1114 | `(,(buffer-name helm-swoop-target-buffer))
1115 | (error "No buffer selected")))
1116 | (prefix-arg (prefix-numeric-value
1117 | (or current-prefix-arg helm-swoop-last-prefix-number 1)))
1118 | contents preserve-position)
1119 | (helm-swoop--set-prefix prefix-arg)
1120 | (setq helm-multi-swoop-last-selected-buffers buffs)
1121 | ;; Create buffer sources
1122 | (mapc (lambda (buf)
1123 | (when (get-buffer buf)
1124 | (with-current-buffer (get-buffer buf)
1125 | (let* ((func
1126 | (or func
1127 | (lambda ()
1128 | (helm-swoop--split-lines-by
1129 | (helm-swoop--get-content buf t)
1130 | "\n" prefix-arg))))
1131 | (action
1132 | (or action
1133 | `(("Go to Line"
1134 | . (lambda (line)
1135 | (switch-to-buffer ,buf)
1136 | (helm-swoop--goto-line
1137 | (when (string-match "^[0-9]+" line)
1138 | (string-to-number
1139 | (match-string 0 line))))
1140 | (when (re-search-forward
1141 | (mapconcat 'identity
1142 | (split-string
1143 | helm-pattern " ") "\\|")
1144 | nil t)
1145 | (funcall helm-swoop-flash-region-function
1146 | (match-beginning 0) (match-end 0))
1147 | (goto-char (match-beginning 0)))
1148 | (helm-swoop--recenter)))
1149 | ("Edit" . helm-multi-swoop--edit)))))
1150 | (setq preserve-position
1151 | (cons (cons buf (point)) preserve-position))
1152 | (setq
1153 | contents
1154 | (cons
1155 | (helm-c-source-multi-swoop buf func action prefix-arg)
1156 | contents))))))
1157 | buffs)
1158 | (unwind-protect
1159 | (progn
1160 | (add-hook 'helm-after-update-hook 'helm-swoop--pattern-match)
1161 | (add-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position t)
1162 | (setq helm-swoop-line-overlay
1163 | (make-overlay (point) (point)))
1164 | (overlay-put helm-swoop-line-overlay
1165 | 'face 'helm-swoop-target-line-face)
1166 | (helm-swoop--target-line-overlay-move)
1167 | ;; Execute helm
1168 | (let ((helm-display-function helm-swoop-split-window-function)
1169 | (helm-display-source-at-screen-top nil)
1170 | (helm-completion-window-scroll-margin 5))
1171 | (helm :sources contents
1172 | :buffer helm-multi-swoop-buffer
1173 | :input (or query helm-multi-swoop-query "")
1174 | :prompt helm-swoop-prompt
1175 | :candidate-number-limit
1176 | helm-multi-swoop-candidate-number-limit
1177 | :preselect
1178 | (regexp-quote
1179 | (format "%s %s" (line-number-at-pos)
1180 | (helm-swoop--get-string-at-line))))))
1181 | ;; Restore
1182 | (progn
1183 | (when (= 1 helm-exit-status)
1184 | (helm-swoop-back-to-last-point t)
1185 | (helm-swoop--restore-unveiled-overlay))
1186 | (setq helm-swoop-invisible-targets nil)
1187 | (remove-hook 'helm-after-update-hook 'helm-swoop--pattern-match)
1188 | (remove-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position)
1189 | (setq helm-multi-swoop-last-query helm-swoop-pattern)
1190 | (helm-swoop--restore-unveiled-overlay)
1191 | (setq helm-multi-swoop-query nil)
1192 | (setq helm-multi-swoop-all-from-helm-swoop-last-point nil)
1193 | (mapc (lambda (buf)
1194 | (let ((current-buf (buffer-name (current-buffer))))
1195 | (with-current-buffer (car buf)
1196 | ;; Delete overlay
1197 | (delete-overlay helm-swoop-line-overlay)
1198 | (helm-swoop--delete-overlay 'target-buffer)
1199 | ;; Restore each buffer's position
1200 | (unless (equal (car buf) current-buf)
1201 | (goto-char (cdr buf))))))
1202 | preserve-position)))))
1203 |
1204 | (defun helm-multi-swoop--get-buffer-list ()
1205 | "Get buffer list."
1206 | (let (buflist1 buflist2)
1207 | ;; eliminate buffers start with whitespace and dired buffers
1208 | (mapc (lambda (buf)
1209 | (setq buf (buffer-name buf))
1210 | (unless (string-match "^\\s-" buf)
1211 | (unless (eq 'dired-mode (with-current-buffer buf major-mode))
1212 | (setq buflist1 (cons buf buflist1)))))
1213 | (buffer-list))
1214 | ;; eliminate buffers match pattern
1215 | (mapc (lambda (buf)
1216 | (unless (string-match helm-multi-swoop-ignore-buffers-match buf)
1217 | (setq buflist2 (cons buf buflist2))))
1218 | buflist1)
1219 | buflist2))
1220 |
1221 | (defun helm-c-source-helm-multi-swoop-buffers ()
1222 | "Show buffer list to select."
1223 | `((name . "helm-multi-swoop select buffers")
1224 | (candidates . helm-multi-swoop--get-buffer-list)
1225 | (header-line . "[C-SPC]/[M-SPC] select, [RET] next step")
1226 | (keymap . ,helm-multi-swoop-buffers-map)
1227 | (match . ,(helm-swoop-match-functions))
1228 | ;; (search . ,(helm-swoop-search-functions))
1229 | ))
1230 |
1231 | (defun helm-multi-swoop--get-query (query)
1232 | "Get query from QUERY."
1233 | (cond (query
1234 | (setq helm-multi-swoop-query query))
1235 | (mark-active
1236 | (let ((st (buffer-substring-no-properties
1237 | (region-beginning) (region-end))))
1238 | (if (string-match "\n" st)
1239 | (message "Multi line region is not allowed")
1240 | (setq helm-multi-swoop-query
1241 | (helm-swoop-pre-input-optimize st)))))
1242 | ((setq helm-multi-swoop-query
1243 | (helm-swoop-pre-input-optimize
1244 | (funcall helm-swoop-pre-input-function))))
1245 | (t (setq helm-multi-swoop-query ""))))
1246 |
1247 | ;;;###autoload
1248 | (defun helm-multi-swoop (&optional query buflist)
1249 | "Multi swoop for QUERY in BUFLIST.
1250 |
1251 | Usage:
1252 | \\[execute-extended-command] helm-multi-swoop
1253 | 1. Select any buffers by [C-SPC] or [M-SPC]
1254 | 2. Press [RET] to start `helm-multi-swoop'
1255 |
1256 | \\[universal-argument] \\[execute-extended-command] helm-multi-swoop
1257 | If you have done helm-multi-swoop before, you can skip select buffers step.
1258 | Last selected buffers will be applied to helm-multi-swoop."
1259 | (interactive)
1260 | (setq helm-multi-swoop-query (helm-multi-swoop--get-query query))
1261 | (if (equal current-prefix-arg '(4))
1262 | (helm-multi-swoop--exec nil
1263 | :query helm-multi-swoop-query
1264 | :buflist buflist)
1265 | (if buflist
1266 | (helm-multi-swoop--exec nil
1267 | :query query
1268 | :buflist buflist)
1269 | (helm :sources (helm-c-source-helm-multi-swoop-buffers)
1270 | :buffer helm-multi-swoop-buffer-list
1271 | :prompt "Mark any buffers by [C-SPC] or [M-SPC]: "))))
1272 |
1273 | ;;;###autoload
1274 | (defun helm-multi-swoop-all (&optional query)
1275 | "Apply all buffers to helm-multi-swoop for QUERY."
1276 | (interactive)
1277 | (setq helm-multi-swoop-query (helm-multi-swoop--get-query query))
1278 | (helm-multi-swoop--exec nil
1279 | :query helm-multi-swoop-query
1280 | :buflist (helm-multi-swoop--get-buffer-list)))
1281 |
1282 | (defun get-buffers-matching-mode (mode)
1283 | "Return a list of buffers where their `major-mode' is equal to MODE."
1284 | (let (buffer-mode-matches)
1285 | (mapc (lambda (buf)
1286 | (when (get-buffer buf)
1287 | (with-current-buffer (get-buffer buf)
1288 | (if (eq mode major-mode)
1289 | (add-to-list 'buffer-mode-matches (buffer-name buf))))))
1290 | (buffer-list))
1291 | buffer-mode-matches))
1292 |
1293 | (defun helm-multi-swoop-by-mode (mode &optional query)
1294 | "Apply all buffers whose mode is MODE to helm-multi-swoop for QUERY."
1295 | (setq helm-multi-swoop-query (helm-multi-swoop--get-query query))
1296 | (if (get-buffers-matching-mode mode)
1297 | (helm-multi-swoop--exec nil
1298 | :query helm-multi-swoop-query
1299 | :buflist (get-buffers-matching-mode mode))
1300 | (message "there are no buffers in that mode right now")))
1301 |
1302 | ;;;###autoload
1303 | (defun helm-multi-swoop-org (&optional query)
1304 | "Applie all `org-mode' buffers to helm-multi-swoop for QUERY."
1305 | (interactive)
1306 | (helm-multi-swoop-by-mode 'org-mode query))
1307 |
1308 | ;;;###autoload
1309 | (defun helm-multi-swoop-current-mode (&optional query)
1310 | "Applie all buffers of the same mode as the current buffer to helm-multi-swoop for QUERY."
1311 | (interactive)
1312 | (helm-multi-swoop-by-mode major-mode query))
1313 |
1314 | ;;;###autoload
1315 | (defun helm-multi-swoop-projectile (&optional query)
1316 | "Apply all opened buffers of the current project to helm-multi-swoop for QUERY."
1317 | (interactive)
1318 | (setq helm-multi-swoop-query (helm-multi-swoop--get-query query))
1319 | (if (require 'projectile nil 'noerror)
1320 | ;; set filter function that is used in projectile-project-buffers
1321 | (let ((projectile-buffers-filter-function
1322 | helm-multi-swoop-projectile-buffers-filter))
1323 | (helm-multi-swoop--exec nil
1324 | :query helm-multi-swoop-query
1325 | :buflist (mapcar #'buffer-name
1326 | (projectile-project-buffers))))
1327 | (error "Package 'projectile' is not available")))
1328 |
1329 |
1330 | (defun helm-swoop--wrap-function-with-pre-input-function (target-fn pre-input-fn)
1331 | "Wrap function with pre input function for TARGET-FN and PRE-INPUT-FN."
1332 | (let ((helm-swoop-pre-input-function pre-input-fn))
1333 | (funcall target-fn)))
1334 |
1335 | ;;;###autoload
1336 | (defun helm-swoop-without-pre-input ()
1337 | "Start helm-swoop without pre input query."
1338 | (interactive)
1339 | (helm-swoop--wrap-function-with-pre-input-function
1340 | 'helm-swoop (lambda () nil)))
1341 |
1342 | ;;;###autoload
1343 | (defun helm-swoop-symble-pre-input ()
1344 | "Start helm-swoop without pre input query."
1345 | (interactive)
1346 | (helm-swoop--wrap-function-with-pre-input-function
1347 | 'helm-swoop (lambda () (format "\\_<%s\\_> " (thing-at-point 'symbol)))))
1348 |
1349 | ;; option -------------------------------------------------------
1350 |
1351 | (defun helm-multi-swoop-all-from-isearch ()
1352 | "Invoke `helm-multi-swoop-all' from isearch."
1353 | (interactive)
1354 | (let ((query (if isearch-regexp
1355 | isearch-string
1356 | (regexp-quote isearch-string))))
1357 | (let (search-nonincremental-instead)
1358 | (isearch-exit))
1359 | (helm-multi-swoop-all query)))
1360 | ;; When doing isearch, hand the word over to helm-swoop
1361 | ;; (define-key isearch-mode-map (kbd "C-x M-i") 'helm-multi-swoop-all-from-isearch)
1362 |
1363 | (defun helm-multi-swoop-all-from-helm-swoop ()
1364 | "Invoke `helm-multi-swoop-all' from helm-swoop."
1365 | (interactive)
1366 | (helm-swoop--restore)
1367 | (delete-overlay helm-swoop-line-overlay)
1368 | (setq helm-multi-swoop-all-from-helm-swoop-last-point helm-swoop-last-point)
1369 | (let ((query helm-pattern))
1370 | (run-with-timer 0 nil (lambda () (helm-multi-swoop-all query))))
1371 | (helm-exit-minibuffer))
1372 |
1373 | (defun helm-multi-swoop-current-mode-from-helm-swoop ()
1374 | "Invoke `helm-multi-swoop-all' from helm-swoop."
1375 | (interactive)
1376 | (helm-swoop--restore)
1377 | (delete-overlay helm-swoop-line-overlay)
1378 | (setq helm-multi-swoop-all-from-helm-swoop-last-point helm-swoop-last-point)
1379 | (let ((query helm-pattern))
1380 | (run-with-timer 0 nil (lambda () (helm-multi-swoop-current-mode query))))
1381 | (helm-exit-minibuffer))
1382 | ;; (define-key helm-swoop-map (kbd "M-m") 'helm-multi-swoop-current-mode-from-helm-swoop)
1383 |
1384 | (defadvice helm-resume (around helm-multi-swoop-resume activate)
1385 | "Resume if the last used helm buffer is *Helm Swoop*."
1386 | (if (equal helm-last-buffer helm-multi-swoop-buffer)
1387 | (if (boundp 'helm-multi-swoop-last-query)
1388 | (if (not (ad-get-arg 0))
1389 | (helm-multi-swoop helm-multi-swoop-last-query
1390 | helm-multi-swoop-last-selected-buffers))
1391 | ;; Temporary apply second last buffer
1392 | (let ((helm-last-buffer (cadr helm-buffers)))
1393 | ad-do-it))
1394 | ad-do-it))
1395 |
1396 | ;;; @ helm-multi-swoop-edit -----------------------------------
1397 | (defvar helm-multi-swoop-edit-save t
1398 | "Save each buffer you edit when editing is complete.")
1399 | (defvar helm-multi-swoop-edit-buffer "*Helm Multi Swoop Edit*")
1400 |
1401 | (defvar helm-multi-swoop-edit-map
1402 | (let ((map (make-sparse-keymap)))
1403 | (define-key map (kbd "C-x C-s") 'helm-multi-swoop--edit-complete)
1404 | (define-key map (kbd "C-c C-g") 'helm-multi-swoop--edit-cancel)
1405 | (define-key map (kbd "C-c C-q C-k") 'helm-multi-swoop--edit-delete-all-lines)
1406 | map))
1407 |
1408 | (defun helm-multi-swoop--edit (candidate)
1409 | "This function will only be called from `helm-swoop-edit' for CANDIDATE."
1410 | (interactive)
1411 | (delete-overlay helm-swoop-line-overlay)
1412 | (helm-swoop--delete-overlay 'target-buffer)
1413 | (with-current-buffer (get-buffer-create helm-multi-swoop-edit-buffer)
1414 | (helm-swoop--clear-edit-buffer 'helm-multi-swoop-edit)
1415 | (let ((bufstr "")
1416 | (buf (get-buffer helm-multi-swoop-buffer))
1417 | mark)
1418 | ;; Get target line number to edit
1419 | (when buf
1420 | (with-current-buffer buf
1421 | ;; Set overlay to helm-source-header for editing marked lines
1422 | (save-excursion
1423 | (goto-char (point-min))
1424 | (let ((beg (point))
1425 | end)
1426 | (overlay-recenter (point-max))
1427 | (while (setq beg (text-property-any beg (point-max)
1428 | 'face 'helm-source-header))
1429 | (setq end (next-single-property-change beg 'face))
1430 | (overlay-put (make-overlay beg end) 'source-header t)
1431 | (setq beg end)
1432 | (goto-char end))))
1433 | ;; Use selected line by [C-SPC] or [M-SPC]
1434 | (mapc (lambda (ov)
1435 | (when (overlay-get ov 'source-header)
1436 | (setq bufstr (concat (buffer-substring
1437 | (overlay-start ov) (overlay-end ov))
1438 | bufstr)))
1439 | (when (eq 'helm-visible-mark (overlay-get ov 'face))
1440 | (let ((str (buffer-substring (overlay-start ov) (overlay-end ov))))
1441 | (unless (equal "" str) (setq mark t))
1442 | (setq bufstr (concat (buffer-substring
1443 | (overlay-start ov) (overlay-end ov))
1444 | bufstr)))))
1445 | (overlays-in (point-min) (point-max)))
1446 | (if mark
1447 | (progn (setq bufstr (concat "Helm Multi Swoop\n" bufstr))
1448 | (setq mark nil))
1449 | (setq bufstr (concat "Helm Multi Swoop\n"
1450 | (buffer-substring
1451 | (point-min) (point-max)))))))
1452 |
1453 | ;; Set for edit buffer
1454 | (insert bufstr)
1455 | (add-text-properties (point-min) (point-max)
1456 | '(read-only t rear-nonsticky t front-sticky t))
1457 |
1458 | ;; Set for editable context
1459 | (let ((inhibit-read-only t))
1460 | ;; Title and explanation
1461 | (goto-char (point-min))
1462 | (let ((ov (make-overlay (point) (line-end-position))))
1463 | (overlay-put ov 'helm-multi-swoop-edit t)
1464 | (overlay-put ov 'face 'font-lock-function-name-face)
1465 | (overlay-put ov 'after-string
1466 | (propertize
1467 | (substitute-command-keys
1468 | (concat
1469 | " [\\\\[helm-swoop--edit-complete]] Complete"
1470 | ", [\\\\[helm-swoop--edit-cancel]] Cancel"
1471 | ", [\\\\[helm-swoop--edit-delete-all-lines]] Delete All"))
1472 | 'face 'helm-bookmark-addressbook)))
1473 | ;; Line number and editable area
1474 | (while (re-search-forward "^\\([0-9]+\s\\)\\(.*\\)$" nil t)
1475 | (let* ((bol1 (match-beginning 1))
1476 | (eol1 (match-end 1))
1477 | (bol2 (match-beginning 2))
1478 | (eol2 (match-end 2)))
1479 |
1480 | ;; Line number
1481 | (add-text-properties bol1 eol1
1482 | '(face font-lock-function-name-face
1483 | intangible t))
1484 | ;; Editable area
1485 | (remove-text-properties bol2 eol2 '(read-only t))
1486 | ;; (add-text-properties bol2 eol2 '(font-lock-face helm-match))
1487 |
1488 | ;; For line tail
1489 | (set-text-properties eol2 (or (1+ eol2) (point-max))
1490 | '(read-only t rear-nonsticky t))))
1491 | (helm-swoop--target-word-overlay 'edit-buffer 0))))
1492 |
1493 | (other-window 1)
1494 | (switch-to-buffer helm-multi-swoop-edit-buffer)
1495 | (goto-char (point-min))
1496 | (if (string-match "^[0-9]+" candidate)
1497 | (re-search-forward
1498 | (concat "^" (match-string 0 candidate)) nil t))
1499 | (use-local-map helm-multi-swoop-edit-map))
1500 |
1501 | (defun helm-multi-swoop--separate-text-property-into-list (prop)
1502 | "Separete text property into list for PROP."
1503 | (interactive)
1504 | (let (list end)
1505 | (save-excursion
1506 | (goto-char (point-min))
1507 | (while (setq end (next-single-property-change (point) prop))
1508 | ;; Must eliminate last return because of unexpected edit result
1509 | (setq list (cons
1510 | (let ((str (buffer-substring-no-properties (point) end)))
1511 | (if (string-match "\n\n\\'" str)
1512 | (replace-regexp-in-string "\n\\'" "" str)
1513 | str))
1514 | list))
1515 | (goto-char end))
1516 | (setq list (cons (buffer-substring-no-properties (point) (point-max))
1517 | list)))
1518 | (nreverse list)))
1519 |
1520 | (defun helm-multi-swoop--collect-edited-lines ()
1521 | "Create a list of edited lines with each its own line number."
1522 | (interactive)
1523 | (let* ((list (helm-multi-swoop--separate-text-property-into-list 'helm-header))
1524 | (length (length list))
1525 | (i 1) ;; 0th list is header
1526 | pairs)
1527 | (while (<= i length)
1528 | (let (contents)
1529 | ;; Make ((number . line) (number . line) (number . line) ...)
1530 | (with-temp-buffer
1531 | (insert (format "%s" (nth (1+ i) list)))
1532 | (goto-char (point-min))
1533 | (while (re-search-forward "^\\([0-9]+\\)\s" nil t)
1534 | (setq contents
1535 | (cons (cons (string-to-number (match-string 1))
1536 | (buffer-substring-no-properties
1537 | (point)
1538 | (save-excursion
1539 | (if (re-search-forward
1540 | "^\\([0-9]+\\)\s\\|^\\(\\-+\\)" nil t)
1541 | (1- (match-beginning 0))
1542 | (goto-char (point-max))
1543 | (re-search-backward "\n" nil t)))))
1544 | contents))))
1545 | ;; Make ((buffer-name (number . line) (number . line) ...)
1546 | ;; (buffer-name (number . line) (number . line) ...) ...)
1547 | (setq pairs (cons (cons (nth i list) contents) pairs)))
1548 | (setq i (+ i 2)))
1549 | (delete '(nil) pairs)))
1550 |
1551 | (defun helm-multi-swoop--edit-complete ()
1552 | "Delete all extracted lines, and apply change to buffers and kill temporary edit buffer."
1553 | (interactive)
1554 | (let ((lines (helm-multi-swoop--collect-edited-lines))
1555 | read-only)
1556 | (mapc (lambda (elm)
1557 | (with-current-buffer (car elm)
1558 | (unless buffer-read-only
1559 | (save-excursion
1560 | (mapc (lambda (cell)
1561 | (let ((k (car cell))
1562 | (v (cdr cell)))
1563 | (goto-char (point-min))
1564 | (delete-region (line-beginning-position k)
1565 | (line-end-position k))
1566 | (goto-char (line-beginning-position k))
1567 | (insert v)))
1568 | (cdr elm))))
1569 | (if helm-multi-swoop-edit-save
1570 | (if buffer-read-only
1571 | (setq read-only t)
1572 | (save-buffer)))))
1573 | lines)
1574 | (select-window helm-swoop-synchronizing-window)
1575 | (kill-buffer (get-buffer helm-multi-swoop-edit-buffer))
1576 | (if read-only
1577 | (message "Couldn't save some buffers because of read-only")
1578 | (message "Successfully helm-multi-swoop-edit applied to original buffer"))))
1579 |
1580 | (defun helm-multi-swoop--edit-delete-all-lines ()
1581 | "Delete all extracted lines, and apply change to buffers and kill temporary edit buffer."
1582 | (interactive)
1583 | (let ((lines (helm-multi-swoop--collect-edited-lines))
1584 | read-only)
1585 | (mapc (lambda (elm)
1586 | (with-current-buffer (car elm)
1587 | (unless buffer-read-only
1588 | (save-excursion
1589 | (mapc (lambda (cell)
1590 | (let ((k (car cell)))
1591 | (goto-char (point-min))
1592 | (delete-region (line-beginning-position k)
1593 | (if (eq (line-end-position k)
1594 | (point-max))
1595 | (line-end-position k)
1596 | (1+ (line-end-position k))))))
1597 | (cdr elm))))
1598 | (if helm-multi-swoop-edit-save
1599 | (if buffer-read-only
1600 | (setq read-only t)
1601 | (save-buffer)))))
1602 | lines)
1603 | (select-window helm-swoop-synchronizing-window)
1604 | (kill-buffer (get-buffer helm-multi-swoop-edit-buffer))
1605 | (if read-only
1606 | (message "Couldn't save some buffers because of read-only")
1607 | (message "Successfully helm-multi-swoop-edit applied to original buffer"))))
1608 |
1609 | (defun helm-multi-swoop--edit-cancel ()
1610 | "Cancel edit and kill temporary buffer."
1611 | (interactive)
1612 | (select-window helm-swoop-synchronizing-window)
1613 | (kill-buffer (get-buffer helm-multi-swoop-edit-buffer))
1614 | (message "helm-multi-swoop-edit canceled"))
1615 |
1616 | ;;;###autoload
1617 | (defun helm-multi-swoop-edit ()
1618 | "Multi swoop edit."
1619 | (interactive)
1620 | (helm-exit-and-execute-action 'helm-multi-swoop--edit))
1621 |
1622 | ;;; @ helm-swoop-same-face-at-point -----------------------------------
1623 |
1624 | (defsubst helm-swoop--get-at-face (&optional point)
1625 | "Get at face at POINT."
1626 | (or point (setq point (point)))
1627 | (let ((face (or (get-char-property point 'read-face-name)
1628 | (get-char-property point 'face))))
1629 | face))
1630 |
1631 | (defun helm-swoop--cull-face-include-line (face)
1632 | "Cull face include line for FACE."
1633 | (let ((po (point-min)) res)
1634 | (save-excursion
1635 | (while (setq po (next-single-property-change po 'face))
1636 | (when (equal face (helm-swoop--get-at-face po))
1637 | (goto-char po)
1638 | (setq res (cons (format "%s %s"
1639 | (line-number-at-pos po)
1640 | (buffer-substring (line-beginning-position)
1641 | (line-end-position)))
1642 | res))
1643 | (let ((ov (make-overlay po (or (next-single-property-change po 'face)
1644 | (point-max)))))
1645 | (overlay-put ov 'face 'helm-swoop-target-word-face)
1646 | (overlay-put ov 'target-buffer 'helm-swoop-target-word-face)))))
1647 | (nreverse (delete-dups res))))
1648 |
1649 | (defun helm-swoop-same-face-at-point (&optional face)
1650 | "Same face at point for FACE."
1651 | (interactive)
1652 | (or face (setq face (helm-swoop--get-at-face)))
1653 | (helm-swoop :query ""
1654 | :source
1655 | `((name . "helm-swoop-same-face-at-point")
1656 | (candidates . ,(helm-swoop--cull-face-include-line face))
1657 | (header-line . ,(format "%s" face))
1658 | (action
1659 | . (("Go to Line"
1660 | . (lambda (line)
1661 | (helm-swoop--goto-line
1662 | (when (string-match "^[0-9]+" line)
1663 | (string-to-number (match-string 0 line))))
1664 | (let ((po (point))
1665 | (poe (line-end-position)))
1666 | (while (<= (setq po (next-single-property-change po 'face)) poe)
1667 | (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face po))
1668 | (goto-char po))))
1669 | (helm-swoop--recenter)))
1670 | ("Edit" . helm-swoop--edit))))))
1671 |
1672 | (defun helm-multi-swoop-same-face-at-point (&optional face)
1673 | "Same face at point for FACE."
1674 | (interactive)
1675 | (or face (setq face (helm-swoop--get-at-face)))
1676 | (helm-multi-swoop--exec
1677 | nil
1678 | :query ""
1679 | :func (lambda () (helm-swoop--cull-face-include-line face))
1680 | :action (lambda (line)
1681 | (switch-to-buffer (assoc-default 'name (helm-get-current-source)))
1682 | (helm-swoop--goto-line
1683 | (when (string-match "^[0-9]+" line)
1684 | (string-to-number (match-string 0 line))))
1685 | (let ((po (point))
1686 | (poe (line-end-position)))
1687 | (while (<= (setq po (next-single-property-change po 'face)) poe)
1688 | (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face po))
1689 | (goto-char po))))
1690 | (helm-swoop--recenter))
1691 | :buflist (helm-multi-swoop--get-buffer-list)))
1692 |
1693 | (provide 'helm-swoop)
1694 |
1695 | ;; Local Variables:
1696 | ;; indent-tabs-mode: nil
1697 | ;; End:
1698 |
1699 | ;;; helm-swoop.el ends here
1700 |
--------------------------------------------------------------------------------
/tests/helm-swoop-test.el:
--------------------------------------------------------------------------------
1 | ;;; helm-swoop-test.el --- Test definitions for helm-swoop -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright (C) 2019 Helm-Swoop Community
4 |
5 | ;; Author: Naoya Yamashita
6 | ;; License: GPL-3.0
7 | ;; Homepage: https://github.com/emacsorphanage/helm-swoop
8 |
9 | ;; This program is free software; you can redistribute it and/or modify
10 | ;; it under the terms of the GNU General Public License as published by
11 | ;; the Free Software Foundation, either version 3 of the License, or
12 | ;; (at your option) any later version.
13 |
14 | ;; This program is distributed in the hope that it will be useful,
15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | ;; GNU General Public License for more details.
18 |
19 | ;; You should have received a copy of the GNU General Public License
20 | ;; along with this program. If not, see .
21 |
22 | ;;; Commentary:
23 |
24 | ;; Test definitions for `helm-swoop'.
25 |
26 |
27 | ;;; Code:
28 |
29 | (require 'buttercup)
30 | (require 'helm-swoop)
31 |
32 | (describe "A suite"
33 | (it "contains a spec with an expectation"
34 | (expect t :to-be t)))
35 |
36 | ;; (provide 'helm-swoop-test)
37 |
38 | ;; Local Variables:
39 | ;; indent-tabs-mode: nil
40 | ;; End:
41 |
42 | ;;; helm-swoop-test.el ends here
43 |
--------------------------------------------------------------------------------