pax_global_header00006660000000000000000000000064151477543020014522gustar00rootroot0000000000000052 comment=d345e2198d6b80c01d627af7aa44ab25b9ed8eda jacktasia-dumb-jump-d345e21/000077500000000000000000000000001514775430200157035ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/.coderabbit.yaml000066400000000000000000000005061514775430200207440ustar00rootroot00000000000000# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json language: "en-US" early_access: false reviews: profile: "chill" request_changes_workflow: false high_level_summary: true poem: false review_status: true collapse_walkthrough: false auto_review: enabled: true drafts: false jacktasia-dumb-jump-d345e21/.dir-locals.el000066400000000000000000000002201514775430200203260ustar00rootroot00000000000000;;; Directory Local Variables ;;; For more information see (info "(emacs) Directory Variables") ((emacs-lisp-mode (indent-tabs-mode . nil))) jacktasia-dumb-jump-d345e21/.ert-runner000066400000000000000000000000241514775430200200010ustar00rootroot00000000000000--reporter ert -L . jacktasia-dumb-jump-d345e21/.github/000077500000000000000000000000001514775430200172435ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/.github/workflows/000077500000000000000000000000001514775430200213005ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/.github/workflows/test.yml000066400000000000000000000027201514775430200230030ustar00rootroot00000000000000name: CI on: push: branches: - master paths-ignore: - '**.md' pull_request: paths-ignore: - '**.md' jobs: linux: runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false matrix: emacs_version: ['25.3','26.1','26.2','26.3','27.1','28.1','29.4','30.1'] cask_version: ['snapshot'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.10' - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} - uses: conao3/setup-cask@master with: version: ${{ matrix.cask_version }} - name: Run tests timeout-minutes: 20 run: make actions-test macos: runs-on: macos-latest timeout-minutes: 30 strategy: fail-fast: false matrix: emacs_version: ['28.1','29.4','30.1'] cask_version: ['snapshot'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.10' - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} - uses: conao3/setup-cask@master with: version: ${{ matrix.cask_version }} - name: Install search tools run: brew install the_silver_searcher ripgrep - name: Run tests timeout-minutes: 20 run: make install unit jacktasia-dumb-jump-d345e21/.gitignore000066400000000000000000000000551514775430200176730ustar00rootroot00000000000000.cask/ \#.*test# .*test~ *.elc *.~undo-tree~ jacktasia-dumb-jump-d345e21/COPYING000066400000000000000000001044041514775430200167410ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . jacktasia-dumb-jump-d345e21/Cask000066400000000000000000000002571514775430200165130ustar00rootroot00000000000000(source gnu) (source melpa) (package-file "dumb-jump.el") (development (depends-on "el-mock") (depends-on "noflet") (depends-on "ert-runner") (depends-on "undercover")) jacktasia-dumb-jump-d345e21/Makefile000066400000000000000000000114771514775430200173550ustar00rootroot00000000000000# Build Control Makefile # # - Best used with GNU Make. # - Support NetBSD bmake (will issue a warning on the -include line; ignore it) # - If support for smake (Jörg Schilling make) is needed, a SMakefile should be written. # Identify tools: # Set this to detect if GNU Make is being used. _GNU_MAKE_ONLY_FILE = $(if $(MAKE_VERSION),gnu.mk) # Set these but don't override values from the environment if they are set. CASK ?= cask EMACS ?= emacs EMACS_VERSION ?= 29.4 GH ?= gh RELEASE_REPO ?= jacktasia/dumb-jump RELEASE_BRANCH ?= master RELEASE_VERSION ?= RELEASE_BUMP ?= RELEASE_NOTES_FILE ?= RELEASE_GENERATE_NOTES ?= 1 # ---------------------------------------------------------------------------- # Rules # ----- # Most recipes do not correspond to the presence of a file; they must be # declared PHONY to avoid conflict with a file name. # .PHONY: all test unit install setup \ actions-test test-docker test-this-docker \ release-dry-run release-check release help all: test .cask: ${CASK} test: unit unit: .cask ${CASK} exec ert-runner install: ${CASK} install setup: @bash test/github-actions-setup.sh actions-test: install setup unit # EMACS_VERSION can be overridden: make test-docker EMACS_VERSION=28.2 test-docker: @bash test/run-tests-locally.sh $(EMACS_VERSION) release-dry-run: @GH="$(GH)" \ RELEASE_REPO="$(RELEASE_REPO)" \ RELEASE_BRANCH="$(RELEASE_BRANCH)" \ RELEASE_VERSION="$(RELEASE_VERSION)" \ RELEASE_BUMP="$(RELEASE_BUMP)" \ RELEASE_TAG="$(RELEASE_TAG)" \ RELEASE_NOTES_FILE="$(RELEASE_NOTES_FILE)" \ RELEASE_GENERATE_NOTES="$(RELEASE_GENERATE_NOTES)" \ bash test/release.sh dry-run release-check: @GH="$(GH)" \ RELEASE_REPO="$(RELEASE_REPO)" \ RELEASE_BRANCH="$(RELEASE_BRANCH)" \ RELEASE_VERSION="$(RELEASE_VERSION)" \ RELEASE_BUMP="$(RELEASE_BUMP)" \ RELEASE_TAG="$(RELEASE_TAG)" \ RELEASE_NOTES_FILE="$(RELEASE_NOTES_FILE)" \ RELEASE_GENERATE_NOTES="$(RELEASE_GENERATE_NOTES)" \ bash test/release.sh check release: @GH="$(GH)" \ RELEASE_REPO="$(RELEASE_REPO)" \ RELEASE_BRANCH="$(RELEASE_BRANCH)" \ RELEASE_VERSION="$(RELEASE_VERSION)" \ RELEASE_BUMP="$(RELEASE_BUMP)" \ RELEASE_TAG="$(RELEASE_TAG)" \ RELEASE_NOTES_FILE="$(RELEASE_NOTES_FILE)" \ RELEASE_GENERATE_NOTES="$(RELEASE_GENERATE_NOTES)" \ bash test/release.sh release # Include the test-some rule only when GNU Make is used. # # - GNU Make will try to include 'gnu.mk'. # - NetBSD Make (bmake) will see '-include ' (empty) and do nothing as # expected because the content of gnu.mk can only be parsed by GNU Make. # - The gnu.mk parses Make command line and builds the logic for the test-this # and test-this-docker rules. # -include $(_GNU_MAKE_ONLY_FILE) help: @printf -- "\n\ Execute dumb-jump Ert tests.\n\ The following targets are supported:\n\ \n\ - make : same as 'make test'\n\ - make install : install all dependencies specified in Cask file\n\ - make unit : execute all Ert tests\n\ - make test : execute all Ert tests\n\ - make test-this T1 [T2...] : execute specified Ert test(s) T1, T2...\n\ - make test-this-docker T1 [T2...] : execute specified Ert test(s) in Docker\n\ - make test-concurrent : execute all Ert tests, but concurrently.\n\ - make test-docker : run tests locally in Docker (default: Emacs 29.4)\n\ - make test-docker EMACS_VERSION=X.Y : run tests in Docker with a specific Emacs version\n\ - make release-dry-run : show planned release version/tag and readiness checks\n\ - make release-check : validate release prerequisites\n\ - make release : tag/push current version and create GitHub release\n\ - make help : prints this help.\n\n\ Notes:\n\ - 'test-concurrent' shows # of skipped tests due to unavailability of a search tool, others do not.\n\ - 'test-this' and 'test-this-docker' are only available when using GNU Make.\n\ - Use 'test-this' to identify a set of tests by complete or partial names.\n\ - Use 'test-this-docker' to run a filtered test set in Docker.\n\ - 'test-docker' requires Docker. Supported Emacs versions: 26.3 27.2 28.2 29.4 30.2\n\ - 'release' does not run tests; run them manually before cutting a release.\n\ - 'release' expects a clean '$(RELEASE_BRANCH)' checkout with ';; Version:' set in dumb-jump.el.\n\ - Default release bump behavior: if current vX.Y.Z tag exists, patch bumps to next version.\n\ - Optional release vars: RELEASE_VERSION=X.Y.Z RELEASE_BUMP=patch|minor|major RELEASE_TAG=vX.Y.Z RELEASE_NOTES_FILE=path RELEASE_GENERATE_NOTES=0\n\n" # ---------------------------------------------------------------------------- jacktasia-dumb-jump-d345e21/README.md000066400000000000000000000365551514775430200172000ustar00rootroot00000000000000# dumb-jump ![CI](https://github.com/jacktasia/dumb-jump/workflows/CI/badge.svg) [![MELPA](http://melpa.org/packages/dumb-jump-badge.svg?x=6)](http://melpa.org/#/dumb-jump) [![MELPA Stable](https://stable.melpa.org/packages/dumb-jump-badge.svg?x=1)](https://stable.melpa.org/#/dumb-jump) ![Dumb Jump GIF](media/dumb-jump-example-v2.gif?raw=true) ## About **Dumb Jump** is an Emacs "jump to definition" package with support for 60+ programming languages that favors "just working". This means minimal -- and ideally zero -- configuration with absolutely no stored indexes (TAGS) or persistent background processes. Dumb Jump requires at least GNU Emacs `24.4` (the package uses `subr-x` helpers such as `string-trim`, `string-blank-p`, `string-prefix-p`, and `string-suffix-p` in `dumb-jump.el`). ### How it works Dumb Jump uses [The Silver Searcher](https://github.com/ggreer/the_silver_searcher) `ag`, [ripgrep](https://github.com/BurntSushi/ripgrep) `rg`, or `grep` to find potential definitions of a function or variable under point. It uses a set of regular expressions based on the file extension, or `major-mode`, of the current buffer. The matches are run through a shared set of heuristic methods to find the best candidate to jump to. If it can't decide and you are using the legacy selector path, it will present the user with a list using `completing-read`, helm, or ivy via `dumb-jump-selector`. The `xref` UI is described separately later in this README. #### Success Rate For the currently [supported languages](#supported-languages) it seems to do a good job of finding what you want. If you find a case where it does not work as expected do not hesitate to [open an issue](https://github.com/jacktasia/dumb-jump/issues). It can be slow if it needs to use `grep` and/or a project is large. Although it can be sped up by [installing `ag`](https://github.com/ggreer/the_silver_searcher#installing) or [installing `rg`](https://github.com/BurntSushi/ripgrep#installation) and/or creating a `.dumbjump` file in your project's root directory with paths that should be excluded ([see configuration](#configuration)). ## Supported Languages There is currently basic support for the following languages: * Apex * Bash * C/C++ * C# * Clojure * COBOL * CoffeeScript * Common Lisp * Coq * Crystal * Dart * D * Elixir * Emacs Lisp * Erlang * F# * Faust * Fennel * Fortran * Go * Groovy * Haskell * Jai * Java * JavaScript * Julia * Kotlin * LaTeX * Lua * Matlab * Nim * Nix * Objective-C * OCaml * Odin * OpenSCAD * Org mode * Pascal * Perl * PHP * Protocol Buffers * PureScript * Python * R * Racket * Ruby * Rust * Sass * Scala * Scheme * SML * Solidity * SQL * Swift * SystemVerilog * Tcl * Terraform / HCL * TypeScript * Vala * VHDL * Zig If you have any issues with the existing languages, or you want support for another one, then please [open an issue](https://github.com/jacktasia/dumb-jump/issues). PRs are also welcome. If you'd like to add a language these PRs for [lua](https://github.com/jacktasia/dumb-jump/pull/33) and [rust](https://github.com/jacktasia/dumb-jump/pull/57) are good examples. ## Installing The recommended way to install Dumb Jump is via `package.el`. It's available on [MELPA](http://melpa.org/#/dumb-jump): M-x `package-install dumb-jump` #### Spacemacs If you're using an up-to-date Spacemacs, then you already have Dumb Jump by default just make sure you install `ag` or `rg` (see below) to ensure you have the best experience. #### Installing `ag` or `rg` Dumb Jump performs best with The Silver Searcher `ag` ([ag install instructions](https://github.com/ggreer/the_silver_searcher#installing)) or ripgrep `rg` ([rg install instructions](https://github.com/BurntSushi/ripgrep#installation)) installed on your system. ## Usage #### Basic To enable the [xref][] backend (new in version 0.5.4), evaluate ~~~lisp (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) ~~~ or add it to your initialisation file. Using this, you can now use M-. (or gd when using Evil). Xref can be customized to use `completing-read` to select a target. That way a completion framework of your choice (Icomplete, Helm, Ivy, ...) will be used instead of the default pop-up buffer. To do this, evaluate ~~~lisp (setq xref-show-definitions-function #'xref-show-definitions-completing-read) ~~~ Note that the function `xref-show-definitions-completing-read` requires at least Xref 1.1.0. This can either be downloaded from ELPA or is bundled with Emacs 28.1 or newer. If you use [Consult](https://github.com/minad/consult), you can set `xref-show-definitions-function` to `consult-xref` to get live preview of definition candidates while you cycle through them: ~~~lisp (setq xref-show-definitions-function #'consult-xref) ~~~ `use-package` example: ~~~lisp (use-package dumb-jump :ensure t :custom (dumb-jump-prefer-searcher 'rg) (xref-show-definitions-function #'consult-xref) :config (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)) ~~~ [xref]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html ## Configuration ##### Excluding project directories Dumb Jump will automatically look for a project root. If it's not finding one then either put a `.dumbjump` file in your project root and optionally add excluded directories to make it faster. Project root directory denoters: `.dumbjump` `.projectile` `.git` `.hg` `.fslckout` `.bzr` `_darcs` `.svn` `Makefile` `PkgInfo` `-pkg.el` `_FOSSIL_`. If you want to stop a directory from registering as the project root (and have Dumb Jump keep looking) add an empty `.dumbjumpignore` file in that directory. ##### Example `.dumbjump` -tests -node_modules -build -images +../some-lib/src +/usr/lib/src *NOTE* When adding paths outside of the project (using `+`) ensure you use `dumb-jump-force-searcher` of either `'ag` or `'rg` (see below). This is required because the default searcher (`git-grep`) won't be able to search outside of the project root. This edge case will be fixed in a future release. That is, `git-grep` will NOT be set as the default searcher if a `.dumbjump` is present with a `+` path outside of the repo. ##### `.emacs` options * `(setq dumb-jump-default-project "~/code")` to change default project if one is not found (defaults to `~`) * `(setq dumb-jump-quiet t)` if Dumb Jump is too chatty. * To support more languages and/or definition types customize `dumb-jump-find-rules` variable. * `(setq dumb-jump-git-grep-search-args "")` to set additional command line arguments when using git-grep for searching (defaults to `""`). * `(setq dumb-jump-ag-search-args "")` to set additional command line arguments when using ag for searching (defaults to `""`). * `(setq dumb-jump-rg-search-args "")` to set additional command line arguments when using rg for searching (defaults to `"--pcre2"`). Two user-options are used to select the search tool: * `dumb-jump-prefer-searcher`: identifies the search tool normally used, unless it is nil or the value of `dumb-jump-force-searcher` overrides your preference. * `dumb-jump-force-searcher`: identifies how the searcher selection is overridden: * If you want to force a specific tool like `ag` or `rg` set `dumb-jump-force-searcher` to that value. * If you want to use the tool selected by `dumb-jump-prefer-searcher` *except* for some directories where you prefer to use `git-grep`, then set `dumb-jump-force-searcher` to a list holding the path of these directories. * If you want more flexibility in the overriding, then write a function that takes the project directory and return a symbol identifying the search tool to sue for that project directory, or nil to honor `dumb-jump-prefer-searcher` choice. When both `dumb-jump-prefer-searcher` and `dumb-jump-force-searcher` are nil, Dumb Jump selects the first tool found from this list, in that order: * `ag`, * `rg`, * `gnu grep`, * `grep`. These can also all be set via Emacs customization. Once `dump-jump` is loaded, type: M-x `customize-group dumb-jump` to open the customization buffer. Here's a code example for using `ag` in most cases, but overriding this choice to `rg` in monorepos where git-grep has poor hit-rate, use `git grep` in some known directories like `~/src/emacs`: ~~~lisp ;; Choose a default searcher for most projects: (setq dumb-jump-prefer-searcher 'ag) ;; Conditionally override the searcher per-project. (defun my/dumb-jump-force-searcher (project-dir) "Return a dumb-jump searcher symbol for PROJECT-DIR, or nil to not override." (cond ;; Example: force ripgrep in monorepos where git-grep has poor hit-rate ;; (adapt the predicate to your environment). ((string-match-p "/work/monorepo-" project-dir) 'rg) ;; Example: force git-grep in a handful of projects where it’s known-good. ((member (file-truename project-dir) (mapcar #'file-truename '("~/src/emacs/" "~/src/small-lib/"))) 'git-grep) ;; Otherwise: no override; use dumb-jump-prefer-searcher selection. (t nil))) (setq dumb-jump-force-searcher #'my/dumb-jump-force-searcher) ~~~ You can also force an overriding in a specific directory by setting `dumb-jump-force-searcher` in its `.dir-locals.el` file: ~~~lisp ((nil . ((dumb-jump-force-searcher . rg)))) ~~~ #### If your project has multi-line method signatures [you should use `ag`](https://github.com/jacktasia/dumb-jump/issues/129) or [`rg` version `0.10.0` or higher](https://github.com/jacktasia/dumb-jump/issues/255). ##### macOS and git-grep `git-grep` does not work correctly on macOS as of git 2.39 and later. Between versions 2.37 and 2.39, git switched to using the platform's native BSD regex library instead of GNU grep, which breaks the `\b` word-boundary patterns that Dumb Jump relies on. Installing GNU grep does not fix this because it is git's internal regex engine that changed, not the system grep. **Workaround:** force a different searcher on macOS: ~~~lisp (setq dumb-jump-force-searcher 'rg) ; or 'ag ~~~ To learn more about how Dumb Jump picks a searcher see [this issue](https://github.com/jacktasia/dumb-jump/issues/109) and this [pull request](https://github.com/jacktasia/dumb-jump/pull/111). ##### Hydra for effieciency If you have [Hydra](https://github.com/abo-abo/hydra) installed, the following is an example hydra for easily using Dumb-Jump and not needing to remember the bindings or function names: ```el (defhydra dumb-jump-hydra (:color blue :columns 3) "Dumb Jump" ("j" dumb-jump-go "Go") ("o" dumb-jump-go-other-window "Other window") ("e" dumb-jump-go-prefer-external "Go external") ("x" dumb-jump-go-prefer-external-other-window "Go external other window") ("i" dumb-jump-go-prompt "Prompt") ("l" dumb-jump-quick-look "Quick look") ("b" dumb-jump-back "Back")) ``` It can be explicitly bound or used inside another hydra (if you already use something like [Avy](https://github.com/abo-abo/avy)/[Ace](https://github.com/winterTTr/ace-jump-mode) or similar for general "jumping"). #### Debugging a jump 1. M-x `set-variable dumb-jump-debug t` 1. try to jump 1. go to buffer `*Messages*` More details [here](http://p.cweiske.de/506). Thanks to @cweiske and @Glumanda99 ## Obsolete commands and options Versions of dumb jump older than 0.5.4 didn't use xref, and instead had custom commands. These, while marked obsolete, can still be used: * `dumb-jump-go` (former) core functionality. Attempts to jump to the definition for the thing under point. This has been replaced in the new interface with `xref-find-definitions` (M-.). * `dumb-jump-back` jumps back to where you were when you jumped. These are chained so if you go down a rabbit hole you can get back out or where you want to be. This has been replaced with `xref-pop-marker-stack` (M-,), but is mostly equivalent. * `dumb-jump-quick-look` like `dumb-jump-go` but **only** shows tooltip with `file`, `line`, and `context` it does not jump. * `dumb-jump-go-other-window` exactly like `dumb-jump-go` but uses `find-file-other-window` instead of `find-file` * `dumb-jump-go-prefer-external` like `dumb-jump-go` but will prefer definitions not in the current buffer * `dumb-jump-go-prefer-external-other-window` expected combination of `dumb-jump-go-prefer-external` and `dumb-jump-go-other-window` * `dumb-jump-go-prompt` exactly like `dumb-jump-go` but prompts user for function to jump to A few user options only have an effect when used with the legacy interface. These are: * `dumb-jump-after-jump-hook` (use `xref-after-jump-hook` instead) * `dumb-jump-before-jump-hook` (use `xref-after-return-hook` instead) * `dumb-jump-selector` * `dumb-jump-aggressive` * `dumb-jump-use-visible-window` * `dumb-jump-confirm-jump-to-modified-file` The minor mode `dumb-jump-mode` binds a few of these commands by default. If you still use Emacs 24 or older, you won't have xref, and have to use the legacy interface instead. In that case, there will also be no "obsolete" warnings. ## Why? I wanted "jump to definition" functionality to "just work" in emacs. I use IntelliJ for Java and this functionality is basically the only thing I miss when I switch back to emacs for work in other languages. There are certainly other packages that offer this type of functionality, but they all require significantly more configuration and are often limited to a particular language. An alternative may be worth setting up if you are in a specific project or language often (see [alternatives](#alternatives)). ## Contributing Feedback is very welcome via GitHub issues. I will consider supporting other languages either via issue request or PR. If submitting a PR then please add tests as well. ## Running Tests Opening a PR will use GitHub Actions to run all the tests against all supported Emacs versions on Linux and macOS. ### Running tests locally There are a lot of options for running the tests locally: #### Basic/Classic requires [Cask](https://github.com/cask/cask) using your local emacs ```sh cd /path/to/dumb-jump make test ``` The first time you run this it will also run `cask` to setup your directory. ##### Run a subset of tests is the same as before but use the `test-this` target followed by one or several full or partial test names. For example, to run all tests that have 'clojure' or 'org' in their test function name do this: ```sh cd /path/to/dumb-jump make test-this clojure org ``` #### Concurrent requires golang and [Cask](https://github.com/cask/cask) using your local emacs ```sh cd /path/to/dumb-jump make test-concurrent ``` #### Docker only requires Docker; runs tests against the default Emacs version (29.4) ~~~sh cd /path/to/dumb-jump make test-docker ~~~ To run against a specific Emacs version: ~~~sh make test-docker EMACS_VERSION=28.2 ~~~ To run a subset of tests in Docker (GNU Make only): ~~~sh make test-this-docker clojure org ~~~ Supported versions: `26.3 27.2 28.2 29.4 30.2` ## Alternatives Here is a list of potential alternative packages for emacs: * [Tags](https://www.gnu.org/software/emacs/manual/html_node/emacs/Tags-Tables.html) supports multiple languages * [GNU Global](http://www.gnu.org/software/global/) supports multiple languages * [Tern](http://ternjs.net/) for JavaScript * [elpy](https://github.com/jorgenschaefer/elpy) for Python * [robe](https://github.com/dgutov/robe) for Ruby Most of these were sourced from this [emacs StackExchange answer](http://emacs.stackexchange.com/questions/10125/can-emacs-support-go-to-declaration-of-function-in-an-entire-project). jacktasia-dumb-jump-d345e21/dumb-jump.el000066400000000000000000006612041514775430200201360ustar00rootroot00000000000000;;; dumb-jump.el --- Jump to definition for 60+ languages without configuration -*- lexical-binding: t; -*- ;; Copyright (C) 2015-2021 jack angers ;; Author: jack angers and contributors ;; Url: https://github.com/jacktasia/dumb-jump ;; Version: 0.5.5 ;; Package-Requires: ((emacs "24.4") (dash "2.9.0")) ;; Keywords: programming ;; Dumb Jump is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; Dumb Jump is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public ;; License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Dumb Jump. If not, see http://www.gnu.org/licenses. ;;; Commentary: ;; Dumb Jump is an Emacs "jump to definition" package with support for 60+ programming languages that favors ;; "just working" over speed or accuracy. This means minimal -- and ideally zero -- configuration with absolutely ;; no stored indexes (TAGS) or persistent background processes. ;; ;; Dumb Jump provides a xref-based interface for jumping to ;; definitions. It is based on tools such as grep, the silver searcher ;; (https://geoff.greer.fm/ag/), ripgrep ;; (https://github.com/BurntSushi/ripgrep) or git-grep ;; (https://git-scm.com/docs/git-grep). ;; ;; To enable Dumb Jump, add the following to your initialisation file: ;; ;; (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) ;; ;; Now pressing M-. on an identifier should open a buffer at the place ;; where it is defined, or a list of candidates if uncertain. This ;; list can be navigated using M-g M-n (next-error) and M-g M-p ;; (previous-error). ;;; Code: (unless (require 'xref nil :noerror) (require 'etags)) (require 'dash) (require 'cl-generic nil :noerror) (require 'cl-lib) (require 'subr-x) ; use: `string-blank-p' (defun dumb-jump--chop-prefix (prefix text) "Remove PREFIX from TEXT when present." (if (and (stringp prefix) (stringp text) (string-prefix-p prefix text)) (substring text (length prefix)) text)) (defun dumb-jump--contains-p (needle text &optional ignore-case) "Return non-nil when TEXT contains NEEDLE as a literal substring. When IGNORE-CASE is non-nil, match without case sensitivity." (and (stringp needle) (stringp text) (save-match-data (let ((case-fold-search ignore-case)) (if (string-match-p (regexp-quote needle) text) t nil))))) (defun dumb-jump--index-of (needle text) "Return the index of NEEDLE in TEXT, or nil when not found." (when (and (stringp needle) (stringp text)) (save-match-data (string-match-p (regexp-quote needle) text)))) (defun dumb-jump--join (separator strings) "Join STRINGS using SEPARATOR." (mapconcat #'identity strings separator)) (defun dumb-jump--match (regexp text &optional start) "Return list of REGEXP matches in TEXT from START, or nil." (when (and (stringp regexp) (stringp text)) (save-match-data (when (string-match regexp text start) (let* ((group-count (/ (length (match-data t)) 2)) (i 0) matches) (while (< i group-count) (push (match-string i text) matches) (setq i (1+ i))) (nreverse matches)))))) (defun dumb-jump--matched-positions-all (regexp text &optional start) "Return a list of match ranges for REGEXP in TEXT from START. Each element is a cons cell of the form (START . END)." (when (and (stringp regexp) (stringp text)) (save-match-data (let ((pos (or start 0)) matches) (while (string-match regexp text pos) (let ((beg (match-beginning 0)) (end (match-end 0))) (push (cons beg end) matches) ;; Avoid infinite loops if REGEXP can match empty strings. (setq pos (if (= beg end) (1+ end) end)))) (nreverse matches))))) (defun dumb-jump--replace (old new text) "Replace all OLD literal matches in TEXT with NEW." (replace-regexp-in-string (regexp-quote old) (or new "") (or text "") t t)) (defun dumb-jump--split (regexp text &optional omit-nulls) "Split TEXT on REGEXP and optionally OMIT-NULLS." (split-string (or text "") regexp omit-nulls)) (defun dumb-jump--trim (text) "Trim leading and trailing whitespace from TEXT." (string-trim (or text ""))) (defun dumb-jump--select-choice (choices &optional prompt) "Choose one of CHOICES with `completing-read'. PROMPT defaults to \"Jump to: \"." (completing-read (or prompt "Jump to: ") choices nil t)) (defun dumb-jump--show-preview (text) "Display TEXT preview to the user." (message "%s" text)) (defgroup dumb-jump nil "Easily jump to project function and variable definitions." :group 'tools :group 'convenience) ;;;###autoload (defvar dumb-jump-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-M-g") 'dumb-jump-go) (define-key map (kbd "C-M-p") 'dumb-jump-back) (define-key map (kbd "C-M-q") 'dumb-jump-quick-look) map)) (defcustom dumb-jump-window 'current "Which window to use when jumping. Valid options are \\='current (default) or \\='other." :group 'dumb-jump :type '(choice (const :tag "Current window" current) (const :tag "Other window" other))) (defcustom dumb-jump-use-visible-window t "If true will jump in a visible window that shows the opened file." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-selector 'completing-read "Which selector to use when there is multiple choices. The available selectors are: - helm : https://emacs-helm.github.io/helm/ - ivy : https://github.com/abo-abo/swiper - Completing Read: Emacs default `completing-read'. When selecting helm or ivy, if the corresponding package is not installed, the selector falls back to `completing-read'." :group 'dumb-jump :type '(choice (const :tag "Helm" helm) (const :tag "Ivy" ivy) (const :tag "Completing Read" completing-read))) (defcustom dumb-jump-ivy-jump-to-selected-function #'dumb-jump-ivy-jump-to-selected "Prompts user for a choice using ivy then dumb-jump to that choice." :group 'dumb-jump :type 'function) (defcustom dumb-jump-prefer-searcher nil "The preferred searcher command line tool to use. The available choices are: - \\='ag : https://github.com/ggreer/the_silver_searcher - \\='rg : https://github.com/BurntSushi/ripgrep - \\='grep : https://en.wikipedia.org/wiki/Grep - \\='gnu-grep : https://www.gnu.org/software/grep/manual/grep.html - \\='git-grep : https://git-scm.com/docs/git-grep - \\='git-grep-plus-ag If nil, select the most optimal searcher at runtime, looking for all tools listed above except for git-grep in the order of that list. However, the choice is overridden by `dumb-jump-force-searcher' selection unless that is nil." :group 'dumb-jump :type '(choice (const :tag "Best Available" nil) (const :tag "ag" ag) (const :tag "rg" rg) (const :tag "grep" grep) (const :tag "gnu-grep" gnu-grep) (const :tag "git grep" git-grep) (const :tag "git grep + ag" git-grep-plus-ag))) (defcustom dumb-jump-force-searcher nil "Search tool override of `dumb-jump-prefer-searcher' selection. By default this is nil to honour the choice made by `dumb-jump-prefer-searcher'. However, you may want to override that choice for some projects by identifying one of two preferred choice overriding methods: - Override preferred via user-specified function: Enter the name of a function that takes the current directory and return the search tool symbol to use for this project or nil if the choice made in `dumb-jump-prefer-searcher' must be honoured. - Override preferred for directories needing git-grep: Specify one or more project directories where the git-grep search tool must be used. - Override to a specific tool. That is mostly useful to set the overriding inside the .dir-locals.el of the directory. The choices are: \\='ag, \\='rg, \\='grep, \\='gnu-grep, \\='git-grep, or \\='git-grep-plus-ag." :group 'dumb-jump :type '(choice (const :tag "nil: honour `dumb-jump-prefer-searcher' choice." nil) (function :tag "Override preferred via user-specified function") (repeat :tag "Override preferred for directories needing git-grep" (directory :tag "Repo root")) (const :tag "ag" ag) (const :tag "rg" rg) (const :tag "grep" grep) (const :tag "gnu grep" gnu-grep) (const :tag "git grep" git-grep) (const :tag "git grep + ag" git-grep-plus-ag))) (defcustom dumb-jump-grep-prefix "LANG=C" "Prefix to grep command. Seemingly makes it faster for pure text." :group 'dumb-jump :type 'string) (defcustom dumb-jump-grep-cmd "grep" "The path to grep. By default assumes it is in path." :group 'dumb-jump :type 'string) (defcustom dumb-jump-ag-cmd "ag" "The path to the silver searcher. By default assumes it is in path." :group 'dumb-jump :type 'string) (defcustom dumb-jump-rg-cmd "rg" "The path to ripgrep. By default assumes it is in path." :group 'dumb-jump :type 'string) (defcustom dumb-jump-git-grep-cmd "git grep" "The path to git grep. By default assumes it is in path." :group 'dumb-jump :type 'string) ;; --------------------------------------------------------------------------- ;; Dumb Jump Regular Expressions (see `dumb-jump-find-rules' docstring) (defcustom dumb-jump-force-using-space-bracket-exp (eq system-type 'windows-nt) "When t the `\\\\s` in regexp code strings is replaced by `[[:space:]]`. Otherwise it is left in the regular expression. Defaults to t under Windows because older gnu grep versions have problem dealing with `\\\\s` to match end of words due to the 2 bytes used to identify the end of line." :group 'dumb-jump :type 'boolean) (defun dumb-jump-use-space-bracket-exp-for (variant) "Return t when `\\\\s` must be replaced by `[[:space]]` for VARIANT. VARIANT must be a one of the following symbols: ag, rg, grep, gnu-grep, git-grep or git-grep-plus-ag." (and dumb-jump-force-using-space-bracket-exp (memq variant '(grep gnu-grep git-grep git-grep-plus-ag)))) ;; word-boundary regexps: they replace the "\\j" in dumb-jump regexes. ;; [:todo 2026-01-29, by Pierre Rouleau: Should we not exclude '_' from word boundary?] (defcustom dumb-jump-ag-word-boundary "(?![a-zA-Z0-9\\?\\*-])" "Regexp that replaces `\\j` in dumb-jump regexes for ag search. `\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and ag will use this value." :group 'dumb-jump :type 'string) ;; [:todo 2026-01-29, by Pierre Rouleau: Should we not exclude '_' from word boundary?] (defcustom dumb-jump-rg-word-boundary "($|[^a-zA-Z0-9\\?\\*-])" "Regexp that replaces `\\j` in dumb-jump regexes for rg search. `\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and rg will use this value." :group 'dumb-jump :type 'string) ;; [:todo 2026-01-29, by Pierre Rouleau: Should we not exclude '_' from word boundary?] (defcustom dumb-jump-git-grep-word-boundary "($|[^a-zA-Z0-9\\?\\*-])" "Regexp that replaces `\\j` in dumb-jump regexes for git-grep search. `\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and git grep will use this value." :group 'dumb-jump :type 'string) ;; [:todo 2026-01-29, by Pierre Rouleau: Should we not exclude '_' from word boundary?] (defcustom dumb-jump-grep-word-boundary "($|[^a-zA-Z0-9\\?\\*-])" "Regexp that replaces `\\j` in dumb-jump regexes for grep search. `\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and grep will use this value." :group 'dumb-jump :type 'string) ;; [:todo 2026-01-29, by Pierre Rouleau: Should we not exclude '_' from word boundary?] (defcustom dumb-jump-gnu-grep-word-boundary "($|[^a-zA-Z0-9\\?\\*-])" "Regexp that replaces `\\j` in dumb-jump regexes for gnu grep search. `\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and grep will use this value." :group 'dumb-jump :type 'string) ;; -- (defcustom dumb-jump-fallback-regex "\\bJJJ\\j" "When `dumb-jump-fallback-search' is t use this regex. Defaults to boundary search of symbol under point." :group 'dumb-jump :type 'string) (defcustom dumb-jump-fallback-search t "If nothing is found with normal search fallback searching fallback regex." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-zgrep-cmd "zgrep" "The path to grep to use for gzipped files. By default assumes it is in path." :group 'dumb-jump :type 'string) (defcustom dumb-jump-grep-args "-REn" "Grep command args [R]ecursive, [E]xtended regexes, and show line [n]umbers." :group 'dumb-jump :type 'string) (defcustom dumb-jump-gnu-grep-args "-rEn" "Grep command args [r]ecursive and [E]xtended regexes, and show line [n]umbers." :group 'dumb-jump :type 'string) (defcustom dumb-jump-max-find-time 2 "Number of seconds a grep/find command can take before issuing a warning. The warning recommend using a faster search tool and config." :group 'dumb-jump :type 'integer) (defcustom dumb-jump-functions-only nil "Should we only jump to functions?" :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-quiet nil "If non-nil Dumb Jump will not log anything to *Messages*. Note that it prevents printing when `dumb-jump-debug' is non-nil." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-ignore-context nil "If non-nil Dumb Jump will ignore the context of point when jumping." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-git-grep-search-untracked t "If non-nil Dumb Jump will also search untracked files when using git-grep." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-git-grep-search-args "" "Appends the passed arguments to the git-grep search function. Default: \"\"." :group 'dumb-jump :type 'string) (defcustom dumb-jump-ag-search-args "" "Appends the passed arguments to the ag search function. Default: \"\"." :group 'dumb-jump :type 'string) (defcustom dumb-jump-rg-search-args "--pcre2" "Appends the passed arguments to the rg search function. Default: \"--pcre2\"." :group 'dumb-jump :type 'string) (defcustom dumb-jump-search-type-org-only-org t "If non nil restrict type ag/rg to org file. If nil add also the language type of current src block." :group 'dumb-jump :type 'boolean) ;; [:todo 2026-01-29, by Pierre Rouleau: Why 3 backslashes in front of '('? ] (defcustom dumb-jump-find-rules ;;-- elisp '((:language "elisp" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\((defun|cl-defun|cl-defgeneric|cl-defmethod|cl-defsubst)\\s+JJJ\\j" :tests ("(defun test (blah)" "(defun test\n" "(cl-defun test (blah)" "(cl-defun test\n") :not ("(defun test-asdf (blah)" "(defun test-blah\n" "(cl-defun test-asdf (blah)" "(cl-defun test-blah\n" "(defun tester (blah)" "(defun test? (blah)" "(defun test- (blah)")) (:language "elisp" :type "function" ; macros :supports ("ag" "grep" "rg" "git-grep") :regex "\\((defmacro|cl-defmacro|cl-define-compiler-macro)\\s+JJJ\\j" :tests ("(defmacro test (blah)" "(defmacro test\n") :not ("(defmacro test-asdf (blah)" "(defmacro test-blah\n" "(defmacro tester (blah)" "(defmacro test? (blah)" "(defmacro test- (blah)")) (:language "elisp" :type "function" ; hydras :supports ("ag" "grep" "rg" "git-grep") :regex "\\(defhydra\\b\\s*JJJ\\j" :tests ("(defhydra test " "(defhydra test\n" "(defhydra test (blah\n" "(defhydra test (blah)") :not ("(defhydra tester" "(defhydra test?" "(defhydra test-" "(defhydra test? (blah\n" "(defhydra test? (blah)")) (:language "elisp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(defvar(-local)?\\b\\s*JJJ\\j" :tests ("(defvar test " "(defvar test\n" "(defvar-local test" "(defvar-local test\n") :not ("(defvar tester" "(defvar test?" "(defvar test-" "(defvar-local tester" "(defvar-local test?" "(defvar-local test-")) (:language "elisp" :type "variable" :supports ("ag" "grep" "rg" "ugrep" "git-grep") :regex "\\(defconst\\b\\s*JJJ\\j" :tests ("(defconst test " "(defconst test\n") :not ("(defconst tester" "(defconst test?" "(defconst test-")) (:language "elisp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(defcustom\\b\\s*JJJ\\j" :tests ("(defcustom test " "(defcustom test\n") :not ("(defcustom tester" "(defcustom test?" "(defcustom test-")) (:language "elisp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(setq\\b\\s*JJJ\\j" :tests ("(setq test 123)") :not ("setq test-blah 123)" "(setq tester" "(setq test?" "(setq test-")) ;; The following regex identifying let-bound variables is the reason why ;; searching for an elisp function cause a set of false positive on all ;; locations where the function is invoked. (:language "elisp" :type "variable" ; let bound variables :supports ("ag" "grep" "rg" "git-grep") :regex "\\(JJJ\\s+" :tests ("(let ((test 123)))" "(let* ((test 123)))") :not ("(let ((test-2 123)))" "(let* ((test-2 123)))")) (:language "elisp" :type "type" ; cl-lib structured type definitions :supports ("ag" "grep" "rg" "git-grep") :regex "\\((cl-defstruct|cl-deftype)\\s+JJJ\\j" :tests ("(cl-defstruct test " "(cl-defstruct test\n" "(cl-deftype test " "(cl-deftype test\n") :not ("(cl-defstruct test-asdf (blah)" "(cl-defstruct test-blah\n" "(cl-deftype test-asdf (blah)" "(cl-deftype test-blah\n")) (:language "elisp" :type "variable" ;; variable in method signature :supports ("ag" "grep" "rg" "git-grep") :regex "\\((defun|cl-defun|cl-defgeneric|cl-defmethod)\\s*.+\\(?\\s*JJJ\\j\\s*\\)?" :tests ("(defun blah (test)" "(defun blah (test blah)" "(defun (blah test)") :not ("(defun blah (test-1)" "(defun blah (test-2 blah)" "(defun (blah test-3)")) ;;-- common lisp (:language "commonlisp" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(def(un|macro|generic|method|setf)\\s+JJJ\\j" ;; \\j usage see `dumb-jump-ag-word-boundary` :tests ("(defun test (blah)" "(defun test\n" "(defmacro test (blah)" "(defmacro test\n" "(defgeneric test (blah)" "(defgeneric test\n" "(defmethod test (blah)" "(defmethod test\n" "(defsetf test (blah)" "(defsetf test\n") :not ("(defun test-asdf (blah)" "(defun test-blah\n" "(defun tester (blah)" "(defun test? (blah)" "(defun test- (blah)" "(defmacro test-asdf (blah)" "(defmacro test-blah\n" "(defmacro tester (blah)" "(defmacro test? (blah)" "(defmacro test- (blah)" "(defgeneric test-asdf (blah)" "(defgeneric test-blah\n" "(defgeneric tester (blah)" "(defgeneric test? (blah)" "(defun test- (blah)" "(defmethod test-asdf (blah)" "(defmethod test-blah\n" "(defmethod tester (blah)" "(defmethod test? (blah)" "(defun test- (blah)" "(defsetf test-asdf (blah)" "(defsetf test-blah\n" "(defsetf tester (blah)" "(defsetf test? (blah)" "(defun test- (blah)")) (:language "commonlisp" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define-(modify-macro|compiler-macro|setf-expander)\\s+JJJ\\j" ;; \\j usage see `dumb-jump-ag-word-boundary` :tests ("(define-modify-macro test (blah)" "(define-modify-macro test\n" "(define-compiler-macro test (blah)" "(define-compiler-macro test\n") :not ("(define-modify-macro test-asdf (blah)" "(define-modify-macro test-blah\n" "(define-modify-macro tester (blah)" "(define-modify-macro test? (blah)" "(define-modify-macro test- (blah)" "(define-compiler-macro test-asdf (blah)" "(define-compiler-macro test-blah\n" "(define-compiler-macro tester (blah)" "(define-compiler-macro test? (blah)" "(define-compiler-macro test- (blah)")) (:language "commonlisp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(def(var|parameter|constant)\\b\\s*JJJ\\j" :tests ("(defvar test " "(defvar test\n" "(defparameter test " "(defparameter test\n" "(defconstant test " "(defconstant test\n") :not ("(defvar tester" "(defvar test?" "(defvar test-" "(defparameter tester" "(defparameter test?" "(defparameter test-" "(defconstant tester" "(defconstant test?" "(defconstant test-")) (:language "commonlisp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define-symbol-macro\\b\\s*JJJ\\j" :tests ("(define-symbol-macro test " "(define-symbol-macro test\n") :not ("(define-symbol-macro tester" "(define-symbol-macro test?" "(define-symbol-macro test-")) (:language "commonlisp" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(def(class|struct|type)\\b\\s*JJJ\\j" :tests ("(defclass test " "(defclass test\n" "(defstruct test " "(defstruct test\n" "(deftype test " "(deftype test\n") :not ("(defclass tester" "(defclass test?" "(defclass test-" "(defstruct tester" "(defstruct test?" "(defstruct test-" "(deftype tester" "(deftype test?" "(deftype test-")) (:language "commonlisp" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define-condition\\b\\s*JJJ\\j" :tests ("(define-condition test " "(define-condition test\n") :not ("(define-condition tester" "(define-condition test?" "(define-condition test-")) ;;-- racket (:language "racket" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+\\(\\s*JJJ\\j" :tests ("(define (test blah)" "(define (test\n") :not ("(define test blah" "(define (test-asdf blah)" "(define test (lambda (blah")) (:language "racket" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+JJJ\\s*\\\(\\s*lambda" :tests ("(define test (lambda (blah" "(define test (lambda\n") :not ("(define test blah" "(define test-asdf (lambda (blah)" "(define (test)" "(define (test blah) (lambda (foo")) (:language "racket" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(let\\s+JJJ\\s*(\\\(|\\\[)*" :tests ("(let test ((blah foo) (bar bas))" "(let test\n" "(let test [(foo") :not ("(let ((test blah")) (:language "racket" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+JJJ\\j" :tests ("(define test " "(define test\n") :not ("(define (test")) (:language "racket" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(\\\(|\\\[)\\s*JJJ\\s+" :tests ("(let ((test 'foo" "(let [(test 'foo" "(let [(test 'foo" "(let [[test 'foo" "(let ((blah 'foo) (test 'bar)") :not ("{test foo")) (:language "racket" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(lambda\\s+\\\(?[^\(\)]*\\s*JJJ\\j\\s*\\\)?" :tests ("(lambda (test)" "(lambda (foo test)" "(lambda test (foo)") :not ("(lambda () test")) (:language "racket" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+\\\([^\(\)]+\\s*JJJ\\j\\s*\\\)?" :tests ("(define (foo test)" "(define (foo test bar)") :not ("(define foo test" "(define (test foo" "(define (test)")) (:language "racket" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(struct\\s+JJJ\\j" :tests ("(struct test (a b)")) ;;-- scheme (:language "scheme" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+\\(\\s*JJJ\\j" :tests ("(define (test blah)" "(define (test\n") :not ("(define test blah" "(define (test-asdf blah)" "(define test (lambda (blah")) (:language "scheme" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+JJJ\\s*\\\(\\s*lambda" :tests ("(define test (lambda (blah" "(define test (lambda\n") :not ("(define test blah" "(define test-asdf (lambda (blah)" "(define (test)" "(define (test blah) (lambda (foo")) (:language "scheme" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(let\\s+JJJ\\s*(\\\(|\\\[)*" :tests ("(let test ((blah foo) (bar bas))" "(let test\n" "(let test [(foo") :not ("(let ((test blah")) (:language "scheme" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+JJJ\\j" :tests ("(define test " "(define test\n") :not ("(define (test")) (:language "scheme" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(\\\(|\\\[)\\s*JJJ\\s+" :tests ("(let ((test 'foo" "(let [(test 'foo" "(let [(test 'foo" "(let [[test 'foo" "(let ((blah 'foo) (test 'bar)") :not ("{test foo")) (:language "scheme" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(lambda\\s+\\\(?[^\(\)]*\\s*JJJ\\j\\s*\\\)?" :tests ("(lambda (test)" "(lambda (foo test)" "(lambda test (foo)") :not ("(lambda () test")) (:language "scheme" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\(define\\s+\\\([^\(\)]+\\s*JJJ\\j\\s*\\\)?" :tests ("(define (foo test)" "(define (foo test bar)") :not ("(define foo test" "(define (test foo" "(define (test)")) ;;-- janet (:language "janet" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(\(de\)?f\\s+JJJ\\j" :tests ("(def test (foo)")) (:language "janet" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(var\\s+JJJ\\j" :tests ("(var test (foo)")) (:language "janet" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(\(de\)fn-?\\s+JJJ\\j" :tests ("(defn test [foo]" "(defn- test [foo]") :not ("(defn test? [foo]" "(defn- test? [foo]")) (:language "janet" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(defmacro\\s+JJJ\\j" :tests ("(defmacro test [foo]")) ;;-- c++ (:language "c++" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\bJJJ(\\s|\\))*\\((\\w|[,&*.<>:]|\\s)*(\\))\\s*(const|->|\\{|$)|typedef\\s+(\\w|[(*]|\\s)+JJJ(\\)|\\s)*\\(" :tests ("int test(){" "my_struct (*test)(int a, int b){" "auto MyClass::test ( Builder::Builder& reference, ) -> decltype( builder.func() ) {" "int test( int *random_argument) const {" "test::test() {" "typedef int (*test)(int);") :not ("return test();)" "int test(a, b);" "if( test() ) {" "else test();")) ;; (:language "c++" :type "variable" ;; :supports ("grep") ;; :regex "(\\b\\w+|[,>])([*&]|\\s)+JJJ\\s*(\\[([0-9]|\\s)*\\])*\\s*([=,){;]|:\\s*[0-9])|#define\\s+JJJ\\b" ;; :tests ("int test=2;" "char *test;" "int x = 1, test = 2" "int test[20];" "#define test" "unsigned int test:2;")) (:language "c++" :type "variable" :supports ("ag" "rg") :regex "\\b(?!(class\\b|struct\\b|return\\b|else\\b|delete\\b))(\\w+|[,>])([*&]|\\s)+JJJ\\s*(\\[(\\d|\\s)*\\])*\\s*([=,(){;]|:\\s*\\d)|#define\\s+JJJ\\b" :tests ("int test=2;" "char *test;" "int x = 1, test = 2" "int test[20];" "#define test" "typedef int test;" "unsigned int test:2") :not ("return test;" "#define NOT test" "else test=2;")) (:language "c++" :type "type" :supports ("ag" "rg" "git-grep") :regex "\\b(class|struct|enum|union)\\b\\s*JJJ\\b\\s*(final\\s*)?(:((\\s*\\w+\\s*::)*\\s*\\w*\\s*?\\s*,*)+)?((\\{|$))|}\\s*JJJ\\b\\s*;" :tests ("typedef struct test {" "enum test {" "} test;" "union test {" "class test final: public Parent1, private Parent2{" "class test : public std::vector {") :not("union test var;" "struct test function() {")) ;;-- clojure (:language "clojure" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(def.*\ JJJ\\j" :tests ("(def test (foo)" "(defn test [foo]" "(defn ^:some-data test [foo]" "(defn- test [foo]" "(defmacro test [foo]" "(deftask test [foo]" "(deftype test [foo]" "(defmulti test fn" "(defmethod test type" "(definterface test (foo)" "(defprotocol test (foo)" "(defrecord test [foo]" "(deftest test")) ;;-- coffeescript (:language "coffeescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*JJJ\\s*[=:].*[-=]>" :tests ("test = () =>" "test= =>" "test = ->" "test=()->" "test : () =>" "test: =>" "test : ->" "test:()->") :not ("# test = =>" "test = 1")) (:language "coffeescript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*JJJ\\s*[:=][^:=-][^>]+$" :tests ("test = $" "test : [" "test = {" "test = a") :not ("test::a" "test: =>" "test == 1" "# test = 1")) (:language "coffeescript" :type "class" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*\\bclass\\s+JJJ" :tests ("class test" "class test extends") :not ("# class")) ;;-- objc : Objective-C (:language "objc" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\)\\s*JJJ(:|\\b|\\s)" :tests ("- (void)test" "- (void)test:(UIAlertView *)alertView") :not ("- (void)testnot" "- (void)testnot:(UIAlertView *)alertView")) (:language "objc" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\b\\*?JJJ\\s*=[^=\\n]+" :tests ("NSString *test = @\"asdf\"") :not ("NSString *testnot = @\"asdf\"" "NSString *nottest = @\"asdf\"")) (:language "objc" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(@interface|@protocol|@implementation)\\b\\s*JJJ\\b\\s*" :tests ("@interface test: UIWindow") :not ("@interface testnon: UIWindow")) (:language "objc" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "typedef\\b\\s+(NS_OPTIONS|NS_ENUM)\\b\\([^,]+?,\\s*JJJ\\b\\s*" :tests ("typedef NS_ENUM(NSUInteger, test)") :not ("typedef NS_ENUMD(NSUInteger, test)")) ;;-- swift (:language "swift" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(let|var)\\s*JJJ\\s*(=|:)[^=:\\n]+" :tests ("let test = 1234" "var test = 1234" "private lazy var test: UITapGestureRecognizer") :not ("if test == 1234:")) (:language "swift" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "func\\s+JJJ\\b\\s*(<[^>]*>)?\\s*\\(" :tests ("func test(asdf)" "func test()" "func test()") :not ("func testnot(asdf)" "func testnot()")) (:language "swift" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|struct|protocol|enum)\\s+JJJ\\b\\s*?" :tests ("struct test" "struct test: Codable" "struct test" "class test:" "class test: UIWindow" "class test") :not ("class testnot:" "class testnot(object):" "struct testnot(object)")) (:language "swift" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(typealias)\\s+JJJ\\b\\s*?=" :tests ("typealias test =") :not ("typealias testnot")) ;;-- csharp : C# (:language "csharp" :type "function" :supports ("ag" "rg") :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\(" :tests ("int test()" "int test(param)" "static int test()" "static int test(param)" "public static MyType test()" "private virtual SomeType test(param)" "static int test()") :not ("test()" "testnot()" "blah = new test()")) (:language "csharp" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44")) (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "csharp" :regex "(class|interface)\\s*JJJ\\b" :tests ("class test:" "public class test : IReadableChannel, I") :not ("class testnot:" "public class testnot : IReadableChannel, I")) ;;-- java (literally the same regexes as c#, but different tests) (:language "java" :type "function" :supports ("ag" "rg") :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\(" :tests ("int test()" "int test(param)" "static int test()" "static int test(param)" "public static MyType test()" "private virtual SomeType test(param)" "static int test()" "private foo[] test()") :not ("test()" "testnot()" "blah = new test()" "foo bar = test()")) (:language "java" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44")) (:language "java" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|interface)\\s*JJJ\\b" :tests ("class test:" "public class test implements Something") :not ("class testnot:" "public class testnot implements Something")) ;;-- vala (again just like c#, exactly the same..) (:language "vala" :type "function" :supports ("ag" "rg") :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\(" :tests ("int test()" "int test(param)" "static int test()" "static int test(param)" "public static MyType test()" "private virtual SomeType test(param)" "static int test()") :not ("test()" "testnot()" "blah = new test()")) (:language "vala" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44")) (:language "vala" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|interface)\\s*JJJ\\b" :tests ("class test:" "public class test : IReadableChannel, I") :not ("class testnot:" "public class testnot : IReadableChannel, I")) ;;-- coq (renamed Rocq in March 2025) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Variable\\s+JJJ\\b" :tests ("Variable test") :not ("Variable testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Inductive\\s+JJJ\\b" :tests ("Inductive test") :not ("Inductive testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Lemma\\s+JJJ\\b" :tests ("Lemma test") :not ("Lemma testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Definition\\s+JJJ\\b" :tests ("Definition test") :not ("Definition testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Hypothesis\\s+JJJ\\b" :tests ("Hypothesis test") :not ("Hypothesis testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Theorm\\s+JJJ\\b" :tests ("Theorm test") :not ("Theorm testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Fixpoint\\s+JJJ\\b" :tests ("Fixpoint test") :not ("Fixpoint testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*Module\\s+JJJ\\b" :tests ("Module test") :not ("Module testx")) (:language "coq" :type "function" :supports ("ag" "rg" "git-grep") :regex "\\s*CoInductive\\s+JJJ\\b" :tests ("CoInductive test") :not ("CoInductive testx")) ;;-- python (:language "python" :type "variable" :supports ("ag" "rg") :regex "\\s*\\bJJJ\\b(\\s*:[^=\\n]+)?\\s*=[^=\\n]+" :tests ("test = 1234" "test: int = 1234" "test: int | None = 1234" "test: List[Optional[int]] = [1234, None]") :not ("if test == 1234:" "_test = 1234" "if (test := 3):" "while test:" "test['key'] = 1234")) (:language "python" :type "variable" :supports ("grep" "git-grep") :regex "\\s*\\bJJJ\\b(\\s*:[^=]+)?\\s*=[^=]+" :tests ("test = 1234" "test: int = 1234" "test: int | None = 12i34" "test: List[Optional[int]] = [1234, None]") :not ("if test == 1234:" "_test = 1234" "if (test := 3):" "while test:" "test['key'] = 1234")) (:language "python" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "def\\s*JJJ\\b\\s*\\\(" :tests ("\tdef test(asdf)" "def test()") :not ("\tdef testnot(asdf)" "def testnot()")) (:language "python" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\b\\s*\\\(?" :tests ("class test(object):" "class test:") :not ("class testnot:" "class testnot(object):")) ;;-- matlab (:language "matlab" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("for test = 1:2:" "_test = 1234")) (:language "matlab" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*function\\s*[^=]+\\s*=\\s*JJJ\\b" :tests ("\tfunction y = test(asdf)" "function x = test()" "function [x, losses] = test(A, y, lambda, method, qtile)") :not ("\tfunction testnot(asdf)" "function testnot()")) (:language "matlab" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*classdef\\s*JJJ\\b\\s*" :tests ("classdef test") :not ("classdef testnot")) ;;-- nim (:language "nim" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(const|let|var)\\s*JJJ\\*?\\s*(=|:)[^=:\\n]+" :tests ("let test = 1234" "var test = 1234" "var test: Stat" "const test = 1234" "const test* = 1234") :not ("if test == 1234:")) (:language "nim" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(proc|func|macro|template)\\s*`?JJJ`?\\b\\*?\\s*\\\(" :tests ("\tproc test(asdf)" "proc test()" "func test()" "macro test()" "template test()" "proc test*()") :not ("\tproc testnot(asdf)" "proc testnot()")) (:language "nim" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "type\\s*JJJ\\b\\*?\\s*(\\{[^}]+\\})?\\s*=\\s*\\w+" :tests ("type test = object" "type test {.pure.} = enum" "type test* = ref object") :not ("type testnot = object")) ;;-- nix (:language "nix" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\b\\s*JJJ\\s*=[^=;]+" :tests ("test = 1234;" "test = 123;" "test=123") :not ("testNot = 1234;" "Nottest = 1234;" "AtestNot = 1234;")) ;;-- org ;; org named blocks (:language "org" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*#\\+[nN][aA][mM][eE]:\\s*JJJ\\j" :tests ("#+name: test" "#+NAME: test" "#+Name: test" " #+name: test" "#+name:test") :not ("#+name: tester" "#+name: test-block" "some #+name: test")) ;; org call references (#+call: block-name) (:language "org" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*#\\+[cC][aA][lL][lL]:\\s*JJJ\\j" :tests ("#+call: test" "#+CALL: test" "#+Call: test" " #+call: test" "#+call: test()" "#+call: test(x=1)") :not ("#+call: tester" "#+call: test-other" "some #+call: test")) ;; org headings (* Heading text) (:language "org" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\*+\\s+JJJ\\j" :tests ("* test" "** test" "*** test" "**** test" "* test heading" "** test with more words") :not ("* tester" "** testing" "* test-other" "not a * test heading")) ;; org custom ID (:CUSTOM_ID: value in property drawers) (:language "org" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*:CUSTOM_ID:\\s*JJJ\\j" :tests (":CUSTOM_ID: test" ":CUSTOM_ID: test" " :CUSTOM_ID: test" ":CUSTOM_ID:test") :not (":CUSTOM_ID: tester" ":CUSTOM_ID: test-other" "inline :CUSTOM_ID: test text")) ;;-- ruby (:language "ruby" :type "variable" :supports ("ag" "rg" "git-grep") :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)" :tests ("test = 1234" "self.foo, test, bar = args") :not ("if test == 1234" "foo_test = 1234")) (:language "ruby" :type "function" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])((private|public|protected)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])" :tests ("def test(foo)" "def test()" "def test foo" "def test; end" "def self.test()" "def MODULE::test()" "private def test") :not ("def test_foo")) (:language "ruby" :type "function" :supports ("ag" "rg" "git-grep") :regex "(^|\\W)define(_singleton|_instance)?_method(\\s|[(])\\s*:JJJ($|[^\\w|:])" :tests ("define_method(:test, &body)" "mod.define_instance_method(:test) { body }")) (:language "ruby" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("class test" "class Foo::test")) (:language "ruby" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])module\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("module test" "module Foo::test")) (:language "ruby" :type "function" :supports ("ag" "rg" "git-grep") :regex "(^|\\W)alias(_method)?\\W+JJJ(\\W|$)" :tests ("alias test some_method" "alias_method :test, :some_method" "alias_method 'test' 'some_method'" "some_class.send(:alias_method, :test, :some_method)") :not ("alias some_method test" "alias_method :some_method, :test" "alias test_foo test")) ;;-- Groovy (:language "groovy" :type "variable" :supports ("ag" "rg" "git-grep") :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)" :tests ("test = 1234" "self.foo, test, bar = args") :not ("if test == 1234" "foo_test = 1234")) (:language "groovy" :type "function" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])((private|public)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])" :tests ("def test(foo)" "def test()" "def test foo" "def test; end" "def self.test()" "def MODULE::test()" "private def test") :not ("def test_foo")) (:language "groovy" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("class test" "class Foo::test")) ;;-- crystal (:language "crystal" :type "variable" :supports ("ag" "rg" "git-grep") :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)" :tests ("test = 1234" "self.foo, test, bar = args") :not ("if test == 1234" "foo_test = 1234")) (:language "crystal" :type "function" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])((private|public|protected)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])" :tests ("def test(foo)" "def test()" "def test foo" "def test; end" "def self.test()" "def MODULE::test()" "private def test") :not ("def test_foo")) (:language "crystal" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("class test" "class Foo::test")) (:language "crystal" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])module\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("module test" "module Foo::test")) (:language "crystal" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])struct\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("struct test" "struct Foo::test")) (:language "crystal" :type "type" :supports ("ag" "rg" "git-grep") :regex "(^|[^\\w.])alias\\s+(\\w*::)*JJJ($|[^\\w|:])" :tests ("alias test" "alias Foo::test")) ;;-- scad (:language "scad" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test == 1234 {")) (:language "scad" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test()" "function test ()")) (:language "scad" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "module\\s*JJJ\\s*\\\(" :tests ("module test()" "module test ()")) ;;-- scala (:language "scala" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bval\\s*JJJ\\s*=[^=\\n]+" :tests ("val test = 1234") :not ("case test => 1234")) (:language "scala" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bvar\\s*JJJ\\s*=[^=\\n]+" :tests ("var test = 1234") :not ("case test => 1234")) (:language "scala" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\btype\\s*JJJ\\s*=[^=\\n]+" :tests ("type test = 1234") :not ("case test => 1234")) (:language "scala" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bdef\\s*JJJ\\s*\\\(" :tests ("def test(asdf)" "def test()")) (:language "scala" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\s*\\\(?" :tests ("class test(object)")) (:language "scala" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "trait\\s*JJJ\\s*\\\(?" :tests ("trait test(object)")) (:language "scala" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "object\\s*JJJ\\s*\\\(?" :tests ("object test(object)")) ;;-- solidity (:language "solidity" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test() internal" "function test (uint x, address y)" "function test() external")) (:language "solidity" :type "modifier" :supports ("ag" "grep" "rg" "git-grep") :regex "modifier\\s*JJJ\\s*\\\(" :tests ("modifier test()" "modifier test ()")) (:language "solidity" :type "event" :supports ("ag" "grep" "rg" "git-grep") :regex "event\\s*JJJ\\s*\\\(" :tests ("event test();" "event test (uint indexed x)" "event test(uint x, address y)")) (:language "solidity" :type "error" :supports ("ag" "grep" "rg" "git-grep") :regex "error\\s*JJJ\\s*\\\(" :tests ("error test();" "error test (uint x)" "error test(uint x, address y)")) (:language "solidity" :type "contract" :supports ("ag" "grep" "rg" "git-grep") :regex "contract\\s*JJJ\\s*(is|\\\{)" :tests ("contract test{" "contract test {" "contract test is foo")) (:language "solidity" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "struct\\s*JJJ\\s*\\\{" :tests ("struct test{" "struct test {")) ;;-- R (:language "r" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*=[^=><]" :tests ("test = 1234") :not ("if (test == 1234)")) (:language "r" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*<-\\s*function\\b" :tests ("test <- function" "test <- function(") :not ("test <- functionX")) ;;-- perl (:language "perl" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "sub\\s*JJJ\\s*(\\{|\\()" :tests ("sub test{" "sub test {" "sub test(" "sub test (")) (:language "perl" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "JJJ\\s*=\\s*" :tests ("$test = 1234")) ;;-- Tcl (:language "tcl" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "proc\\s+JJJ\\s*\\{" :tests ("proc test{" "proc test {")) (:language "tcl" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "set\\s+JJJ" :tests ("set test 1234")) (:language "tcl" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(variable|global)\\s+JJJ" :tests ("variable test" "global test")) ;;-- shell (:language "shell" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*" :tests ("function test{" "function test {" "function test () {") :not ("function nottest {")) (:language "shell" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "JJJ\\\(\\\)\\s*\\{" :tests ("test() {") :not ("testx() {")) (:language "shell" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*=\\s*" :tests ("test = 1234") :not ("blahtest = 1234")) ;;-- php (:language "php" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test()" "function test ()")) (:language "php" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\*\\s@method\\s+[^ \t]+\\s+JJJ\\(" :tests ("/** @method string|false test($a)" " * @method bool test()")) (:language "php" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(\\s|->|\\$|::)JJJ\\s*=\\s*" :tests ("$test = 1234" "$foo->test = 1234")) (:language "php" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\*\\s@property(-read|-write)?\\s+([^ \t]+\\s+)&?\\$JJJ(\\s+|$)" :tests ("/** @property string $test" "/** @property string $test description for $test property" " * @property-read bool|bool $test" " * @property-write \\ArrayObject $test")) (:language "php" :type "trait" :supports ("ag" "grep" "rg" "git-grep") :regex "trait\\s*JJJ\\s*\\\{" :tests ("trait test{" "trait test {")) (:language "php" :type "interface" :supports ("ag" "grep" "rg" "git-grep") :regex "interface\\s*JJJ\\s*(extends|\\\{)" :tests ("interface test{" "interface test {") "interface test extends test2") (:language "php" :type "class" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\s*(extends|implements|\\\{)" :tests ("class test{" "class test {" "class test extends foo" "class test implements foo")) ;; PHP 8.1+ enum definition (:language "php" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\benum\\s+JJJ\\b\\s*(:\\s*(int|string))?\\s*(implements[^{]+)?\\{" :tests ("enum test {" "enum test: int {" "enum test: string {" "enum test implements Stringable {" "enum test: int implements JsonSerializable {") :not ("// enum test" "$enum = 'test'")) ;; PHP 8.1+ enum case (:language "php" :type "constant" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*case\\s+JJJ\\s*(;|=)" :tests (" case test;" "case test = 1;" "case test = 'value';") :not ("case 'test':" "case \"test\":" "default:")) ;; PHP abstract class (:language "php" :type "class" :supports ("ag" "grep" "rg" "git-grep") :regex "\\babstract\\s+class\\s+JJJ\\s*(extends|implements|\\\{)" :tests ("abstract class test {" "abstract class test extends Base {" "abstract class test implements Foo {") :not ("// abstract class test")) ;; PHP final class (including final readonly) (:language "php" :type "class" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfinal\\s+(readonly\\s+)?class\\s+JJJ\\s*(extends|implements|\\\{)" :tests ("final class test {" "final readonly class test {" "final class test extends Base {") :not ("// final class test")) ;; PHP readonly class (including readonly final) (:language "php" :type "class" :supports ("ag" "grep" "rg" "git-grep") :regex "\\breadonly\\s+(final\\s+)?class\\s+JJJ\\s*(extends|implements|\\\{)" :tests ("readonly class test {" "readonly final class test {" "readonly class test implements Serializable {") :not ("// readonly class test")) ;; PHP class constant with optional visibility/final (:language "php" :type "constant" :supports ("ag" "grep" "rg" "git-grep") :regex "(final\\s+)?(public|protected|private)?\\s*const\\s+JJJ\\s*=" :tests ("const test = 'value';" "public const test = 100;" "private const test = 'secret';" "protected const test = [];" "final public const test = 42;" "final const test = true;") :not ("$const = 'test'" "// const test")) ;; PHP global const (outside class) (:language "php" :type "constant" :supports ("ag" "grep" "rg" "git-grep") :regex "^const\\s+JJJ\\s*=" :tests ("const test = 'app_name';" "const test = 42;" "const test = [];") :not (" const test =" "public const test =")) ;; PHP define() function (:language "php" :type "constant" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*define\\s*\\(\\s*['\"]JJJ['\"]" :tests ("define('test', 100);" "define(\"test\", 'value');" "define('test',") :not ("// define('test'" "$define = 'test'")) ;; PHP typed property declaration (:language "php" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(public|protected|private)\\s+(static\\s+)?(readonly\\s+)?\\??[A-Za-z_][A-Za-z0-9_\\\\|&]*\\s+\\$JJJ\\s*(;|=|,)" :tests ("public int $test;" "private string $test = '';" "protected ?array $test = null;" "public readonly string $test;" "private static int $test = 0;" "public DateTime $test;") :not ("public function foo(int $test)" "return $test;")) ;; PHP static property (without explicit type) (:language "php" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(public|protected|private)?\\s*static\\s+\\$JJJ\\s*(;|=)" :tests ("static $test;" "public static $test = [];" "private static $test = null;") :not ("static function test()" "static::$test")) ;; PHP namespace declaration (:language "php" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bnamespace\\s+([A-Za-z_][A-Za-z0-9_]*\\\\)*JJJ\\s*[;{]" :tests ("namespace test;" "namespace App\\test;" "namespace App\\Services\\test {") :not ("// namespace test" "use App\\test;")) ;; PHP use statement for class imports (:language "php" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\buse\\s+([A-Za-z_][A-Za-z0-9_]*\\\\)*JJJ\\s*(;|,|\\s+as\\s+)" :tests ("use test;" "use App\\test;" "use App\\Models\\test as TestModel;" "use App\\test, App\\Other;") :not ("use function test;" "use const test;")) ;;-- dart (:language "dart" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]" :tests ("test(foo) {" "test (foo){" "test(foo){")) (:language "dart" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\s*[\\\(\\\{]" :tests ("class test(object) {" "class test{")) ;;-- dlang (:language "dlang" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^[[:space:]]*([][[:alnum:]_!.*<>]+[[:space:]]+)+JJJ[[:space:]]*\\\([^;{}]*\\\)([[:space:]]+@?[[:alnum:]_]+)*[[:space:]]*[{]" :tests ("void test() {" "public static int test(int value) {" "auto test(T)(T value) {" "void test() pure {" "void test() @safe {") :not ("return test();" "auto value = test(arg);" "test();")) (:language "dlang" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234;" "immutable test = 1;" "auto test = foo();") :not ("if (test == 1234)" "int nottest = 44;")) (:language "dlang" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|interface|struct|union|enum|alias)\\s+JJJ\\b" :tests ("class test {" "struct test {" "alias test = int;") :not ("class testnot {" "alias nottest = test;")) ;;-- faust (:language "faust" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\(\\\(.+\\\)\)*\\s*=" :tests ("test = osc + 0.5;" "test(freq) = osc(freq) + 0.5;")) ;;-- fennel (:language "fennel" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\((local|var)\\s+JJJ\\j" :tests ("(local test (foo)" "(var test (foo)")) (:language "fennel" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(fn\\s+JJJ\\j" :tests ("(fn test [foo]") :not ("(fn test? [foo]")) (:language "fennel" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\(macro\\s+JJJ\\j" :tests ("(macro test [foo]")) ;;-- fortran (:language "fortran" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if (test == 1234)")) (:language "fortran" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\b(function|subroutine|FUNCTION|SUBROUTINE)\\s+JJJ\\b\\s*\\\(" :tests ("function test (foo)" "integer function test(foo)" "subroutine test (foo, bar)" "FUNCTION test (foo)" "INTEGER FUNCTION test(foo)" "SUBROUTINE test (foo, bar)") :not ("end function test" "end subroutine test" "END FUNCTION test" "END SUBROUTINE test")) (:language "fortran" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*(interface|INTERFACE)\\s+JJJ\\b" :tests ("interface test" "INTERFACE test") :not ("interface test2" "end interface test" "INTERFACE test2" "END INTERFACE test")) (:language "fortran" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*(module|MODULE)\\s+JJJ\\s*" :tests ("module test" "MODULE test") :not ("end module test" "END MODULE test")) ;;-- go (:language "go" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test == 1234 {")) (:language "go" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*:=\\s*" :tests ("test := 1234")) (:language "go" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "func\\s+\\\([^\\\)]*\\\)\\s+JJJ\\s*\\\(" :tests ("func (s *blah) test(filename string) string {")) (:language "go" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "func\\s+JJJ\\s*\\\(" :tests ("func test(url string) (string, error)")) (:language "go" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "type\\s+JJJ\\s+struct\\s+\\\{" :tests ("type test struct {")) ;;-- javascript extended (:language "javascript" :tags ("angular") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(service|factory)\\\(['\"]JJJ['\"]" :tests ("module.factory('test', [\"$rootScope\", function($rootScope) {")) (:language "javascript" :tags ("es6") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*[=:]\\s*\\\([^\\\)]*\\\)\\s+=>" :tests ("const test = (foo) => " "test: (foo) => {" " test: (foo) => {")) (:language "javascript" :tags ("es6") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]" :tests ("test(foo) {" "test (foo){" "test(foo){") :not ("test = blah.then(function(){")) (:language "javascript" :tags ("es6") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\s*[\\\(\\\{]" :tests ("class test(object) {" "class test{")) (:language "javascript" :tags ("es6") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ\\s+extends" :tests ("class test extends Component{")) ;;-- javascript (:language "javascript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234" "const test = props =>") :not ("if (test === 1234)")) (:language "javascript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfunction\\b[^\\(]*\\\(\\s*[^\\)]*\\bJJJ\\b\\s*,?\\s*\\\)?" :tests ("function (test)" "function (test, blah)" "function somefunc(test, blah) {" "function(blah, test)") :not ("function (testLen)" "function (test1, blah)" "function somefunc(testFirst, blah) {" "function(blah, testLast)" "function (Lentest)" "function (blahtest, blah)" "function somefunc(Firsttest, blah) {" "function(blah, Lasttest)")) (:language "javascript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test()" "function test ()")) (:language "javascript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*:\\s*function\\s*\\\(" :tests ("test: function()")) (:language "javascript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*=\\s*function\\s*\\\(" :tests ("test = function()")) ;;-- hcl terraform (:language "hcl" :type "block" :supports ("ag" "grep" "rg" "git-grep") :regex "(variable|output|module)\\s*\"JJJ\"\\s*\\\{" :tests ("variable \"test\" {" "output \"test\" {" "module \"test\" {")) (:language "hcl" :type "block" :supports ("ag" "grep" "rg" "git-grep") :regex "(data|resource)\\s*\"\\w+\"\\s*\"JJJ\"\\s*\\\{" :tests ("data \"openstack_images_image_v2\" \"test\" {" "resource \"google_compute_instance\" \"test\" {")) ;;-- typescript (:language "typescript" :tags ("angular") :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(service|factory)\\\(['\"]JJJ['\"]" :tests ("module.factory('test', [\"$rootScope\", function($rootScope) {")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*[=:]\\s*\\\([^\\\)]*\\\)\\s+=>" :tests ("const test = (foo) => " "test: (foo) => {" " test: (foo) => {")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]" :tests ("test(foo) {" "test (foo){" "test(foo){") :not ("test = blah.then(function(){")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ(\\s*<[^>]*>)?\\s*[\\\(\\\{]" :tests ("class test{" "class test{")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ(\\s*<[^>]*>)?\\s+extends" :tests ("class test extends Component{" "class test extends Component{")) (:language "typescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ(\\s*<[^>]*>)?\\s*[\\\(\\\{]" :tests ("class test{" "class test{")) (:language "typescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "class\\s*JJJ(\\s*<[^>]*>)?\\s+extends" :tests ("class test extends Component{" "class test extends Component{")) (:language "typescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(export\\s+)?interface\\s+JJJ\\b" :tests ("interface test{" "interface test extends Thing{" "export interface test{") :not ("interface testnot{")) (:language "typescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(export\\s+)?type\\s+JJJ\\b" :tests ("type test = number" "type test = T" "export type test = number") :not ("type testnot = number")) (:language "typescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(export\\s+)?enum\\s+JJJ\\b" :tests ("enum test{" "export enum test{") :not ("enum testnot{")) (:language "typescript" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "(declare\\s+)?namespace\\s+JJJ\\b" :tests ("declare namespace test" "namespace test") :not ("declare testnot")) (:language "typescript" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "(export\\s+)?module\\s+JJJ\\b" :tests ("export module test" "module test") :not ("module testnot")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test()" "function test ()")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*:\\s*function\\s*\\\(" :tests ("test: function()")) (:language "typescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*=\\s*function\\s*\\\(" :tests ("test = function()")) (:language "typescript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234" "const test = props =>") :not ("if (test === 1234)")) (:language "typescript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfunction\\b[^\\(]*\\\(\\s*[^\\)]*\\bJJJ\\b\\s*,?\\s*\\\)?" :tests ("function (test)" "function (test, blah)" "function somefunc(test, blah) {" "function(blah, test)") :not ("function (testLen)" "function (test1, blah)" "function somefunc(testFirst, blah) {" "function(blah, testLast)" "function (Lentest)" "function (blahtest, blah)" "function somefunc(Firsttest, blah) {" "function(blah, Lasttest)")) ;;-- julia (:language "julia" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(@noinline|@inline)?\\s*function\\s*JJJ(\\{[^\\}]*\\})?\\(" :tests ("function test()" "@inline function test()" "function test{T}(h)")) (:language "julia" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(@noinline|@inline)?JJJ(\\{[^\\}]*\\})?\\([^\\)]*\\)\s*=" :tests ("test(a)=1" "test(a,b)=1*8" "@noinline test()=1" "test{T}(x)=x")) (:language "julia" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "macro\\s*JJJ\\(" :tests ("macro test(a)=1" " macro test(a,b)=1*8")) (:language "julia" :type "variable" :supports ("ag" "rg") :regex "const\\s+JJJ\\b" :tests ("const test = ")) (:language "julia" :type "type" :supports ("ag" "rg") :regex "(mutable)?\\s*struct\\s*JJJ" :tests ("struct test")) (:language "julia" :type "type" :supports ("ag" "rg") :regex "(type|immutable|abstract)\\s*JJJ" :tests ("type test" "immutable test" "abstract test <:Testable" )) ;;-- haskell (:language "haskell" :type "module" :supports ("ag") :regex "^module\\s+JJJ\\s+" :tests ("module Test (exportA, exportB) where")) ; TODO Doesn't support any '=' in arguments. E.g. 'foo A{a = b,..} = bar'. (:language "haskell" :type "top level function" :supports ("ag") :regex "^\\bJJJ(?!(\\s+::))\\s+((.|\\s)*?)=\\s+" :tests ("test n = n * 2" "test X{..} (Y a b c) \n bcd \n =\n x * y" "test ab cd e@Datatype {..} (Another thing, inTheRow) = \n undefined" "test = runRealBasedMode @ext @ctx identity identity" "test unwrap wrap nr@Naoeu {..} (Action action, specSpecs) = \n undefined") :not ("nottest n = n * 2" "let testnot x y = x * y" "test $ y z" "let test a o = mda" "test :: Sometype -> AnotherType aoeu kek = undefined")) (:language "haskell" :type "type-like" :supports ("ag") :regex "^\\s*((data(\\s+family)?)|(newtype)|(type(\\s+family)?))\\s+JJJ\\s+" :tests ("newtype Test a = Something { b :: Kek }" "data Test a b = Somecase a | Othercase b" "type family Test (x :: *) (xs :: [*]) :: Nat where" "data family Test " "type Test = TestAlias") :not ("newtype NotTest a = NotTest (Not a)" "data TestNot b = Aoeu")) ; datatype contstuctor that doesn't match type definition. (:language "haskell" :type "(data)type constructor 1" :supports ("ag") :regex "(data|newtype)\\s{1,3}(?!JJJ\\s+)([^=]{1,40})=((\\s{0,3}JJJ\\s+)|([^=]{0,500}?((?\\s*)?JJJ\\s+" :tests ( "class (Constr1 m, Constr 2) => Test (Kek a) where" "class Test (Veryovka a) where ") :not ("class Test2 (Kek a) where" "class MakeTest (AoeuTest x y z) where")) ;;-- ocaml (:language "ocaml" :type "type" :supports ("ag" "rg") :regex "^\\s*(and|type)\\s+.*\\bJJJ\\b" :tests ("type test =" "and test =" "type 'a test =" "type ('a, _, 'c) test")) (:language "ocaml" :type "variable" :supports ("ag" "rg") :regex "let\\s+JJJ\\b" :tests ("let test =" "let test x y =")) (:language "ocaml" :type "variable" :supports ("ag" "rg") :regex "let\\s+rec\\s+JJJ\\b" :tests ("let rec test =" "let rec test x y =")) (:language "ocaml" :type "variable" :supports ("ag" "rg") :regex "\\s*val\\s*\\bJJJ\\b\\s*" :tests ("val test")) (:language "ocaml" :type "module" :supports ("ag" "rg") :regex "^\\s*module\\s*\\bJJJ\\b" :tests ("module test =")) (:language "ocaml" :type "module" :supports ("ag" "rg") :regex "^\\s*module\\s*type\\s*\\bJJJ\\b" :tests ("module type test =")) ;;-- purescript (:language "purescript" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*\\bJJJ\\b\\s+(::|[^=]*\\s=[^=])" :tests ("test :: Int -> String" "test :: Number -> Number -> Number" " test :: Int -> String" "test x y = x + y" "test (Just x) = x" "test { x } = x") :not ("nottest :: Int -> String" "testing x = 1" "test x == y" "test >>= bar")) (:language "purescript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*\\bJJJ\\s*=[^=]" :tests ("test = 42" "test = \\x -> x + 1" " test = compute x") :not ("test == 42" "-- test = 42")) (:language "purescript" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\blet\\s+JJJ\\s*(\\::|=[^=])" :tests ("let test = 42" "let test :: Int") :not ("let testing = 42" "let test == 42")) (:language "purescript" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "^\\s*(type|newtype|data)\\s+JJJ\\b" :tests ("type test = Int" "newtype test = test Int" "data test = test Int | Other String") :not ("type testOther = Int" "data testOther = testOther Int")) ;; lua (:language "lua" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test === 1234")) (:language "lua" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfunction\\b[^\\(]*\\\(\\s*[^\\)]*\\bJJJ\\b\\s*,?\\s*\\\)?" :tests ("function (test)" "function (test, blah)" "function somefunc(test, blah)" "function(blah, test)") :not ("function (testLen)" "function (test1, blah)" "function somefunc(testFirst, blah)" "function(blah, testLast)" "function (Lentest)" "function (blahtest, blah)" "function somefunc(Firsttest, blah)" "function(blah, Lasttest)")) (:language "lua" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*JJJ\\s*\\\(" :tests ("function test()" "function test ()")) (:language "lua" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*.+[.:]JJJ\\s*\\\(" :tests ("function MyClass.test()" "function MyClass.test ()" "function MyClass:test()" "function MyClass:test ()")) (:language "lua" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*=\\s*function\\s*\\\(" :tests ("test = function()")) (:language "lua" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\b.+\\.JJJ\\s*=\\s*function\\s*\\\(" :tests ("MyClass.test = function()")) ;;-- rust (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\blet\\s+(\\\([^=\\n]*)?(mut\s+)?JJJ([^=\\n]*\\\))?(:\\s*[^=\\n]+)?\\s*=\\s*[^=\\n]+" :tests ("let test = 1234;" "let test: u32 = 1234;" "let test: Vec = Vec::new();" "let mut test = 1234;" "let mut test: Vec = Vec::new();" "let (a, test, b) = (1, 2, 3);" "let (a, mut test, mut b) = (1, 2, 3);" "let (mut a, mut test): (u32, usize) = (1, 2);")) (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bconst\\s+JJJ:\\s*[^=\\n]+\\s*=[^=\\n]+" :tests ("const test: u32 = 1234;")) (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bstatic\\s+(mut\\s+)?JJJ:\\s*[^=\\n]+\\s*=[^=\\n]+" :tests ("static test: u32 = 1234;" "static mut test: u32 = 1234;")) ;; variable in method signature (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfn\\s+.+\\s*\\\((.+,\\s+)?JJJ:\\s*[^=\\n]+\\s*(,\\s*.+)*\\\)" :tests ("fn abc(test: u32) -> u32 {" "fn abc(x: u32, y: u32, test: Vec, z: Vec)" "fn abc(x: u32, y: u32, test: &mut Vec, z: Vec)")) ;; "if let" and "while let" desugaring (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(if|while)\\s+let\\s+([^=\\n]+)?(mut\\s+)?JJJ([^=\\n\\\(]+)?\\s*=\\s*[^=\\n]+" :tests ("if let Some(test) = abc() {" "if let Some(mut test) = abc() {" "if let Ok(test) = abc() {" "if let Ok(mut test) = abc() {" "if let Foo(mut test) = foo {" "if let test = abc() {" "if let Some(test) = abc()" "if let Some((a, test, b)) = abc()" "while let Some(test) = abc() {" "while let Some(mut test) = abc() {" "while let Ok(test) = abc() {" "while let Ok(mut test) = abc() {") :not ("while let test(foo) = abc() {")) ;; structure fields (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "struct\\s+[^\\n{]+[{][^}]*(\\s*JJJ\\s*:\\s*[^\\n},]+)[^}]*}" :tests ("struct Foo { abc: u32, test: Vec, b: PathBuf }" "struct Foo{test:Vec}" "struct FooBar<'a> { test: Vec }") :not ("struct Foo { abc: u32, b: Vec }" "/// ... construct the equivalent ...\nfn abc() {\n")) ;; enum variants (:language "rust" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "enum\\s+[^\\n{]+\\s*[{][^}]*\\bJJJ\\b[^}]*}" :tests ("enum Foo { VariantA, test, VariantB(u32) }" "enum Foo { test(T) }" "enum BadStyle{test}" "enum Foo32 { Bar, testing, test(u8) }") :not ("enum Foo { testing }")) (:language "rust" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfn\\s+JJJ\\s*\\\(" :tests ("fn test(asdf: u32)" "fn test()" "pub fn test()")) (:language "rust" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bmacro_rules!\\s+JJJ" :tests ("macro_rules! test")) (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "struct\\s+JJJ\\s*[{\\\(]?" :tests ("struct test(u32, u32)" "struct test;" "struct test { abc: u32, def: Vec }")) (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "trait\\s+JJJ\\s*[{]?" :tests ("trait test;" "trait test { fn abc() -> u32; }")) (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\btype\\s+JJJ([^=\\n]+)?\\s*=[^=\\n]+;" :tests ("type test = Rc>;" "type test = Arc>>;")) (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "impl\\s+((\\w+::)*\\w+\\s+for\\s+)?(\\w+::)*JJJ\\s+[{]?" :tests ("impl test {" "impl abc::test {" "impl std::io::Read for test {" "impl std::io::Read for abc::test {")) (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "mod\\s+JJJ\\s*[{]?" :tests ("mod test;" "pub mod test {")) ;; enum definitions (:language "rust" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\benum\\s+JJJ\\b\\s*[{]?" :tests ("enum test { A, B, C }" "enum test {" "pub enum test {" "pub enum test { A, B }" "pub enum test {" "enum test { Variant1, Variant2(Type) }" "pub(crate) enum test { Variant }") :not ("enum testing { A, B }" "enum Foo { test, Bar }")) ;;-- elixir (:language "elixir" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bdef(p)?\\s+JJJ\\s*[ ,\\\(]" :tests ("def test do" "def test, do:" "def test() do" "def test(), do:" "def test(foo, bar) do" "def test(foo, bar), do:" "defp test do" "defp test(), do:")) (:language "elixir" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*JJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test == 1234")) (:language "elixir" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "defmodule\\s+(\\w+\\.)*JJJ\\s+" :tests ("defmodule test do" "defmodule Foo.Bar.test do")) (:language "elixir" :type "module" :supports ("ag" "grep" "rg" "git-grep") : :regex "defprotocol\\s+(\\w+\\.)*JJJ\\s+" :tests ("defprotocol test do" "defprotocol Foo.Bar.test do")) ;;-- erlang (:language "erlang" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "^JJJ\\b\\s*\\\(" :tests ("test() ->" "test()->" "test(Foo) ->" "test (Foo,Bar) ->" "test(Foo, Bar)->")) (:language "erlang" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*JJJ\\s*=[^:=\\n]+" :tests ("test = 1234") :not ("if test =:= 1234" "if test == 1234")) (:language "erlang" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "^-module\\\(JJJ\\\)" :tests ("-module(test).")) ;;-- scss (:language "scss" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "@mixin\\sJJJ\\b\\s*\\\(" :tests ("@mixin test()")) (:language "scss" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "@function\\sJJJ\\b\\s*\\\(" :tests ("@function test()")) (:language "scss" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "JJJ\\s*:\\s*" :tests ("test :")) ;;-- sml (:language "sml" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*(data)?type\\s+.*\\bJJJ\\b" :tests ("datatype test =" "datatype test=" "datatype 'a test =" "type test =" "type 'a test =" "type 'a test" "type test") :not ("datatypetest =")) (:language "sml" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*val\\s+\\bJJJ\\b" :tests ("val test =" "val test=" "val test : bool")) (:language "sml" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*fun\\s+\\bJJJ\\b.*\\s*=" :tests ("fun test list =" "fun test (STRING_NIL, a) =" "fun test ((s1,s2): 'a queue) : 'a * 'a queue =" "fun test (var : q) : int =" "fun test f e xs =")) (:language "sml" :type "module" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*(structure|signature|functor)\\s+\\bJJJ\\b" :tests ("structure test =" "structure test : MYTEST =" "signature test =" "functor test (T:TEST) =" "functor test(T:TEST) =")) ;;-- sql (:language "sql" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "(CREATE|create)\\s+(.+?\\s+)?(FUNCTION|function|PROCEDURE|procedure)\\s+JJJ\\s*\\\(" :tests ("CREATE FUNCTION test(i INT) RETURNS INT" "create or replace function test (int)" "CREATE PROCEDURE test (OUT p INT)" "create definer = 'test'@'localhost' procedure test()")) (:language "sql" :type "table" :supports ("ag" "grep" "rg" "git-grep") :regex "(CREATE|create)\\s+(.+?\\s+)?(TABLE|table)(\\s+(IF NOT EXISTS|if not exists))?\\s+JJJ\\b" :tests ("CREATE TABLE test (" "create temporary table if not exists test" "CREATE TABLE IF NOT EXISTS test (" "create global temporary table test")) (:language "sql" :type "view" :supports ("ag" "grep" "rg" "git-grep") :regex "(CREATE|create)\\s+(.+?\\s+)?(VIEW|view)\\s+JJJ\\b" :tests ("CREATE VIEW test (" "create sql security definer view test" "CREATE OR REPLACE VIEW test AS foo")) (:language "sql" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(CREATE|create)\\s+(.+?\\s+)?(TYPE|type)\\s+JJJ\\b" :tests ("CREATE TYPE test" "CREATE OR REPLACE TYPE test AS foo (" "create type test as (")) ;;-- systemverilog (:language "systemverilog" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*class\\s+\\bJJJ\\b" :tests ("virtual class test;" "class test;" "class test extends some_class") :not ("virtual class testing;" "class test2;" "class some_test" "class some_class extends test")) (:language "systemverilog" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*task\\s+\\bJJJ\\b" :tests ("task test (" "task test(") :not ("task testing (" "task test2(")) (:language "systemverilog" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\b\\s*=" :tests ("assign test =" "assign test=" "int test =" "int test=") :not ("assign testing =" "assign test2=")) (:language "systemverilog" :type "function" : supports ("ag" "rg" "git-grep") :regex "function\\s[^\\s]+\\s*\\bJJJ\\b" :tests ("function Matrix test ;" "function Matrix test;") :not ("function test blah")) ;; matches SV class handle declarations (:language "systemverilog" :type "function" :supports ("ag" "rg" "git-grep") :regex "^\\s*[^\\s]*\\s*[^\\s]+\\s+\\bJJJ\\b" :tests ("some_class_name test" " another_class_name test ;" "some_class test[];" "some_class #(1) test") :not ("test some_class_name" "class some_class extends test")) ;;-- vhdl (:language "vhdl" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*type\\s+\\bJJJ\\b" :tests ("type test is" "type test is") :not ("type testing is" "type test2 is")) (:language "vhdl" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*constant\\s+\\bJJJ\\b" :tests ("constant test :" "constant test:") :not ("constant testing " "constant test2:")) (:language "vhdl" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "function\\s*\"?JJJ\"?\\s*\\\(" :tests ("function test(signal)" "function test (signal)" "function \"test\" (signal)") :not ("function testing(signal")) ;;-- latex (:language "tex" :type "command" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\\.*newcommand\\\*?\\s*\\\{\\s*(\\\\)JJJ\\s*}" :tests ("\\newcommand{\\test}" "\\renewcommand{\\test}" "\\renewcommand*{\\test}" "\\newcommand*{\\test}" "\\renewcommand{ \\test }") :not("\\test" "test")) (:language "tex" :type "command" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\\.*newcommand\\\*?\\s*(\\\\)JJJ\\j" :tests ("\\newcommand\\test {}" "\\renewcommand\\test{}" "\\newcommand \\test") :not("\\test" "test")) (:language "tex" :type "length" : supports ("ag" "grep" "rg" "git-grep") :regex "\\\\(s)etlength\\s*\\\{\\s*(\\\\)JJJ\\s*}" :tests ("\\setlength { \\test}" "\\setlength{\\test}" "\\setlength{\\test}{morecommands}" ) :not("\\test" "test")) (:language "tex" :type "counter" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\\newcounter\\\{\\s*JJJ\\s*}" :tests ("\\newcounter{test}" ) :not("\\test" "test")) (:language "tex" :type "environment" :supports ("ag" "grep" "rg" "git-grep") :regex "\\\\.*newenvironment\\s*\\\{\\s*JJJ\\s*}" :tests ("\\newenvironment{test}" "\\newenvironment {test}{morecommands}" "\\lstnewenvironment{test}" "\\newenvironment {test}" ) :not("\\test" "test" )) ;;-- pascal (todo: var, type, const) (:language "pascal" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bfunction\\s+JJJ\\b" :tests (" function test : ")) (:language "pascal" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bprocedure\\s+JJJ\\b" :tests (" procedure test ; ")) ;;-- f# (:language "fsharp" :type "variable" :supports ("ag" "grep" "git-grep") :regex "let\\s+JJJ\\b.*\\\=" :tests ("let test = 1234" "let test() = 1234" "let test abc def = 1234") :not ("let testnot = 1234" "let testnot() = 1234" "let testnot abc def = 1234")) (:language "fsharp" :type "interface" :supports ("ag" "grep" "git-grep") :regex "member(\\b.+\\.|\\s+)JJJ\\b.*\\\=" :tests ("member test = 1234" "member this.test = 1234") :not ("member testnot = 1234" "member this.testnot = 1234")) (:language "fsharp" :type "type" :supports ("ag" "grep" "git-grep") :regex "type\\s+JJJ\\b.*\\\=" :tests ("type test = 1234") :not ("type testnot = 1234")) ;;-- kotlin (:language "kotlin" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "fun\\s*(<[^>]*>)?\\s*JJJ\\s*\\(" :tests ("fun test()" "fun test()")) (:language "kotlin" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(val|var)\\s*JJJ\\b" :not ("val testval" "var testvar") :tests ("val test " "var test")) (:language "kotlin" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|interface)\\s*JJJ\\b" :tests ("class test" "class test : SomeInterface" "interface test")) ;;-- zig (:language "zig" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "fn\\s+JJJ\\b" :tests ("fn test() void {" "fn test(a: i32) i32 {" "pub fn test(a: i32) i32 {" "export fn test(a: i32) i32 {" "extern \"c\" fn test(a: i32) i32 {" "inline fn test(a: i32) i32 {")) (:language "zig" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "(var|const)\\s+JJJ\\b" :tests ("const test: i32 = 3;" "var test: i32 = 3;" "pub const test: i32 = 3;")) ;;-- protobuf (:language "protobuf" :type "message" :supports ("ag" "grep" "rg" "git-grep") :regex "message\\s+JJJ\\s*\\\{" :tests ("message test{" "message test {")) (:language "protobuf" :type "enum" :supports ("ag" "grep" "rg" "git-grep") :regex "enum\\s+JJJ\\s*\\\{" :tests ("enum test{" "enum test {")) ;;-- apex (literally the same regexes as java) (:language "apex" :type "function" :supports ("ag" "rg") :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\(" :tests ("int test()" "int test(param)" "static int test()" "static int test(param)" "public static MyType test()" "private virtual SomeType test(param)" "static int test()" "private foo[] test()") :not ("test()" "testnot()" "blah = new test()" "foo bar = test()")) (:language "apex" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44")) (:language "apex" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "(class|interface)\\s*JJJ\\b" :tests ("class test:" "public class test implements Something") :not ("class testnot:" "public class testnot implements Something")) ;;-- jai (:language "jai" :type "function" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*::" :tests ("test ::")) (:language "jai" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*(:|:\\s*=|::)" :tests ("test: Type" "test : Type = Val" "test :: Val")) (:language "jai" :type "type" :supports ("ag" "grep" "rg" "git-grep") :regex "\\bJJJ\\s*::" :tests ("test ::")) ;;-- odin (:language "odin" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "\\s*\\bJJJ\\s*:\\s*([^=\\n]+\\s*:|:|[^=\\n]+\\s*=|=)" :tests ("test :: struct" "test ::enum" "test:: union" "test: : custom_type" "test :: [2]f32" "test : f32 : 20" "test: i32 : 10" "test := 20" "test : f32 = 20" "test: i32 = 10" "test: i32= 10" "test :i32= 10" "test :: proc()" "test ::proc() {" "test:: proc(a: i32) -> i32 {" "test::proc{}" "test: :proc \"contextless\" {}")) ;;-- cobol (:language "cobol" :type "variable" :supports ("ag" "grep" "rg" "git-grep") :regex "^(.{6}[^*/])?\\s*([frs]d|[[:digit:]]{1,2})\\s+JJJ([\\. ]|$)" :tests (" 01 test." "000350 10 test pic x." " 88 test value '10'." "fd test." " sd test.") :not (" *01 test" " 05 test-01" " 05 testing")) (:language "cobol" :type "section" :supports ("ag" "grep" "rg" "git-grep") :regex "^(.{6}[^*/])?JJJ(\\s+section)?\\." :tests (" test." " test section." "test." "test section.") :not (" test." " *test section.")) (:language "cobol" :type "submodule" :supports ("ag" "grep" "rg" "git-grep") :regex "^(.{6}[^*/])?program-id\\.\\s*[\"']?JJJ[\"']?.*\\." :tests (" program-id. test." " program-id. 'test'." "program-id. \"test\".") :not (" test."))) "List of search regex pattern templates organized by language and type. Used for generating the grep tool search commands. For a given language, a regular expression is only used by Dumb Jump when the currently used search tool is identified in the :supports value. The regex string is a template filled by `dumb-jump-populate-regex' and should contain the \"JJJ\" string, a marker for the searched identifier. It may also contain the following: - \"\\\\j\" : a marker for word-boundary regular-expression to use instead of \"\\\\b\" when word boundary concept must support Lisp language family and must not include the characters '-', '?' and '*'. In the Lisp family of programming languages a large number of characters are allowed in identifiers, including '-', '?' and '*'. This marker is replaced by value of the search tool specific dumb-jump-TOOL-word-boundary, like `dumb-jump-ag-word-boundary' for ag. - \"\\\\s\" : for a single white space character. Replaced by \"[[:space:]]\" for some search tools as identified by `dumb-jump-use-space-bracket-exp-for' returning t for a tool variant. The language types supported are listed in the linked page below: - Ag: URL \ `https://github.com/ggreer/the_silver_searcher/blob/master/tests/list_file_types.t' - rg: URL \ `https://github.com/BurntSushi/ripgrep/blob/master/crates/ignore/src/default_types.rs#L12' More information using the search tool command line help." :group 'dumb-jump :type '(repeat (plist :options ((:language string) (:type string) (:supports string) (:regex string) (:tests (repeat string)) (:not (repeat string)))))) (defcustom dumb-jump-language-file-exts ;; dumb-jump language file extension ag type rg type '((:language "elisp" :ext "el" :agtype "elisp" :rgtype "elisp") (:language "elisp" :ext "el.gz" :agtype "elisp" :rgtype "elisp") (:language "commonlisp" :ext "lisp" :agtype "lisp" :rgtype "lisp") (:language "commonlisp" :ext "lsp" :agtype "lisp" :rgtype "lisp") (:language "c++" :ext "c" :agtype "cc" :rgtype "c") (:language "c++" :ext "h" :agtype "cc" :rgtype "c") (:language "c++" :ext "C" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "H" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "tpp" :agtype "cpp" :rgtype nil) (:language "c++" :ext "cpp" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "hpp" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "cxx" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "hxx" :agtype "cpp" :rgtype nil) (:language "c++" :ext "cc" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "hh" :agtype "cpp" :rgtype "cpp") (:language "c++" :ext "c++" :agtype nil :rgtype nil) (:language "c++" :ext "h++" :agtype nil :rgtype nil) (:language "coq" :ext "v" :agtype nil :rgtype nil) (:language "ocaml" :ext "ml" :agtype "ocaml" :rgtype "ocaml") (:language "ocaml" :ext "mli" :agtype "ocaml" :rgtype "ocaml") (:language "ocaml" :ext "mll" :agtype "ocaml" :rgtype "ocaml") (:language "ocaml" :ext "mly" :agtype "ocaml" :rgtype "ocaml") ;; groovy is nil type because jenkinsfile is not in searcher type lists (:language "groovy" :ext "gradle" :agtype nil :rgtype nil) (:language "groovy" :ext "groovy" :agtype nil :rgtype nil) (:language "groovy" :ext "jenkinsfile" :agtype nil :rgtype nil) (:language "haskell" :ext "hs" :agtype "haskell" :rgtype "haskell") (:language "haskell" :ext "lhs" :agtype "haskell" :rgtype "haskell") (:language "objc" :ext "m" :agtype "objc" :rgtype "objc") (:language "csharp" :ext "cs" :agtype "csharp" :rgtype "csharp") (:language "java" :ext "java" :agtype "java" :rgtype "java") (:language "vala" :ext "vala" :agtype "vala" :rgtype "vala") (:language "vala" :ext "vapi" :agtype "vala" :rgtype "vala") (:language "julia" :ext "jl" :agtype "julia" :rgtype "julia") (:language "clojure" :ext "clj" :agtype "clojure" :rgtype "clojure") (:language "clojure" :ext "cljc" :agtype "clojure" :rgtype "clojure") (:language "clojure" :ext "cljs" :agtype "clojure" :rgtype "clojure") (:language "clojure" :ext "cljx" :agtype "clojure" :rgtype "clojure") (:language "coffeescript" :ext "coffee" :agtype "coffee" :rgtype "coffeescript") (:language "faust" :ext "dsp" :agtype nil :rgtype nil) (:language "faust" :ext "lib" :agtype nil :rgtype nil) (:language "fennel" :ext "fnl" :agtype nil :rgtype nil) (:language "fortran" :ext "F" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "f" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "f77" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "f90" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "f95" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "F77" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "F90" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "F95" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "f03" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "for" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "ftn" :agtype "fortran" :rgtype "fortran") (:language "fortran" :ext "fpp" :agtype "fortran" :rgtype "fortran") (:language "go" :ext "go" :agtype "go" :rgtype "go") (:language "javascript" :ext "js" :agtype "js" :rgtype "js") (:language "javascript" :ext "jsx" :agtype "js" :rgtype "js") (:language "javascript" :ext "vue" :agtype "js" :rgtype "js") (:language "javascript" :ext "html" :agtype "html" :rgtype "html") (:language "javascript" :ext "css" :agtype "css" :rgtype "css") (:language "typescript" :ext "ts" :agtype "ts" :rgtype "ts") (:language "typescript" :ext "tsx" :agtype "ts" :rgtype "ts") (:language "typescript" :ext "vue" :agtype "ts" :rgtype "ts") (:language "dart" :ext "dart" :agtype nil :rgtype "dart") (:language "dlang" :ext "d" :agtype "dlang" :rgtype "d") (:language "dlang" :ext "di" :agtype "dlang" :rgtype "d") (:language "lua" :ext "lua" :agtype "lua" :rgtype "lua") ;; the extension "m" is also used by obj-c so must use matlab-mode ;; since obj-c will win by file extension, but here for searcher types (:language "matlab" :ext "m" :agtype "matlab" :rgtype "matlab") (:language "nim" :ext "nim" :agtype "nim" :rgtype "nim") (:language "nix" :ext "nix" :agtype "nix" :rgtype "nix") (:language "org" :ext "org" :agtype nil :rgtype "org") (:language "perl" :ext "pl" :agtype "perl" :rgtype "perl") (:language "perl" :ext "pm" :agtype "perl" :rgtype "perl") (:language "perl" :ext "pm6" :agtype "perl" :rgtype nil) (:language "perl" :ext "perl" :agtype nil :rgtype "perl") (:language "perl" :ext "plh" :agtype nil :rgtype "perl") (:language "perl" :ext "plx" :agtype nil :rgtype "perl") (:language "perl" :ext "pod" :agtype "perl" :rgtype "pod") (:language "perl" :ext "t" :agtype "perl" :rgtype nil) (:language "php" :ext "php" :agtype "php" :rgtype "php") (:language "php" :ext "php3" :agtype "php" :rgtype "php") (:language "php" :ext "php4" :agtype "php" :rgtype "php") (:language "php" :ext "php5" :agtype "php" :rgtype "php") (:language "php" :ext "phtml" :agtype "php" :rgtype "php") (:language "php" :ext "inc" :agtype "php" :rgtype nil) (:language "purescript" :ext "purs" :agtype nil :rgtype nil) (:language "python" :ext "py" :agtype "python" :rgtype "py") (:language "r" :ext "R" :agtype "r" :rgtype "r") (:language "r" :ext "r" :agtype "r" :rgtype "r") (:language "r" :ext "Rmd" :agtype "r" :rgtype "r") (:language "r" :ext "Rnw" :agtype "r" :rgtype "r") (:language "r" :ext "Rtex" :agtype "r" :rgtype nil) (:language "r" :ext "Rrst" :agtype "r" :rgtype nil) (:language "racket" :ext "rkt" :agtype "racket" :rgtype "lisp") (:language "crystal" :ext "cr" :agtype "crystal" :rgtype "crystal") (:language "crystal" :ext "ecr" :agtype "crystal" :rgtype nil) (:language "ruby" :ext "rb" :agtype "ruby" :rgtype "ruby") (:language "ruby" :ext "erb" :agtype "ruby" :rgtype nil) (:language "ruby" :ext "haml" :agtype "ruby" :rgtype nil) (:language "ruby" :ext "rake" :agtype "ruby" :rgtype nil) (:language "ruby" :ext "slim" :agtype "ruby" :rgtype nil) (:language "rust" :ext "rs" :agtype "rust" :rgtype "rust") (:language "zig" :ext "zig" :agtype nil :rgtype "zig") (:language "scad" :ext "scad" :agtype nil :rgtype nil) (:language "scala" :ext "scala" :agtype "scala" :rgtype "scala") (:language "scheme" :ext "scm" :agtype "scheme" :rgtype "lisp") (:language "scheme" :ext "ss" :agtype "scheme" :rgtype "lisp") (:language "scheme" :ext "sld" :agtype "scheme" :rgtype "lisp") (:language "janet" :ext "janet" :agtype "janet" :rgtype "lisp") (:language "shell" :ext "sh" :agtype nil :rgtype nil) (:language "shell" :ext "bash" :agtype nil :rgtype nil) (:language "shell" :ext "csh" :agtype nil :rgtype nil) (:language "shell" :ext "ksh" :agtype nil :rgtype nil) (:language "shell" :ext "tcsh" :agtype nil :rgtype nil) (:language "sml" :ext "sml" :agtype "sml" :rgtype "sml") (:language "solidity" :ext "sol" :agtype nil :rgtype nil) (:language "sql" :ext "sql" :agtype "sql" :rgtype "sql") (:language "swift" :ext "swift" :agtype nil :rgtype "swift") (:language "tex" :ext "tex" :agtype "tex" :rgtype "tex") (:language "elixir" :ext "ex" :agtype "elixir" :rgtype "elixir") (:language "elixir" :ext "exs" :agtype "elixir" :rgtype "elixir") (:language "elixir" :ext "eex" :agtype "elixir" :rgtype "elixir") (:language "erlang" :ext "erl" :agtype "erlang" :rgtype "erlang") (:language "systemverilog" :ext "sv" :agtype "verilog" :rgtype "verilog") (:language "systemverilog" :ext "svh" :agtype "verilog" :rgtype "verilog") (:language "vhdl" :ext "vhd" :agtype "vhdl" :rgtype "vhdl") (:language "vhdl" :ext "vhdl" :agtype "vhdl" :rgtype "vhdl") (:language "scss" :ext "scss" :agtype "css" :rgtype "css") (:language "pascal" :ext "pas" :agtype "delphi" :rgtype nil) (:language "pascal" :ext "dpr" :agtype "delphi" :rgtype nil) (:language "pascal" :ext "int" :agtype "delphi" :rgtype nil) (:language "pascal" :ext "dfm" :agtype "delphi" :rgtype nil) (:language "fsharp" :ext "fs" :agtype "fsharp" :rgtype nil) (:language "fsharp" :ext "fsi" :agtype "fsharp" :rgtype nil) (:language "fsharp" :ext "fsx" :agtype "fsharp" :rgtype nil) (:language "kotlin" :ext "kt" :agtype "kotlin" :rgtype "kotlin") (:language "kotlin" :ext "kts" :agtype "kotlin" :rgtype "kotlin") (:language "protobuf" :ext "proto" :agtype "proto" :rgtype "protobuf") (:language "hcl" :ext "tf" :agtype "terraform" :rgtype "tf") (:language "hcl" :ext "tfvars" :agtype "terraform" :rgtype nil) (:language "apex" :ext "cls" :agtype nil :rgtype nil) (:language "apex" :ext "trigger" :agtype nil :rgtype nil) (:language "jai" :ext "jai" :agtype nil :rgtype nil) (:language "odin" :ext "odin" :agtype nil :rgtype nil) (:language "cobol" :ext "cbl" :agtype nil :rgtype nil) (:language "cobol" :ext "cob" :agtype nil :rgtype nil) (:language "cobol" :ext "cpy" :agtype nil :rgtype nil)) "Map programming language to file extensions support by search tool. The value of :agytpe, :rgtype is nil when the search tool file type does not search for that file extension, otherwise it is the name of the file type for that tool." :group 'dumb-jump :type '(repeat (plist :options ((:language (string :tag "Language")) (:ext (string :tag "Extension")) (:agtype (string :tag "Ag type")) (:rgtype (string :tag "Ripgrep type")))))) (defcustom dumb-jump-language-contexts '((:language "javascript" :type "function" :left nil :right "^(" ) (:language "javascript" :type "variable" :left "($" :right nil ) (:language "javascript" :type "variable" :left "($" :right "^)" ) (:language "javascript" :type "variable" :left nil :right "^\\." ) (:language "javascript" :type "variable" :left nil :right "^;" ) (:language "typescript" :type "function" :left nil :right "^(" ) (:language "typescript" :type "type" :left "\\(?:[:<>,|&]\\|\\_<\\(?:as\\|extends\\|implements\\)\\_>\\)\\s-*$" :right nil) (:language "typescript" :type "type" :left "\\_<\\(?:type\\|interface\\|enum\\|class\\)\\_>\\s-+$" :right nil) (:language "perl" :type "function" :left nil :right "^(" ) (:language "tcl" :type "function" :left "\\[$" :right nil) (:language "tcl" :type "function" :left "^\\s*$" :right nil) (:language "tcl" :type "variable" :left "\\$$" :right nil) (:language "php" :type "function" :left nil :right "^(" ) (:language "php" :type "class" :left "new\\s+" :right nil ) (:language "elisp" :type "function" :left "($" :right nil ) (:language "elisp" :type "variable" :left nil :right "^)" ) (:language "scheme" :type "function" :left "($" :right nil ) (:language "scheme" :type "variable" :left nil :right "^)" ) (:language "jai" :type "function" :left nil :right "\\s*(" ) (:language "jai" :type "type" :left "\\s*:\\s*" :right nil) (:language "cobol" :type "submodule" :left "call\\s+" :right nil ) (:language "cobol" :type "section" :left "perform\\s+" :right nil ) (:language "cobol" :type "section" :left "go to\\s+" :right nil )) "List of under points contexts for each language. This helps limit the number of regular expressions we use if we know that if there's a ( immediately to the right of a symbol then it's probably a function call." :group 'dumb-jump :type '(repeat (plist :options ((:language (string :tag "Language")) (:type (choice (const "function") (const "variable"))) (:left (choice (const :tag "Anything" nil) (string :tag "Regular expression"))) (:right (choice (const :tag "Anything" nil) (string :tag "Regular expression"))))))) (defcustom dumb-jump-project-denoters '(".dumbjump" ".projectile" ".git" ".hg" ".fslckout" ".bzr" "_darcs" ".svn" "Makefile" "PkgInfo" "-pkg.el" "_FOSSIL_") "Files and directories that signify a directory is a project root. If any of these denoting files are present in project sub-directories (like Makefile) then you can either remove the culprit denoter from the list or create a .dumbjumpignore file in the project sub-directory." :group 'dumb-jump :type '(repeat (string :tag "Name"))) (defcustom dumb-jump-default-project "~" "Directory of default project to search within if a project root is not found." :group 'dumb-jump :type 'string) (defcustom dumb-jump-project nil "Directory of project to search within if normal denoters will not work. This should only be needed in the rarest of cases." :group 'dumb-jump :type 'string) (defcustom dumb-jump-before-jump-hook nil "Hooks called before jumping." :group 'dumb-jump :type 'hook) (defcustom dumb-jump-after-jump-hook nil "Hooks called after jumping." :group 'dumb-jump :type 'hook) (defcustom dumb-jump-aggressive nil "If `t` jump aggressively with the possibility of a false positive. If `nil` always show list of more than 1 match." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-debug nil "If `t` will print helpful debug information. Also ensure that `dumb-jump-quiet' is nil for debugging!" :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-confirm-jump-to-modified-file t "Confirm before jumping to a modified file? If t, confirm before jumping to a modified file (which may lead to an inaccurate jump). If nil, jump without confirmation but print a warning." :group 'dumb-jump :type 'boolean) (defcustom dumb-jump-disable-obsolete-warnings nil "If non-nil, don't warn about using the legacy interface." :group 'dumb-jump :type 'boolean) ;; --------------------------------------------------------------------------- ;; Debugging Utilities ;; ------------------- (defun dumb-jump-message-prin1 (format-str &rest args) "Helper debugging function: generate a FORMAT-STR message with all ARGS." ;; Fist transform each of ARGS to string with `prin1-to-string' then ;; pass them as arguments to message by making a list used the third ;; parameter to apply. (apply 'message format-str (-map 'prin1-to-string args))) ;; --------------------------------------------------------------------------- ;; Search tool presence checkers ;; ----------------------------- (defvar dumb-jump--detected-env-problems nil "List of detected environment problems. Last detected problem is first in the list.") (defun dumb-jump-env-problem (problem) "Add PROBLEM string to `dumb-jump--detected-env-problems' list." (unless (member problem dumb-jump--detected-env-problems) (push problem dumb-jump--detected-env-problems))) ;;;###autoload (defun dumb-jump-show-detected-problems (keep) "Print all problems detected by dumb-jump environment in *Message*. Erase the accumulated list unless the command is issued with any prefix key (such as `\\[universal-argument]')." (interactive "P") (if dumb-jump--detected-env-problems (progn (message "-- Dumb-Jump Detected Environment Problems:") (dolist (problem (reverse dumb-jump--detected-env-problems)) (message problem)) (unless keep (setq dumb-jump--detected-env-problems nil))) (message "No problem recorded yet."))) ;; -- (defvar dumb-jump--ag-installed? 'unset) (defun dumb-jump-ag-installed? () "Return t if ag is installed." (if (eq dumb-jump--ag-installed? 'unset) (setq dumb-jump--ag-installed? (dumb-jump--contains-p "ag version" (shell-command-to-string (concat dumb-jump-ag-cmd " --version")))) dumb-jump--ag-installed?)) (defvar dumb-jump--git-grep-plus-ag-installed? 'unset) (defun dumb-jump-git-grep-plus-ag-installed? () "Return t if git grep and ag is installed." (if (eq dumb-jump--git-grep-plus-ag-installed? 'unset) (setq dumb-jump--git-grep-plus-ag-installed? (and (dumb-jump-git-grep-installed?) (dumb-jump-ag-installed?))) dumb-jump--git-grep-plus-ag-installed?)) (defvar dumb-jump--rg-installed? 'unset) (defun dumb-jump-rg-installed? () "Return t if rg 0.10 or later with PCRE2 support is installed. Return nil otherwise. In that case store diagnostics information in the variable `dumb-jump--detected-env-problems'." (if (eq dumb-jump--rg-installed? 'unset) (setq dumb-jump--rg-installed? (catch 'rg-problem (unless (executable-find dumb-jump-rg-cmd) (dumb-jump-env-problem (format "Ripgrep not found as specified in `dumb-jump-rg-cmd': %s" dumb-jump-rg-cmd)) (throw 'rg-problem nil)) (let* ((stdout (shell-command-to-string (concat dumb-jump-rg-cmd " --version"))) (has-version (string-match "ripgrep \\([0-9]+\\.[0-9]+\\).*" stdout))) (unless has-version (dumb-jump-env-problem "Can't detect Ripgrep version.") (throw 'rg-problem nil)) (unless (version<= "0.10" (match-string-no-properties 1 stdout)) (dumb-jump-env-problem "Ripgrep >= 0.10 is not available.") (throw 'rg-problem nil)) (unless (string-match "features:.*pcre2" stdout) (dumb-jump-env-problem "Ripgrep does not support PCRE2.") (throw 'rg-problem nil)) t))) dumb-jump--rg-installed?)) (defvar dumb-jump--git-grep-installed? 'unset) (defun dumb-jump-git-grep-installed? () "Return t if git-grep is installed." (if (eq dumb-jump--git-grep-installed? 'unset) (setq dumb-jump--git-grep-installed? (dumb-jump--contains-p "fatal: no pattern given" (shell-command-to-string (concat dumb-jump-git-grep-cmd)))) dumb-jump--git-grep-installed?)) (defvar dumb-jump--grep-installed? 'unset) (defun dumb-jump-grep-installed? () "Return non-nil if a grep is installed, nil otherwise. Return \\='gnu if GNU grep is installed, \\='bsd if BSD grep is installed." (if (eq dumb-jump--grep-installed? 'unset) (let* ((version (shell-command-to-string (concat dumb-jump-grep-cmd " --version"))) (variant (cond ((dumb-jump--match "GNU grep" version) 'gnu) ((dumb-jump--match "[0-9]+\\.[0-9]+" version) 'bsd) (t nil)))) (setq dumb-jump--grep-installed? variant)) dumb-jump--grep-installed?)) ;; --------------------------------------------------------------------------- ;; Dumb-Jump Tests ;; --------------- (defun dumb-jump-run-test (test cmd) "Use TEST as the standard input for the CMD." (with-temp-buffer (insert test) (shell-command-on-region (point-min) (point-max) cmd nil t) (buffer-substring-no-properties (point-min) (point-max)))) (defun dumb-jump-run-test-temp-file (test thefile realcmd) "Write TEST string to temporary file THEFILE, run shell REALCMD on it. Return resulting string." (with-temp-buffer (insert test) (write-file thefile nil) (delete-region (point-min) (point-max)) (shell-command realcmd t) (set-buffer-modified-p nil) ; prevent prompt on file deletion during test (delete-file thefile) (buffer-substring-no-properties (point-min) (point-max)))) (defun dumb-jump-run-git-grep-test (test git-grep-cmd) "Execute GIT-GREP-CMD on input TEST string written in temporary file. Necessary because git grep must be given a file as input, not just a string." (let ((thefile ".git.grep.test")) (dumb-jump-run-test-temp-file test thefile (concat git-grep-cmd " " thefile)))) (defun dumb-jump-run-ag-test (test ag-cmd) "Execute AG-CMD on input TEST written in temporary file. The difference is that ag ignores multiline matches when passed input from stdin, which is a crucial feature." (let ((thefile ".ag.test")) (dumb-jump-run-test-temp-file test thefile (concat ag-cmd " " thefile)))) ;; --------------------------------------------------------------------------- ;; Test dumb-jump search rules ;; --------------------------- (defun dumb-jump--search-failure-msg (tool test run-not-tests resp cmd rule) "Return search failure string adjusted to the arguments. TOOL: search tool name. TEST: the test string. RUN-NO-TESTS: t to see a list of all failed rules. RESP: response. CMD: the search command used. RULE: the complete `dumb-jump-find-rules' rule used for this test." (format "%s FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'" tool test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)) (defun dumb-jump-test-grep-rules (&optional run-not-tests) "Test all the grep rules and return count of those that fail. Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules." (let ((variant (if (eq (dumb-jump-grep-installed?) 'gnu) 'gnu-grep 'grep))) (-mapcat (lambda (rule) (-mapcat (lambda (test) (let* ((cmd (concat "grep -En -e " (shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" variant)))) (resp (dumb-jump-run-test test cmd))) (when (or (and (not run-not-tests) (not (dumb-jump--contains-p test resp))) (and run-not-tests (> (length resp) 0))) (list (dumb-jump--search-failure-msg "grep" test run-not-tests resp cmd (plist-get rule :regex)))))) (plist-get rule (if run-not-tests :not :tests)))) (--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules)))) (defun dumb-jump-test-ag-rules (&optional run-not-tests) "Test all the ag rules and return count of those that fail. Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules." (-mapcat (lambda (rule) (-mapcat (lambda (test) (let* ((cmd (concat "ag --nocolor --nogroup --nonumber " (shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'ag)))) (resp (dumb-jump-run-ag-test test cmd))) (when (or (and (not run-not-tests) (not (dumb-jump--contains-p test resp))) (and run-not-tests (> (length resp) 0))) (list (dumb-jump--search-failure-msg "ag" test run-not-tests resp cmd rule))))) (plist-get rule (if run-not-tests :not :tests)))) (--filter (member "ag" (plist-get it :supports)) dumb-jump-find-rules))) (defun dumb-jump-test-rg-rules (&optional run-not-tests) "Test all the rg rules and return count of those that fail. Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules." (-mapcat (lambda (rule) (-mapcat (lambda (test) (let* ((cmd (concat "rg --color never --no-heading -U --pcre2 " (shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'rg)))) (resp (dumb-jump-run-test test cmd))) (when (or (and (not run-not-tests) (not (dumb-jump--contains-p test resp))) (and run-not-tests (> (length resp) 0))) (list (dumb-jump--search-failure-msg "rg" test run-not-tests resp cmd rule))))) (plist-get rule (if run-not-tests :not :tests)))) (--filter (member "rg" (plist-get it :supports)) dumb-jump-find-rules))) (defun dumb-jump-test-git-grep-rules (&optional run-not-tests) "Test all the git grep rules and return count of those that fail. Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules." (-mapcat (lambda (rule) (-mapcat (lambda (test) ;; -h: suppress output of filename on each match ;; --untracked : in addition to searching tracked file in working ;; tree , search also in untracked files. ;; -E : POSIX extended/basic regexp to search. (let* ((cmd (concat "git grep --color=never -h --untracked -E " (shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'git-grep)))) (resp (dumb-jump-run-git-grep-test test cmd))) (when (or (and (not run-not-tests) (not (dumb-jump--contains-p test resp))) (and run-not-tests (> (length resp) 0))) (list (dumb-jump--search-failure-msg "git-grep" test run-not-tests resp cmd rule))))) (plist-get rule (if run-not-tests :not :tests)))) (--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules))) ;; --------------------------------------------------------------------------- (defun dumb-jump-message (str &rest args) "Log message STR with ARGS to *Messages* if not using `dumb-jump-quiet'." (unless dumb-jump-quiet (apply 'message str args)) nil) (defmacro dumb-jump-debug-message (&rest exprs) "Generate a debug message to print all expressions EXPRS." (declare (indent defun)) (let ((i 5) frames frame) ;; based on https://emacs.stackexchange.com/a/2312 (while (setq frame (backtrace-frame i)) (push frame frames) (cl-incf i)) ;; this is a macro-expanded version of the code in the stackexchange ;; code from above. This version should work on emacs-24.3, since it ;; doesn't depend on thread-last. (let* ((frame (cl-find-if (lambda (frame) (ignore-errors (and (car frame) (eq (caaddr frame) 'defalias)))) (reverse frames))) (func (cl-cadadr (cl-caddr frame))) (defun-name (symbol-name func))) (with-temp-buffer (insert "DUMB JUMP DEBUG `") (insert defun-name) (insert "` START\n----\n\n") (dolist (expr exprs) (insert (prin1-to-string expr) ":\n\t%s\n\n")) (insert "\n-----\nDUMB JUMP DEBUG `") (insert defun-name) (insert "` END\n-----") `(when dumb-jump-debug (dumb-jump-message ,(buffer-string) ,@exprs)))))) (defun dumb-jump-get-point-context (line func cur-pos) "Get the LINE context to the left and right of FUNC using CUR-POS as hint." (let ((loc (or (cl-search func line :start2 cur-pos) 0))) (list :left (substring line 0 loc) :right (substring line (+ loc (length func)))))) (defun dumb-jump-to-selected (results choices selected) "With RESULTS use CHOICES to find the SELECTED choice from multiple options." (let* ((result-index (--find-index (string= selected it) choices)) (result (when result-index (nth result-index results)))) (when result (dumb-jump-result-follow result)))) (defun dumb-jump-helm-persist-action (candidate) "Preview CANDIDATE in temporary buffer displaying the file at matched line. \\ This is the persistent action (\\[helm-execute-persistent-action]) for helm." (let* ((file (plist-get candidate :path)) (line (plist-get candidate :line)) (default-directory-old default-directory)) (switch-to-buffer (get-buffer-create " *helm dumb jump persistent*")) (setq default-directory default-directory-old) (fundamental-mode) (erase-buffer) (insert-file-contents file) (let ((buffer-file-name file)) (set-auto-mode) (font-lock-fontify-region (point-min) (point-max)) (goto-char (point-min)) (forward-line (1- line))))) (defun dumb-jump--format-result (proj-root result) "Return file:line:target formatted RESULT as a string stripped of PROJ-ROOT." (format "%s:%s: %s" (dumb-jump--replace proj-root "" (plist-get result :path)) (plist-get result :line) (dumb-jump--trim (plist-get result :context)))) (defun dumb-jump-ivy-jump-to-selected (results choices _proj) "Offer CHOICES as candidates through `ivy-read'. Then execute dumb-jump-result-follow' on the selected choice RESULTS. Ignore _PROJ." (if (fboundp 'ivy-read) (ivy-read "Jump to: " (-zip-pair choices results) :action (lambda (cand) (dumb-jump-result-follow (cdr cand))) :caller 'dumb-jump-ivy-jump-to-selected) (error "ivy-read is unknown. Is it loaded?"))) (defun dumb-jump-prompt-user-for-choice (proj-root results) "Prompt user to select one of the identified RESULTS in PROJ-ROOT. Strip the PROJ-ROOT (project root path) from the file name shown in each entry. Prompt with the mechanism selected by `dumb-jump-selector' user-option if available otherwise default to `completing-read'." (let ((choices (--map (dumb-jump--format-result proj-root it) results))) (cond ((eq dumb-jump-selector 'completing-read) (dumb-jump-to-selected results choices (dumb-jump--select-choice choices "Jump to: "))) ;; ((and (eq dumb-jump-selector 'ivy) (fboundp 'ivy-read)) (funcall dumb-jump-ivy-jump-to-selected-function results choices proj-root)) ;; ((and (eq dumb-jump-selector 'helm) (fboundp 'helm)) (helm :sources (with-no-warnings (helm-make-source "Jump to: " 'helm-source-sync :action '(("Jump to match" . dumb-jump-result-follow)) :candidates (-zip-pair choices results) :persistent-action 'dumb-jump-helm-persist-action)) :buffer "*helm dumb jump choices*")) ;; fallback for unsupported selector values (t (dumb-jump-to-selected results choices (dumb-jump--select-choice choices "Jump to: ")))))) (defun dumb-jump-get-project-root (filepath) "Return project root holding FILEPATH. Keep looking at the parent dir of FILEPATH until we find a denoter file/dir. Return a directory name without the trailing slash." (directory-file-name (expand-file-name (or dumb-jump-project (locate-dominating-file filepath #'dumb-jump-get-config) dumb-jump-default-project)))) (defun dumb-jump-get-config (dir) "If a project denoter is in DIR then return it, otherwise nil. However, if DIR contains a `.dumbjumpignore' it returns nil to keep looking for another root." (if (file-exists-p (expand-file-name ".dumbjumpignore" dir)) nil (car (--filter (file-exists-p (expand-file-name it dir)) dumb-jump-project-denoters)))) (defun dumb-jump-get-language (file) "Get language from FILE extension. Fallback to using `major-mode' name." (let* ((language (or (dumb-jump-get-language-from-mode) (dumb-jump-get-language-by-filename file) (dumb-jump-get-mode-base-name)))) ; src edit buffer ? org-edit-src-exit (if (and (fboundp 'org-src-edit-buffer-p) (org-src-edit-buffer-p)) (progn (setq language "org") (with-no-warnings (org-edit-src-exit)) (if (and (boundp 'org-version) (version< org-version "9")) (save-buffer)))) (if (string= language "org") (setq language (dumb-jump-get-language-in-org))) (if (member language (-distinct (--map (plist-get it :language) dumb-jump-find-rules))) language (format ".%s file" (or (file-name-extension file) ""))))) (defun dumb-jump-get-language-in-org () "Return associated language in org mode src block or \"org\" if outside src. This assumes point is inside an org mode buffer." (let ((lang (nth 0 (with-no-warnings (org-babel-get-src-block-info))))) ;; if lang exists then create a composite language (if lang (dumb-jump-make-composite-language "org" (if (dumb-jump-get-language-from-aliases lang) (dumb-jump-get-language-from-aliases lang) lang) "org" "org" "org") "org"))) (defun dumb-jump-add-language-to-proplist (newlang proplist lang) "Return nil if NEWLANG is already in PROPLIST or (if not) return a new proplist. The new proplis is PROPLIS where a NEWLANG plist(s) is (are) added to PROPLIST. The plist(s) value of NEWLANG is (are) copied from those of LANG and LANG is replaced by NEWLANG." (unless (--filter (string= newlang (plist-get it :language)) proplist) (--splice (string= lang (plist-get it :language)) (list it (plist-put (copy-tree it) :language newlang)) proplist))) (defun dumb-jump-make-composite-language (mode lang extension agtype rgtype) "Concat one MODE (usually the string org) with a LANG (c or python or etc) to make a composite language of the form cPLUSorg or pythonPLUSorg or etc. Modify `dumb-jump-find-rules' and `dumb-jump-language-file-exts' accordingly \(using EXTENSION AGTYPE RGTYPE)" (let* ((complang (concat lang "PLUS" mode)) (alreadyextension (--filter (and (string= complang (plist-get it :language)) (string= extension (plist-get it :ext)) (string= agtype (plist-get it :agtype)) (string= rgtype (plist-get it :rgtype))) dumb-jump-language-file-exts)) (newfindrule (dumb-jump-add-language-to-proplist complang dumb-jump-find-rules lang)) (newfileexts (dumb-jump-add-language-to-proplist complang dumb-jump-language-file-exts lang))) ;; add (if needed) composite language to dumb-jump-find-rules (when newfindrule (set-default 'dumb-jump-find-rules newfindrule)) ;; add (if needed) composite language to dumb-jump-language-file-exts (unless dumb-jump-search-type-org-only-org (when newfileexts (set-default 'dumb-jump-language-file-exts newfileexts))) ;; add (if needed) a new extension to dumb-jump-language-file-exts (unless alreadyextension (set-default 'dumb-jump-language-file-exts (cons `(:language ,complang :ext ,extension :agtype ,agtype :rgtype ,rgtype) dumb-jump-language-file-exts))) complang)) (defcustom dumb-jump-language-aliases-alist '(("sh" . "shell") ("d" . "dlang") ("cperl" . "perl") ("octave" . "matlab") ("emacs-lisp" . "elisp") ("R" . "r")) "An alist of language alias to language name. Aliases are major mode base name sometimes used for some files. For example: \"cperl\" for the \"perl\" language." :group 'dumb-jump :type '(repeat (cons (string :tag "alias ") (string :tag "language")))) (defun dumb-jump-get-language-from-aliases (lang) "Return the dumb-jump language name for a possible alias if there is one. Return nil if LANG is not one of the supported aliases." (assoc-default lang dumb-jump-language-aliases-alist)) (defun dumb-jump-get-mode-base-name () "Get the base name of the mode." (dumb-jump--replace "-mode" "" (symbol-name major-mode))) (defun dumb-jump-get-language-from-mode () "Extract the language from the `major-mode' name. Currently just everything before \"-mode\"." (dumb-jump-get-language-from-aliases (dumb-jump-get-mode-base-name))) (defun dumb-jump-get-language-by-filename (file) "Get the programming language name from the specified FILE extension." ;; Search in `dumb-jump-language-file-exts' for an entry that has the :ext ;; attribute equal to the file extension and return the corresponding ;; :language value. (let* ((filename (if (string-suffix-p ".gz" file) (file-name-sans-extension file) file)) (result (--filter (string-suffix-p (concat "." (plist-get it :ext)) filename) dumb-jump-language-file-exts))) (when (and result (eq (length result) 1)) (plist-get (car result) :language)))) ;; -- (defun dumb-jump-issue-result (issue) "Return a result property list with the ISSUE set as :issue property symbol." `(:results nil :lang nil :symbol nil :ctx-type nil :file nil :root nil :issue ,(intern issue))) (defun dumb-jump-get-results (&optional entered-name) "Perform the dumb-jump search for text at point, region or ENTERED-NAME. Runs `dumb-jump-fetch-results' under conditions adjusted to the current context. Perform the search if searcher is installed, buffer is saved, and there's a symbol under point or an item to search is specified by the ENTERED-NAME string. Return the dumb-jump alist result: - :results - :lang : string: language name - :symbol : string: symbol being searched - :ctx-type: string: - :file : string: file name - :root : string: project root - :issue : symbol: problem description symbol: nogrep or nosymbol." ;; Prevent a empty string entered-name from being interpreted as user entry ;; because `read-from-minibuffer' may return "". (when (and entered-name (string-blank-p entered-name)) (setq entered-name nil)) (cond ;; When no search tool is available just return an empty result identifying ;; a nogrep issue. ((not (or (dumb-jump-ag-installed?) (dumb-jump-rg-installed?) (dumb-jump-git-grep-installed?) (dumb-jump-grep-installed?))) (dumb-jump-issue-result "nogrep")) ;; Inside a shell or eshell buffer, ((or (string= (buffer-name) "*shell*") (string= (buffer-name) "*eshell*")) (dumb-jump-fetch-shell-results entered-name)) ;; When inside a normal buffer but no string specified by ENTERED-NAME, ;; point or region does not identify something to search, ;; just return an empty result identifying a nosymbol issue. ((and (not entered-name) (not (region-active-p)) (not (thing-at-point 'symbol))) (dumb-jump-issue-result "nosymbol")) ;; Otherwise, perform the search for the text identified by string specified ;; by ENTERED-NAME, point or region. (t (dumb-jump-fetch-file-results entered-name)))) (defun dumb-jump-fetch-shell-results (&optional entered-name) "Perform search from shell buffer for text at point, region or ENTERED-NAME. Return the dumb-jump alist result: - :results - :lang : string: language name - :symbol : string: symbol being searched - :ctx-type: string: - :file : string: file name - :root : string: project root." (let* ((cur-file (buffer-name)) (proj-root (dumb-jump-get-project-root default-directory)) (proj-config (dumb-jump-get-config proj-root)) (config (when (string-suffix-p ".dumbjump" proj-config) (dumb-jump-read-config proj-root proj-config))) (lang (or (plist-get config :language) (car (dumb-jump-get-lang-by-shell-contents (buffer-name)))))) (dumb-jump-fetch-results cur-file proj-root lang config entered-name))) (defun dumb-jump-fetch-file-results (&optional entered-name) "Perform a file search for text at point, region or ENTERED-NAME string. Return the dumb-jump alist result: - :results - :lang : string: language name - :symbol : string: symbol being searched - :ctx-type: string: - :file : string: file name - :root : string: project root." (let* ((cur-file (or (buffer-file-name) "")) (proj-root (dumb-jump-get-project-root cur-file)) (proj-config (dumb-jump-get-config proj-root)) (config (when (string-suffix-p ".dumbjump" proj-config) (dumb-jump-read-config proj-root proj-config))) (lang (or (plist-get config :language) (dumb-jump-get-language cur-file)))) (dumb-jump-fetch-results cur-file proj-root lang config entered-name))) ;; -- (defun dumb-jump-process-symbol-by-lang (lang look-for) "Process and potentially transform LANG's LOOK-FOR. For instance, remove clojure namespace prefix." (cond ((and (string= lang "commonlisp") (dumb-jump--contains-p ":" look-for) (not (string-prefix-p ":" look-for))) (nth 1 (dumb-jump--split ":" look-for 'omit-nulls))) ((and (string= lang "clojure") (dumb-jump--contains-p "/" look-for)) (nth 1 (dumb-jump--split "/" look-for))) ((and (string= lang "fennel") (dumb-jump--contains-p "." look-for)) (-last-item (dumb-jump--split "\\." look-for))) ((and (string= lang "ruby") (dumb-jump--contains-p "::" look-for)) (-last-item (dumb-jump--split "::" look-for))) ((and (or (string= lang "ruby") (string= lang "crystal")) (string-prefix-p ":" look-for)) (dumb-jump--chop-prefix ":" look-for)) ((and (string= lang "systemverilog") (string-prefix-p "`" look-for)) (dumb-jump--chop-prefix "`" look-for)) (t look-for))) (defun dumb-jump-get-point-line () "Get line at point." (if (version< emacs-version "24.4") (thing-at-point 'line) (thing-at-point 'line t))) (defun dumb-jump-get-point-symbol () "Get symbol at point." (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) (if (version< emacs-version "24.4") (thing-at-point 'symbol) (thing-at-point 'symbol t)))) (defun dumb-jump--get-symbol-start () "Get the start of symbol at point." (- (if (region-active-p) (region-beginning) (car (bounds-of-thing-at-point 'symbol))) (line-beginning-position))) (defun dumb-jump-get-lang-by-shell-contents (buffer) "Return languages in BUFFER by checking if file extension is mentioned." (let* ((buffer-contents (with-current-buffer buffer (buffer-string))) (found (--filter (dumb-jump--match (concat "\\." (regexp-quote (plist-get it :ext)) "\\b") buffer-contents) dumb-jump-language-file-exts))) (--map (plist-get it :language) found))) (defun dumb-jump-fetch-results (cur-file proj-root lang _config &optional entered-name) "Search for symbol in ENTERED-NAME or symbol at point. Return a list of results based on current file context and calling the currently selected searcher tool (grep, ag, rg, ...). CUR-FILE is the path of the current buffer. PROJ-ROOT is that file's root project directory. LANG is a string programming language with CONFIG a property list of project configuration. ENTERED-NAME is an optional string identifying item to search. The returned property list has the following members: - :results: - :lang : string: language name - :symbol : string: symbol being searched - :ctx-type: string: - :file : string: file name - :root : string: project root." (let* ((cur-line-num (line-number-at-pos)) (proj-config (dumb-jump-get-config proj-root)) (config (when (string-suffix-p ".dumbjump" proj-config) (dumb-jump-read-config proj-root proj-config))) (found-symbol (or entered-name (dumb-jump-get-point-symbol))) (look-for (dumb-jump-process-symbol-by-lang lang found-symbol)) (pt-ctx (if entered-name (get-text-property 0 :dumb-jump-ctx entered-name) (dumb-jump-get-point-context (dumb-jump-get-point-line) look-for (dumb-jump--get-symbol-start)))) (ctx-type (dumb-jump-get-ctx-type-by-language lang pt-ctx)) (gen-funcs (dumb-jump-pick-grep-variant proj-root)) (parse-fn (plist-get gen-funcs :parse)) ; dumb-jump-parse-TOOL-response (generate-fn (plist-get gen-funcs :generate)) (searcher (plist-get gen-funcs :searcher)) (regexes (dumb-jump-get-contextual-regexes lang ctx-type searcher)) (exclude-paths (when config (plist-get config :exclude))) (include-paths (when config (plist-get config :include))) ;; we will search proj root and all include paths (search-paths (-distinct (-concat (list proj-root) include-paths))) ;; run command for all (raw-results (--mapcat ;; TODO: should only pass exclude paths to actual project root (dumb-jump-run-command look-for it regexes lang exclude-paths cur-file cur-line-num parse-fn generate-fn) search-paths)) (results (delete-dups (--map (plist-put it :target look-for) raw-results)))) `(:results ,results :lang ,(if (null lang) "" lang) :symbol ,look-for :ctx-type ,(if (null ctx-type) "" ctx-type) :file ,cur-file :root ,proj-root))) ;;;###autoload (defun dumb-jump-back () "Jump back to where the last jump was done." ;; Note: made obsolete by Emacs `xref-pop-marker-stack'. (interactive) (with-demoted-errors "Error running `dumb-jump-before-jump-hook': %S" (run-hooks 'dumb-jump-before-jump-hook)) (pop-tag-mark) (with-demoted-errors "Error running `dumb-jump-after-jump-hook': %S" (run-hooks 'dumb-jump-after-jump-hook))) ;;;###autoload (defun dumb-jump-quick-look () "Run `dumb-jump-go' in quick look mode. That is, show a tooltip of where it would jump instead." ;; Note: independent of the Emacs xref interface. (interactive) (with-no-warnings (dumb-jump-go t))) ;;;###autoload (defun dumb-jump-go-other-window () "Like dumb-jump-go' but use `find-file-other-window' instead of `find-file'." ;; Note: independent of the Emacs xref interface. (interactive) (let ((dumb-jump-window 'other)) (with-no-warnings (dumb-jump-go)))) ;;;###autoload (defun dumb-jump-go-current-window () "Like `dumb-jump-go' but always use `find-file'." ;; Note: independent of the Emacs xref interface. (interactive) (let ((dumb-jump-window 'current)) (with-no-warnings (dumb-jump-go)))) ;;;###autoload (defun dumb-jump-go-prefer-external () "Like `dumb-jump-go' but prefer external matches from the current file." ;; Note: independent of the Emacs xref interface. (interactive) (with-no-warnings (dumb-jump-go nil t))) ;;;###autoload (defun dumb-jump-go-prompt () "Like `dumb-jump-go' but prompt for function instead of using under point." ;; Note: independent of the Emacs xref interface. (interactive) (with-no-warnings (dumb-jump-go nil nil (read-from-minibuffer "Jump to: ")))) ;;;###autoload (defun dumb-jump-go-prefer-external-other-window () "Like `dumb-jump-go-prefer-external' but create another window. It uses `find-file-other-window' instead of `find-file'." ;; Note: independent of the Emacs xref interface. (interactive) (let ((dumb-jump-window 'other)) (with-no-warnings (dumb-jump-go-prefer-external)))) ;;;###autoload (defun dumb-jump-go (&optional use-tooltip prefer-external entered-name) "Go to the function/variable declaration for thing at point. When USE-TOOLTIP is t a tooltip jump preview will show instead. When PREFER-EXTERNAL is t it will sort external matches before current file. The optional ENTERED-NAME string is the name of the item to jump to manually selected by user as response to a prompt." ;; Note: independent of the Emacs xref interface. (interactive "P") (let* ((start-time (float-time)) (info (dumb-jump-get-results entered-name)) (end-time (float-time)) (fetch-time (- end-time start-time)) (results (plist-get info :results)) (look-for (or entered-name (plist-get info :symbol))) (proj-root (plist-get info :root)) (issue (plist-get info :issue)) (lang (plist-get info :lang)) (result-count (length results))) (when (> fetch-time dumb-jump-max-find-time) (dumb-jump-message "Took over %ss to find '%s'. \ Please install ag or rg, or add a .dumbjump file to '%s' with path exclusions" (number-to-string dumb-jump-max-find-time) look-for proj-root)) (cond ((eq issue 'nogrep) (dumb-jump-message "Please install ag, rg, git grep or grep!")) ((eq issue 'nosymbol) (dumb-jump-message "No symbol under point.")) ((string-suffix-p " file" lang) (dumb-jump-message "Could not find rules for '%s'." lang)) ((= result-count 1) (dumb-jump-result-follow (car results) use-tooltip proj-root)) ((> result-count 1) ;; multiple results so let the user pick from a list ;; unless the match is in the current file (dumb-jump-handle-results results (plist-get info :file) proj-root (plist-get info :ctx-type) look-for use-tooltip prefer-external lang)) ((= result-count 0) (dumb-jump-message "'%s' %s %s declaration not found." look-for (if (string-blank-p (or lang "")) "with unknown language so" lang) (plist-get info :ctx-type)))))) (defcustom dumb-jump-language-comments '((:comment "//" :language "c++") (:comment "/*" :language "c++") (:comment ";" :language "elisp") (:comment ";" :language "commonlisp") (:comment "//" :language "javascript") (:comment "//" :language "typescript") (:comment "//" :language "dart") (:comment "//" :language "dlang") (:comment "/*" :language "dlang") (:comment "/+" :language "dlang") (:comment "--" :language "haskell") (:comment "--" :language "lua") (:comment "//" :language "rust") (:comment "#" :language "julia") (:comment "//" :language "objc") (:comment "//" :language "csharp") (:comment "//" :language "java") (:comment ";" :language "clojure") (:comment "#" :language "coffeescript") (:comment "//" :language "faust") (:comment ";" :language "fennel") (:comment "!" :language "fortran") (:comment "//" :language "go") (:comment "//" :language "zig") (:comment "#" :language "perl") (:comment "#" :language "tcl") (:comment "//" :language "php") (:comment "#" :language "php") (:comment "--" :language "purescript") (:comment "#" :language "python") (:comment "%" :language "matlab") (:comment "#" :language "r") (:comment ";" :language "racket") (:comment "#" :language "ruby") (:comment "#" :language "crystal") (:comment "#" :language "nim") (:comment "#" :language "nix") (:comment "//" :language "scala") (:comment ";" :language "scheme") (:comment "#" :language "janet") (:comment "#" :language "shell") (:comment "//" :language "solidity") (:comment "//" :language "swift") (:comment "#" :language "elixir") (:comment "%" :language "erlang") (:comment "%" :language "tex") (:comment "//" :language "systemverilog") (:comment "--" :language "vhdl") (:comment "//" :language "scss") (:comment "//" :language "pascal") (:comment "//" :language "protobuf") (:comment "#" :language "hcl") (:comment "//" :language "apex") (:comment "*>" :language "cobol")) "List of one-line comments organized by language. A language may have more than 1 comment string." :group 'dumb-jump :type '(repeat (plist :options ((:comment string) (:language string))))) (defun dumb-jump-get-comment-by-language (lang) "Return a list of the one-line comment or comments for the given LANG." (let* ((entries (-distinct (--filter (string= (plist-get it :language) lang) dumb-jump-language-comments)))) (if (> (length entries) 0) (mapcar (lambda (pl) (plist-get pl :comment)) entries) nil))) (defun dumb-jump--context-startswith-comment (context-string comments) "Return t when CONTEXT-STRING starts with any COMMENTS string." (let ((startswith-comment nil) ;; trim leading white-space from context-string (context-str (replace-regexp-in-string "^\\s-+" "" context-string))) (catch 'found-one (dolist (comment comments) (when (string-prefix-p comment context-str) (setq startswith-comment t) (throw 'found-one nil)))) startswith-comment)) (defun dumb-jump-filter-no-start-comments (results lang) "Filter out RESULTS with a :context starting with a LANG comment in file." (let ((comments (dumb-jump-get-comment-by-language lang))) (if comments (-concat (--filter (not (dumb-jump--context-startswith-comment (plist-get it :context) comments)) results)) results))) (defun dumb-jump-handle-results (results cur-file proj-root ctx-type look-for use-tooltip prefer-external &optional language) "Handle the searchers results. RESULTS is a list of property lists with the searcher's results. CUR-FILE is the current file within PROJ-ROOT. CTX-TYPE is a string of the current context. LOOK-FOR is the symbol we're jumping for. USE-TOOLTIP shows a preview instead of jumping. PREFER-EXTERNAL will sort current file last. LANGUAGE is an optional language to pass to `dumb-jump-process-results'." (let* ((processed (dumb-jump-process-results results cur-file proj-root ctx-type look-for use-tooltip prefer-external language)) (results (plist-get processed :results)) (do-var-jump (plist-get processed :do-var-jump)) (var-to-jump (plist-get processed :var-to-jump)) (match-cur-file-front (plist-get processed :match-cur-file-front))) (dumb-jump-debug-message look-for ctx-type var-to-jump (pp-to-string match-cur-file-front) (pp-to-string results) prefer-external proj-root cur-file) (cond (use-tooltip ;; quick-look mode (let* ((choices (--map (dumb-jump--format-result proj-root it) results)) (selected-choice (dumb-jump--select-choice choices "Matches: ")) (selected-result (cdr (assoc selected-choice (-zip-pair choices results))))) (when selected-result (dumb-jump--show-preview (dumb-jump--format-result proj-root selected-result))))) (do-var-jump (dumb-jump-result-follow var-to-jump use-tooltip proj-root)) (t (dumb-jump-prompt-user-for-choice proj-root match-cur-file-front))))) (defun dumb-jump--candidate-x (plist-get it :diff) 0) (or (string= (plist-get it :path) cur-file) (string= (plist-get it :path) rel-cur-file))) match-no-comments) (--filter (and (<= (plist-get it :diff) 0) (or (string= (plist-get it :path) cur-file) (string= (plist-get it :path) rel-cur-file))) match-no-comments) ;; Sort non-current files by path length so the nearest file is ;; more likely to be sorted higher to the top. Also sorts by ;; line number for sanity. (-sort #'dumb-jump--candidate-x (length line-num-raw) 1) (nth 1 line-num-raw)))) (cond ;; fixes rare bug where context is blank but file is defined "/somepath/file.txt:14:" ;; OR: (and (= (length parts) 1) (file-name-exists (nth 0 parts))) ((dumb-jump--match ":[0-9]+:$" resp-line) nil) ((and parts line-num) (if (= (length parts) 2) (list (let ((path (expand-file-name (nth 0 parts)))) (if (file-name-absolute-p (nth 0 parts)) path (file-relative-name path))) line-num (nth 1 parts)) ; this case is when they are searching a particular file... (list (let ((path (expand-file-name cur-file))) (if (file-name-absolute-p cur-file) path (file-relative-name path))) line-num (nth 0 parts))))))) ;; -- ;; Parse Search Tool Results: indirectly called by `dumb-jump-run-command' ;; ----------------------------------------------------------------------- ;; - `dumb-jump-parse-grep-response' ;; - `dumb-jump-parse-ag-response' ;; - `dumb-jump-parse-rg-response' ;; - `dumb-jump-parse-git-grep-response' ;; - `dumb-jump-parse-response-lines' (defun dumb-jump-parse-response-lines (parsed cur-file cur-line-num) "Turn PARSED response lines into a list of property lists. Using CUR-FILE and CUR-LINE-NUM to exclude jump origin." (let* ((records (--mapcat (when it (let* ((line-num (string-to-number (nth 1 it))) (diff (- cur-line-num line-num))) (list `(:path ,(nth 0 it) :line ,line-num :context ,(nth 2 it) :diff ,diff)))) parsed)) (results (-non-nil records))) (--filter (not (and (string= (plist-get it :path) cur-file) (= (plist-get it :line) cur-line-num))) results))) (defun dumb-jump-parse-grep-response (resp cur-file cur-line-num) "Parse raw grep search response RESP into a list of plists. - CUR-FILE: current file. - CUR-LINE-NUM: current line number." (let* ((resp-no-warnings (--filter (and (not (string-prefix-p "grep:" it)) (not (dumb-jump--contains-p "No such file or" it))) (dumb-jump--split "\n" (dumb-jump--trim resp)))) (parsed (--map (dumb-jump-parse-response-line it cur-file) resp-no-warnings))) (dumb-jump-parse-response-lines parsed cur-file cur-line-num))) (defun dumb-jump-parse-ag-response (resp cur-file cur-line-num) "Parse raw ag search response RESP into a list of plists. - CUR-FILE: current file. - CUR-LINE-NUM: current line number." (let* ((resp-lines (dumb-jump--split "\n" (dumb-jump--trim resp))) (parsed (--map (dumb-jump-parse-response-line it cur-file) resp-lines))) (dumb-jump-parse-response-lines parsed cur-file cur-line-num))) (defun dumb-jump-parse-rg-response (resp cur-file cur-line-num) "Parse raw rg search response RESP into a list of plists. - CUR-FILE: current file. - CUR-LINE-NUM: current line number." (let* ((resp-lines (dumb-jump--split "\n" (dumb-jump--trim resp))) (parsed (--map (dumb-jump-parse-response-line it cur-file) resp-lines))) (dumb-jump-parse-response-lines parsed cur-file cur-line-num))) (defun dumb-jump-parse-git-grep-response (resp cur-file cur-line-num) "Parse raw git grep response RESP into a list of plists. - CUR-FILE: current file. - CUR-LINE-NUM: current line number." (let* ((resp-lines (dumb-jump--split "\n" (dumb-jump--trim resp))) (parsed (--map (dumb-jump-parse-response-line it cur-file) resp-lines))) (dumb-jump-parse-response-lines parsed cur-file cur-line-num))) ;; -- (defun dumb-jump-re-match (re s) "Does regular expression RE match string S. If RE is nil return nil." (when (and re s) (dumb-jump--match re s))) (defun dumb-jump-get-ctx-type-by-language (lang pt-ctx) "Detect the type of context by the language LANG and its context PT-CTX. PT-CTX is assumed to be a property list with the :left and :right attributes that are both strings." (let* ((contexts (--filter (string= (plist-get it ':language) lang) dumb-jump-language-contexts)) (usable-ctxs (when (> (length contexts) 0) (--filter (and (or (null (plist-get it :left)) (dumb-jump-re-match (plist-get it :left) (plist-get pt-ctx :left))) (or (null (plist-get it :right)) (dumb-jump-re-match (plist-get it :right) (plist-get pt-ctx :right)))) contexts))) (use-ctx (= (length (--filter (string= (plist-get it ':type) (and usable-ctxs (plist-get (car usable-ctxs) :type))) usable-ctxs)) (length usable-ctxs)))) (when (and usable-ctxs use-ctx) (plist-get (car usable-ctxs) :type)))) (defun dumb-jump-get-ext-includes (language) "Return the --include grep argument of file extensions for LANGUAGE." (let ((exts (dumb-jump-get-file-exts-by-language language))) (dumb-jump-arg-joiner "--include" (--map (format "\\*.%s" it) exts)))) (defun dumb-jump-arg-joiner (prefix values) "Helper to generate command arg with its PREFIX for each value in VALUES." (let* ((normalized-values (--map (dumb-jump--trim (or it "")) values)) (non-empty-values (--filter (> (length it) 0) normalized-values)) (args (dumb-jump--join (format " %s " prefix) non-empty-values))) (if non-empty-values (format " %s %s " prefix args) ""))) (defun dumb-jump-get-contextual-regexes (lang ctx-type searcher) "Get list of search regular expressions by LANG and CTX-TYPE. The arguments are: - LANG: string: the language. - CTX-TYPE: variable, function, etc. - SEARCHER: symbol: the name of the search tool. One of: git-grep, ag, git-grep-plus-ag, rg, gnu-grep, grep." (let* ((raw-rules (dumb-jump-get-rules-by-language lang searcher)) (ctx-type (unless dumb-jump-ignore-context ctx-type)) (ctx-rules (if ctx-type (--filter (string= (plist-get it :type) ctx-type) raw-rules) raw-rules)) (rules (or ctx-rules raw-rules)) (regexes (--map (plist-get it :regex) rules))) regexes)) (defun dumb-jump-populate-regex (it look-for variant) "Populate IT regex template with LOOK-FOR for the specific search VARIANT. Replace the dumb-jump generic regular expression meta concepts with the one required for the search variant tool. The arguments are: - IT : string: the dumb-jump generic regular expression. - LOOK-FOR: string: the searched item. - VARIANT : symbol: the search tool variant, one of: ag, rg, grep, gnu-grep, git-grep-plus-ag, git-grep." (let ((boundary (cond ((eq variant 'rg) dumb-jump-rg-word-boundary) ((eq variant 'ag) dumb-jump-ag-word-boundary) ((eq variant 'git-grep-plus-ag) dumb-jump-ag-word-boundary) ((eq variant 'git-grep) dumb-jump-git-grep-word-boundary) (t dumb-jump-grep-word-boundary)))) (let ((text it)) (setq text (dumb-jump--replace "\\j" boundary text)) (when (dumb-jump-use-space-bracket-exp-for variant) (setq text (dumb-jump--replace "\\s" "[[:space:]]" text))) (setq text (dumb-jump--replace "JJJ" (regexp-quote look-for) text)) text))) (defun dumb-jump-populate-regexes (look-for regexes variant) "Return list of VARIANT specific regexes from the dumb-jump generic REGEXES. Update the generic regexes, populate the target identified in LOOK-FOR. The arguments are: - LOOK-FOR: string: the searched item. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - VARIANT: symbol: the search tool variant, one of: ag, rg, git-grep-plus-ag, git-grep." (--map (dumb-jump-populate-regex it look-for variant) regexes)) ;; -- (defun dumb-jump-generate-ag-command (look-for cur-file proj regexes lang exclude-paths) "Return the ag command to search for LOOK-FOR in the PROJ directory. The arguments are: - LOOK-FOR: string: the searched item. - CUR-FILE: string: current file name. Used to check if it's compressed. - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE-PATHS: list of strings: directories to exclude from search." (let* ((filled-regexes (dumb-jump-populate-regexes look-for regexes 'ag)) (agtypes (dumb-jump-get-ag-type-by-language lang)) (lang-exts (dumb-jump-get-file-exts-by-language lang)) (proj-dir (file-name-as-directory proj)) ;; TODO: --search-zip always? in case the include is the in gz area ;; like emacs lisp code. (cmd (concat dumb-jump-ag-cmd " --nocolor --nogroup" (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "") (if (string-suffix-p ".gz" cur-file) " --search-zip" "") (unless (string-blank-p dumb-jump-ag-search-args) (concat " " dumb-jump-ag-search-args)) (if agtypes (dumb-jump--join "" (--map (format " --%s" it) agtypes)) ;; there can only be one `-G` arg (concat " -G '(" (dumb-jump--join "|" (--map (format "\\.%s" it) lang-exts)) ")$'")))) (exclude-args (dumb-jump-arg-joiner "--ignore-dir" (--map (shell-quote-argument (dumb-jump--replace proj-dir "" it)) exclude-paths))) (regex-args (shell-quote-argument (dumb-jump--join "|" filled-regexes)))) (if (null regexes) "" (dumb-jump-concat-command cmd exclude-args "--" regex-args proj)))) ;; -- (defun dumb-jump-get-git-grep-files-matching-symbol (symbol proj-root) "Return a list of file names in PROJ-ROOT holding the literal SYMBOL. Search for matching files using git grep." (let* ((cmd (format "git grep --full-name -F -c %s %s" (shell-quote-argument symbol) proj-root)) (result (dumb-jump--trim (shell-command-to-string cmd))) ;; result: '\n\ separated lines of: "path-name:count" ;; extract the name of files and return them in a list. (matched-files (--map (cl-first (dumb-jump--split ":" it)) (dumb-jump--split "\n" result)))) matched-files)) (defun dumb-jump-format-files-as-ag-arg (files proj-root) "Take a list of FILES and their PROJ-ROOT and return a `ag -G` argument." (format "'(%s)'" (dumb-jump--join "|" (--map (file-relative-name (expand-file-name it proj-root)) files)))) (defun dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg (symbol proj-root) "Return optimized `ag -G` argument string to search for SYMBOL in PROJ-ROOT. Limit the ag search to files matching SYMBOL in PROJ-ROOT by first getting the list of files with `git grep`. The string does not contain the `ag -G`, just its argument." (dumb-jump-format-files-as-ag-arg (dumb-jump-get-git-grep-files-matching-symbol symbol proj-root) proj-root)) ;; git-grep plus ag only recommended for huge repos like the linux kernel. (defun dumb-jump-generate-git-grep-plus-ag-command (look-for cur-file proj regexes lang exclude-paths) "Return the ag command to search for LOOK-FOR in the PROJ directory. Using ag to search only the files found via git-grep literal symbol search. Note: Only recommended for huge repos like the linux kernel. The arguments are: - LOOK-FOR: string: the searched text - CUR-FILE: - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE_PATHS: list of strings: directories to exclude from search." (let* ((filled-regexes (dumb-jump-populate-regexes look-for regexes 'ag)) (proj-dir (file-name-as-directory proj)) (ag-files-arg (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg look-for proj-dir)) (cmd (concat dumb-jump-ag-cmd " --nocolor --nogroup" (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "") (if (string-suffix-p ".gz" cur-file) " --search-zip" "") " -G " ag-files-arg " ")) (exclude-args (dumb-jump-arg-joiner "--ignore-dir" (--map (shell-quote-argument (dumb-jump--replace proj-dir "" it)) exclude-paths))) (regex-args (shell-quote-argument (dumb-jump--join "|" filled-regexes)))) (if (null regexes) "" (dumb-jump-concat-command cmd exclude-args regex-args proj)))) ;; -- (defun dumb-jump-generate-rg-command (look-for _cur-file proj regexes lang exclude-paths) "Return the rg command to search for LOOK-FOR in the PROJ directory. The arguments are: - LOOK-FOR: string: the searched item. - CUR-FILE: - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE-PATHS: list of strings: directories to exclude from search." (let* ((filled-regexes (dumb-jump-populate-regexes look-for regexes 'rg)) (rgtypes (dumb-jump-get-rg-type-by-language lang)) (proj-dir (file-name-as-directory proj)) (cmd (concat dumb-jump-rg-cmd " --color never --no-heading --line-number -U" (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "") (unless (string-blank-p dumb-jump-rg-search-args) (concat " " dumb-jump-rg-search-args)) (dumb-jump--join "" (--map (format " --type %s" it) rgtypes)))) (exclude-args (dumb-jump-arg-joiner "-g" (--map (shell-quote-argument (concat "!" (dumb-jump--replace proj-dir "" it))) exclude-paths))) (regex-args (shell-quote-argument (dumb-jump--join "|" filled-regexes)))) (if (null regexes) "" (dumb-jump-concat-command cmd exclude-args "--" regex-args proj)))) (defun dumb-jump-generate-git-grep-command (look-for cur-file proj regexes lang exclude-paths) "Return the git grep command to search for LOOK-FOR in the PROJ directory. The arguments are: - LOOK-FOR: string: the searched text - CUR-FILE: string: current file name. Used to check the file extension and restrict search to file extensions of the matching LANG. - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE_PATHS:list of strings: directories to exclude from search." (let* ((filled-regexes (dumb-jump-populate-regexes look-for regexes 'git-grep)) (ggtypes (when (file-name-extension cur-file) (dumb-jump-get-git-grep-type-by-language lang))) (cmd (concat dumb-jump-git-grep-cmd " --color=never --line-number" (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "") (when dumb-jump-git-grep-search-untracked " --untracked") (unless (string-blank-p dumb-jump-git-grep-search-args) (concat " " dumb-jump-git-grep-search-args)) " -E")) (fileexps (dumb-jump--join " " (or (--map (shell-quote-argument (format "%s/*.%s" proj it)) ggtypes) '(":/")))) (exclude-args (dumb-jump--join " " (--map (shell-quote-argument (concat ":(exclude)" it)) exclude-paths))) (regex-args (shell-quote-argument (dumb-jump--join "|" filled-regexes)))) (if (null regexes) "" (dumb-jump-concat-command cmd regex-args "--" fileexps exclude-args)))) (defun dumb-jump-generate-grep-command (look-for cur-file proj regexes lang exclude-paths) "Return the grep command to search for LOOK-FOR in PROJ directory. The arguments are: - LOOK-FOR: string: the searched item. - CUR-FILE: string: current file name. Used to check if it's compressed. - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE-PATHS: list of strings: directories to exclude from search." (let* ((filled-regexes (--map (shell-quote-argument it) (dumb-jump-populate-regexes look-for regexes 'grep))) (cmd (concat (if (eq system-type 'windows-nt) "" (concat dumb-jump-grep-prefix " ")) (if (string-suffix-p ".gz" cur-file) dumb-jump-zgrep-cmd dumb-jump-grep-cmd))) (case-args (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "")) (exclude-args (dumb-jump-arg-joiner "--exclude-dir" exclude-paths)) (include-args (dumb-jump-get-ext-includes lang)) (regex-args (dumb-jump-arg-joiner "-e" filled-regexes))) (if (null regexes) "" (dumb-jump-concat-command cmd dumb-jump-grep-args case-args exclude-args include-args regex-args proj)))) (defun dumb-jump-generate-gnu-grep-command (look-for cur-file proj regexes lang _exclude-paths) "Return the GNU grep command to search for LOOK-FOR in PROJ directory. The arguments are: - LOOK-FOR: string: the searched item. - CUR-FILE: string: current file name. Used to check if it's compressed. - PROJ: string: project root path. - REGEXES: list of strings: each string is a dumb-jump generic regular expression. - LANG: string: handled language. - EXCLUDE-PATHS: list of strings: directories to exclude from search." (let* ((filled-regexes (--map (shell-quote-argument it) (dumb-jump-populate-regexes look-for regexes 'gnu-grep))) (cmd (concat (if (eq system-type 'windows-nt) "" (concat dumb-jump-grep-prefix " ")) (if (string-suffix-p ".gz" cur-file) dumb-jump-zgrep-cmd dumb-jump-grep-cmd))) (case-args (if (member lang dumb-jump--case-insensitive-languages) " --ignore-case" "")) ;; TODO: GNU grep doesn't support these, so skip them (exclude-args "") (include-args "") (regex-args (dumb-jump-arg-joiner "-e" filled-regexes))) (if (null regexes) "" (dumb-jump-concat-command cmd dumb-jump-gnu-grep-args case-args exclude-args include-args regex-args proj)))) ;; --------------------------------------------------------------------------- (defun dumb-jump-concat-command (&rest parts) "Concat the PARTS of a command if each part has a length." (let* ((normalized-parts (--map (dumb-jump--trim (or it "")) parts)) (non-empty-parts (--filter (> (length it) 0) normalized-parts))) (dumb-jump--join " " non-empty-parts))) (defun dumb-jump-get-file-exts-by-language (language) "Return list of file extensions for a LANGUAGE." (--map (plist-get it :ext) (--filter (string= (plist-get it :language) language) dumb-jump-language-file-exts))) (defun dumb-jump-get-ag-type-by-language (language) "Return list of ag type argument for a LANGUAGE." (-distinct (--map (plist-get it :agtype) (--filter (and (plist-get it :agtype) (string= (plist-get it :language) language)) dumb-jump-language-file-exts)))) (defun dumb-jump-get-rg-type-by-language (language) "Return list of rg type argument for a LANGUAGE." (-distinct (--map (plist-get it :rgtype) (--filter (and (plist-get it :rgtype) (string= (plist-get it :language) language)) dumb-jump-language-file-exts)))) (defun dumb-jump-get-git-grep-type-by-language (language) "Return list of git grep type argument for a LANGUAGE." (-distinct (--map (plist-get it :ext) (--filter (and (plist-get it :ext) (string= (plist-get it :language) language)) dumb-jump-language-file-exts)))) (defun dumb-jump-get-rules-by-language (language searcher) "Return a list of rules for the LANGUAGE by SEARCHER." (let* ((searcher-str (cond ((eq 'git-grep searcher) "git-grep") ((eq 'rg searcher) "rg") ((eq 'ag searcher) "ag") ((eq 'git-grep-plus-ag searcher) "ag") (t "grep"))) (results (--filter (and (string= (plist-get it ':language) language) (member searcher-str (plist-get it ':supports))) dumb-jump-find-rules))) (if dumb-jump-functions-only (--filter (string= (plist-get it ':type) "function") results) results))) ;;;###autoload (define-minor-mode dumb-jump-mode "Minor mode for jumping to variable and function definitions." ;; Note: independent of the Emacs xref interface. :global t :keymap dumb-jump-mode-map) ;; ----------------------------------------------------------------------------- ;;; Xref Backend (when (featurep 'xref) (unless dumb-jump-disable-obsolete-warnings (dolist (obsolete '(dumb-jump-mode dumb-jump-go dumb-jump-go-prefer-external-other-window dumb-jump-go-prompt dumb-jump-quick-look dumb-jump-go-other-window dumb-jump-go-current-window dumb-jump-go-prefer-external dumb-jump-go-current-window)) (make-obsolete obsolete (format "`%s' has been obsoleted by the xref interface." obsolete) "2020-06-26")) (make-obsolete 'dumb-jump-back "`dumb-jump-back' has been obsoleted by `xref-pop-marker-stack'." "2020-06-26")) (cl-defmethod xref-backend-identifier-at-point ((_backend (eql dumb-jump))) (let ((bounds (bounds-of-thing-at-point 'symbol))) (and bounds (let* ((ident (dumb-jump-get-point-symbol)) (start (car bounds)) (col (- start (line-beginning-position))) (line (dumb-jump-get-point-line)) (ctx (dumb-jump-get-point-context line ident col))) (propertize ident :dumb-jump-ctx ctx))))) (cl-defmethod xref-backend-definitions ((_backend (eql dumb-jump)) entered-name) (let* ((info (dumb-jump-get-results entered-name)) (results (plist-get info :results)) (look-for (or entered-name (plist-get info :symbol))) (proj-root (plist-get info :root)) (issue (plist-get info :issue)) (lang (plist-get info :lang)) (processed (dumb-jump-process-results results (plist-get info :file) proj-root (plist-get info :ctx-type) look-for nil nil lang)) (results (plist-get processed :results)) (do-var-jump (plist-get processed :do-var-jump)) (var-to-jump (plist-get processed :var-to-jump)) (match-cur-file-front (plist-get processed :match-cur-file-front))) (dumb-jump-debug-message look-for (plist-get info :ctx-type) var-to-jump (pp-to-string match-cur-file-front) (pp-to-string results) match-cur-file-front proj-root (plist-get info :file)) (cond ((eq issue 'nogrep) (dumb-jump-message "Please install ag, rg, git grep or grep!")) ((eq issue 'nosymbol) (dumb-jump-message "No symbol under point.")) ((string-suffix-p " file" lang) (dumb-jump-message "Could not find rules for '%s'." lang)) ((= (length results) 0) (dumb-jump-message "'%s' %s %s declaration not found." look-for (if (string-blank-p (or lang "")) "with unknown language so" lang) (plist-get info :ctx-type))) (t (mapcar (lambda (res) (with-no-warnings (xref-make (plist-get res :context) (xref-make-file-location (let* ((path (plist-get res :path)) (remote-prefix (file-remote-p default-directory))) (if remote-prefix (if (file-name-absolute-p path) (concat remote-prefix path) (concat default-directory path)) (expand-file-name path))) (plist-get res :line) 0)))) (if do-var-jump (list var-to-jump) match-cur-file-front)))))) (cl-defmethod xref-backend-apropos ((_backend (eql dumb-jump)) pattern) (xref-backend-definitions 'dumb-jump pattern)) (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql dumb-jump))) nil)) ;;;###autoload (defun dumb-jump-xref-activate () "Function to activate xref backend. Add this function to `xref-backend-functions' to dumb jump to be activated, whenever it finds a project. It is recommended to add it to the end, so that it only gets activated when no better option is found." (and (dumb-jump-get-project-root default-directory) 'dumb-jump)) (provide 'dumb-jump) ;;; dumb-jump.el ends here jacktasia-dumb-jump-d345e21/gnu.mk000066400000000000000000000041311514775430200170240ustar00rootroot00000000000000# MAKEFILE FILE: gnu.mk # # Purpose : GNU Make compatible logic, conditionally included in Makefile. # ---------------------------------------------------------------------------- # Special rules for: 'make test-this' and 'make test-this-docker' # ---------------------------------------------------------------- # # When the first target is test-this or test-this-docker, the following # arguments on make command line are interpreted as names of ERT test # functions and passed as a single -p regex to ert-runner. # # The following logic builds a properly formatted string in the TEST_NAMES # variable by first building a space-separated list of test names in the # TEST_NAMES_LIST variables and then replaces the spaces by the \| separator. # The special empty and space variables are first required to create a # variable that holds one space character. There must NOT be any trailing # spaces inside this file (and that should always be the case in Make files)! # ---------------------------------------------------------------------------- # Code # ---- # CASK ?= cask empty := space := $(empty) $(empty) # If the first argument is "test-this" or "test-this-docker", execute the # specified test(s). ifneq ($(filter test-this test-this-docker,$(firstword $(MAKECMDGOALS))),) # use remaining goals as test-name arguments TEST_NAMES_LIST := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) TEST_NAMES := $(subst $(space),\|,$(TEST_NAMES_LIST)) # ...and turn them into do-nothing targets when there are some. ifneq ($(strip $(TEST_NAMES_LIST)),) $(eval $(TEST_NAMES_LIST):;@:) endif endif .PHONY: test-this test-this-docker test-this: .cask ifeq ($(strip $(TEST_NAMES)),) @printf -- "ERROR: No test names provided after test-this. Aborting.\n" @exit 1 else ${CASK} exec ert-runner -p "$(TEST_NAMES)" endif test-this-docker: ifeq ($(strip $(TEST_NAMES)),) @printf -- "ERROR: No test names provided after test-this-docker. Aborting.\n" @exit 1 else @bash test/run-tests-locally.sh "$(EMACS_VERSION)" "$(TEST_NAMES)" endif # ---------------------------------------------------------------------------- jacktasia-dumb-jump-d345e21/media/000077500000000000000000000000001514775430200167625ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/media/dumb-jump-example-v2.gif000066400000000000000000002627641514775430200233500ustar00rootroot00000000000000GIF89adw! NETSCAPE2.0!<,d ' )7/- (*6N/[.n()G')V+3H*9V4*F5,T79G5;T'1kC+r!AN'KI&J]&W\9DZ9WJ&Jb+B|&Wdw;: (;~<nRɀ$%r!(HT @#V@ :X! (W%?$:ʹd $Ӓ?ԍ>>⋃E O>t5-Ӈ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f|E9E8C7G]-%`!^jpR g,?̐ĝ60t(*6;*6()F()R'=R''o'(f'&~&Je:We9avJ*6J=5V)5b)6r)5|)5V'Q`K4|K4JKEJKQVanaKDaWQja[jkdjkmjkujs|{sc{sm{{|';':&I&I%UUHT_76FT_hhrFSRoyx)4=4=4)4=3<3K3K3W2a1kOr,{{{MzaƍLΒKʒVΙVΟ_ř`͘`sߪH۪^y{{Ɓ݈Ӗϖׁሿ׉߀ϮܻΫدӰĺɿѹŚĥɶĻͶʌ̔ΟӓәؘɻۿܪH*\Ȱ@*PpHb7dATH"u6 qIV(TJmdJE2RLY* #VP&(<F3&hNFX}X(r@ Uqd%@`e`ܹu8#+HȒ"pxȀuc+lD`h D,A Cs*AW 1c-ci-cask to add the search tools (ag, ripgrep) # that dumb-jump's tests require. # # silex/emacs images ship with Emacs, git, make, and Cask pre-installed. # The EMACS_VERSION build arg selects which Emacs version to bake in. # # All silex/emacs images are amd64 Linux. On Apple Silicon, Docker Desktop # runs them transparently via Rosetta 2 (--platform linux/amd64). # # Supported EMACS_VERSION values (available silex/emacs:-ci-cask tags): # 26.3 27.2 28.2 29.4 30.2 # # Usage (handled automatically by test/run-tests-locally.sh): # make test-docker # make test-docker EMACS_VERSION=28.2 # Default version matches the most recent stable in the CI matrix. ARG EMACS_VERSION=29.4 # Pin to linux/amd64: silex/emacs images are amd64-only; Docker Desktop on # Apple Silicon emulates this via Rosetta 2. FROM --platform=linux/amd64 silex/emacs:${EMACS_VERSION}-ci-cask # ── Search tools ────────────────────────────────────────────────────────────── # dumb-jump tests exercise ag (The Silver Searcher) and ripgrep. # Install from the Debian repos included in the silex base image. RUN apt-get -qq update \ && apt-get install -y --no-install-recommends \ silversearcher-ag \ ripgrep \ && rm -rf /var/lib/apt/lists/* # ── Workspace snapshot ──────────────────────────────────────────────────────── # Copy the repository into the image so tests run against an internal filesystem # instead of a host bind mount (significantly faster on Docker Desktop/macOS). WORKDIR /repo # Install Emacs package dependencies at build time and cache them by Cask file. # This avoids running `cask install` every container start. COPY Cask /repo/Cask COPY dumb-jump.el /repo/dumb-jump.el RUN PATH="/nix/store/emacs/bin:/root/.cask/bin:${PATH}" cask install COPY . /repo # ── Entrypoint ──────────────────────────────────────────────────────────────── COPY test/run-in-container.sh /run-in-container.sh RUN chmod +x /run-in-container.sh ENTRYPOINT ["/run-in-container.sh"] jacktasia-dumb-jump-d345e21/test/data/000077500000000000000000000000001514775430200175735ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/fake-library/000077500000000000000000000000001514775430200221435ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/fake-library/lib.el000066400000000000000000000002101514775430200232240ustar00rootroot00000000000000;;; -*- lexical-binding: t -*- ;; for a fake lib +path in config file (defun func-in-lib (arg1 arg2) (message "%s is %s" arg1 arg2)) jacktasia-dumb-jump-d345e21/test/data/multiproj/000077500000000000000000000000001514775430200216205ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/.dumbjump000066400000000000000000000000001514775430200234320ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj1/000077500000000000000000000000001514775430200233655ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj1/.dumbjumpignore000066400000000000000000000000001514775430200264030ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj1/main.cc000066400000000000000000000001401514775430200246130ustar00rootroot00000000000000#include "../subproj2/header.h" int main(int argc, char **argv) { return Awesome::magic(); } jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj2/000077500000000000000000000000001514775430200233665ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj2/.dumbjumpignore000066400000000000000000000000001514775430200264040ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/multiproj/subproj2/header.h000066400000000000000000000003061514775430200247660ustar00rootroot00000000000000#ifndef TEST_DATA_MULTIPROJ_SUBPROJ2_HEADER_H #define TEST_DATA_MULTIPROJ_SUBPROJ2_HEADER_H class Awesome { public: int magic() { return 42; } }; #endif // TEST_DATA_MULTIPROJ_SUBPROJ2_HEADER_H jacktasia-dumb-jump-d345e21/test/data/proj1/000077500000000000000000000000001514775430200206265ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/.dumbjump000066400000000000000000000000231514775430200224450ustar00rootroot00000000000000-ignored -/ignored2jacktasia-dumb-jump-d345e21/test/data/proj1/.dumbjump-blank000066400000000000000000000000001514775430200235250ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/.dumbjump-include000066400000000000000000000000441514775430200240710ustar00rootroot00000000000000+../fake-library +/etc/var/some/codejacktasia-dumb-jump-d345e21/test/data/proj1/.dumbjump-lang000066400000000000000000000000451514775430200233700ustar00rootroot00000000000000+whatever -whatever2 language pythonjacktasia-dumb-jump-d345e21/test/data/proj1/ignored/000077500000000000000000000000001514775430200222555ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/ignored/fake.js000066400000000000000000000001031514775430200235130ustar00rootroot00000000000000'use strict'; function doSomeStuff() { alert('we did it!'); } jacktasia-dumb-jump-d345e21/test/data/proj1/src/000077500000000000000000000000001514775430200214155ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/000077500000000000000000000000001514775430200221775ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/external.cpp000066400000000000000000000002161514775430200245240ustar00rootroot00000000000000#include "external.h" int ExternalThing() { return 0; } class ExternalThing { }; int main(int argc, char **argv) { ExternalThing et; } jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/external.h000066400000000000000000000002261514775430200241720ustar00rootroot00000000000000#ifndef PROJ1_SRC_CPP_EXTERNAL_H #define PROJ1_SRC_CPP_EXTERNAL_H class ExternalThing { public: void foo(); }; #endif // PROJ1_SRC_CPP_EXTERNAL_H jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/issue-87.cpp000066400000000000000000000015401514775430200242670ustar00rootroot00000000000000// -------------------------------------------------------------------------- // CAdaptiveCaching::_processPixelOverlap() // -------------------------------------------------------------------------- template int CAdaptiveCaching::_processPixelOverlap(const CHitInfoLite &hit, const float *directIllum, const float thresholdElevation, TContribArray &carray, CRCOctree *octree) { } if(_adaptive && !pixContribs.ProcessPixelDone()) { _extrapolateRadianceValid(pixContribs,hit); _processPixelOverlap(hit,hit.directIllum.data(), 1/*thrElevImage[idx]*/,pixContribs,GetOctree()); pixContribs.SetProcessPixelDone(); } jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/only.cpp000066400000000000000000000002071514775430200236630ustar00rootroot00000000000000int main(int argc, char **argv) { IAmOnlyHere iaoh; } // Place after just to have a test with a ":diff < 0". class IAmOnlyHere { }; jacktasia-dumb-jump-d345e21/test/data/proj1/src/cpp/test.cpp000066400000000000000000000001471514775430200236640ustar00rootroot00000000000000class Foo { public: int bar(int val) { return val; } }; int main() { return Foo::bar(42); } jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/000077500000000000000000000000001514775430200220315ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/es6.js000066400000000000000000000006421514775430200230660ustar00rootroot00000000000000let funcName1 = (foo) => "bar"; const funcName2 = (foo) => "bar"; const funcName3 = (foo) => { return "bar"; } const obj = { funcName4 : (foo) => { return "bar"; } } const obj = { funcName5(foo) { return "bar"; } } funcName1(); funcName2(); funcName3(); funcName4(); funcName5(); class MyClass { constructor(a, b) { this.a = a; this.b = b; } } var b = new MyClass(); jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/fake.js000066400000000000000000000005221514775430200232740ustar00rootroot00000000000000'use strict'; function doSomeStuff() { alert('we did it!'); } $scope.resized = function(path, w, h) { path = path.replace(':8081', ':9090'); if (path.indexOf('.gif') !== -1) { return path; } return $scope.resizeHost + encodeURIComponent(path) + '?w=' + w + '&h=' + h; }; someFunc(); // console.log(backgroundColor); jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/fake2.js000066400000000000000000000013261514775430200233610ustar00rootroot00000000000000console.log(doSomeStuff()); // nothing var someVar = 13, someVar2 = 14; function workWithSomeVar(someVar) { var someVar2 = {a: 1, b: 2}; console.log('someVar is', someVar); console.log('someVar is', someVar2); } function workWithSomeVar(blarg, someVar) { var someVar2 = 13; console.log('someVar is', someVar); console.log('someVar is', someVar2); } function workWithSomeVar(blarg, someVar, blah3) { var someVar2 = 13; console.log('someVar is', someVar); console.log('someVar is', someVar2); } var backgroundColor = '#222'; if (isActive) { backgroundColor = 'darkgreen'; } else if (canDrop) { backgroundColor = 'darkkhaki'; } console.log(backgroundColor); jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/fake3.js000066400000000000000000000001641514775430200233610ustar00rootroot00000000000000var someFunc = function() { console.log('some func a'); }; function someFunc() { console.log('some func b'); } jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/nocode.txt000066400000000000000000000000341514775430200240360ustar00rootroot00000000000000this is a file with no code jacktasia-dumb-jump-d345e21/test/data/proj1/src/js/react.js000066400000000000000000000013601514775430200234650ustar00rootroot00000000000000 // normal react es6 class component class MyComponent extends Component { render() { return

My Component!

; } } {children} // exotic react component const MyComponent3 = ({ prop1, prop2, }, { context1, context2, }) => (
{prop1} {context1}
); {children3} // stateless component mycomponent2 const MyComponent2 = props =>
{props.text}
{children2} // inline jsx const mySomething =
...
;
{mySomething}
// decorated Component class MyBaseComponent extends Component ..... const DecoratedComponent = Radium(Rezponsive(MyBaseComponent); export default DecoratedComponent jacktasia-dumb-jump-d345e21/test/data/proj1/src/org/000077500000000000000000000000001514775430200222045ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/src/org/named-blocks.org000066400000000000000000000024421514775430200252560ustar00rootroot00000000000000* Named Block Tests :PROPERTIES: :CUSTOM_ID: named-block-tests :END: This file tests dumb-jump's ability to find org constructs. ** Named Blocks Section Reference to myblock: <> #+name: myblock #+begin_src python def test_function(): return 42 #+end_src Another reference: <> #+NAME: UPPERCASE #+begin_src elisp (message "test") #+end_src Mixed case: <> #+Name: MixedCase #+begin_src shell echo "hello" #+end_src Indented block reference: <> #+name: indented #+begin_src python pass #+end_src Test for uniqueblock lookup: uniqueblock #+name: uniqueblock #+begin_src elisp (message "unique") #+end_src Test for nospace lookup: nospace #+name:nospace #+begin_src elisp (message "no space after colon") #+end_src ** Call References Section :PROPERTIES: :CUSTOM_ID: call-section :END: See also the section with ID call-section for more info. #+call: myblock() #+CALL: UPPERCASE() ** Headings Section Reference to MainTopic heading: MainTopic *** MainTopic Some content here with MainTopic mentioned again. *** SubHeading One Some content here. *** SubHeading Two :PROPERTIES: :CUSTOM_ID: subheading-two :END: More content here. *** NoSpaceID Section :PROPERTIES: :CUSTOM_ID:nospace-id :END: Reference to nospace-id custom ID: nospace-id jacktasia-dumb-jump-d345e21/test/data/proj1/src/org/test.org000066400000000000000000000006671514775430200237050ustar00rootroot00000000000000* python #+begin_src python :results none :session "ses1" :exports code :comments org a=1 blabla(x) b=1 c=2 d=3 e=3 def blabla(x): return x #+end_src * R #+begin_src R :file toto.png :results graphics file :session :exports both :comments org plot(1, blabla(1)) blabla(2) #+end_src #+begin_src R :results none :session :exports code :comments org blabla(x) blabla <- function(x) { x*x } #+end_src jacktasia-dumb-jump-d345e21/test/data/proj1/src/php/000077500000000000000000000000001514775430200222045ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj1/src/php/php8.php000066400000000000000000000177701514775430200236100ustar00rootroot00000000000000value; /** * PHP 8.1+ Enum - Backed with string, implements interface */ enum Environment: string implements Serializable { case Development = 'dev'; case Production = 'prod'; case Testing = 'test'; public function label(): string { return match($this) { self::Development => 'Development', self::Production => 'Production', self::Testing => 'Testing', }; } } // Usage: Jump from Environment/Development/Production below to definitions above $env = Environment::Production; $isDev = Environment::Development; $label = Environment::Testing->label(); // ============================================================================= // CLASSES // ============================================================================= /** * Abstract base class */ abstract class BaseModel { abstract public function getId(): int; abstract protected function validate(): bool; } // Usage: Jump from BaseModel below to definition above class ConcreteModel extends BaseModel { public function getId(): int { return 1; } protected function validate(): bool { return true; } } $model = new ConcreteModel(); /** * Final class - cannot be extended */ final class Singleton { private static ?self $instance = null; private function __construct() {} public static function getInstance(): self { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } } // Usage: Jump from Singleton below to definition above $singleton = Singleton::getInstance(); /** * Readonly class (PHP 8.2+) */ readonly class UserDTO { public function __construct( public int $id, public string $name, public string $email, ) {} } // Usage: Jump from UserDTO below to definition above $userDto = new UserDTO(1, 'John', 'john@example.com'); /** * Final readonly class (PHP 8.2+) */ final readonly class ImmutableConfig { public function __construct( public string $appName, public string $version, ) {} } // Usage: Jump from ImmutableConfig below to definition above $immutableConfig = new ImmutableConfig('MyApp', '1.0.0'); /** * Readonly final class (PHP 8.2+) - alternative modifier order */ readonly final class AnotherDTO { public function __construct( public string $value, ) {} } // Usage: Jump from AnotherDTO below to definition above $anotherDto = new AnotherDTO('test'); // ============================================================================= // INTERFACE & TRAIT // ============================================================================= /** * Interface with constants */ interface Configurable { public const CONFIG_VERSION = 1; public const DEFAULT_TIMEOUT = 30; } // Usage: Jump from Configurable/CONFIG_VERSION below to definitions above class ConfigurableImpl implements Configurable {} $ver = Configurable::CONFIG_VERSION; $timeout = Configurable::DEFAULT_TIMEOUT; /** * Trait definition */ trait Timestampable { public ?DateTime $createdAt = null; public ?DateTime $updatedAt = null; public function touch(): void { $this->updatedAt = new DateTime(); } } // Usage: Jump from Timestampable below to definition above class TimestampedEntity { use Timestampable; } $entity = new TimestampedEntity(); $entity->touch(); // ============================================================================= // CLASS WITH PROPERTIES AND CONSTANTS // ============================================================================= /** * Regular class with modern PHP features */ class User extends BaseModel implements Configurable { use Timestampable; // Class constants with visibility public const TABLE_NAME = 'users'; protected const HIDDEN_FIELDS = ['password']; private const INTERNAL_VERSION = 2; final public const MAX_LOGIN_ATTEMPTS = 5; // Typed properties (PHP 7.4+) public int $id; public string $name; private ?string $email = null; protected array $roles = []; // Readonly property (PHP 8.1+) public readonly string $uuid; // Static property (typed) private static int $instanceCount = 0; public static ?self $lastCreated = null; // Static property (untyped) static $untypedCounter; // Union type property (PHP 8.0+) public string|int $identifier; // Nullable typed property public ?DateTime $lastLogin = null; public function __construct(int $id, string $name) { $this->id = $id; $this->name = $name; $this->uuid = uniqid('user_', true); self::$instanceCount++; self::$lastCreated = $this; } public function getId(): int { return $this->id; } protected function validate(): bool { return !empty($this->name); } public static function getInstanceCount(): int { return self::$instanceCount; } } // Usage: Jump from User/TABLE_NAME/MAX_LOGIN_ATTEMPTS below to definitions above $user = new User(1, 'Alice'); echo User::TABLE_NAME; echo User::MAX_LOGIN_ATTEMPTS; echo $user->id; echo $user->name; echo $user->uuid; echo User::$lastCreated; // ============================================================================= // FUNCTIONS // ============================================================================= // Function using arrow function (PHP 7.4+) function processItems(array $items): array { $doubled = array_map(fn($x) => $x * 2, $items); return $doubled; } // Usage: Jump from processItems below to definition above $result = processItems([1, 2, 3]); // Switch statement (should NOT match enum case pattern) function handleStatus(int $code): string { switch ($code) { case 200: return 'OK'; case 404: return 'Not Found'; default: return 'Unknown'; } } // Usage: Jump from handleStatus below to definition above $statusText = handleStatus(200); // ============================================================================= // NEGATIVE TEST CASES // These should NOT be matched by patterns (comments, variable assignments) // ============================================================================= // enum FakeEnum { case Fake; } // abstract class FakeAbstract {} // final class FakeFinal {} // readonly class FakeReadonly {} // const FAKE_CONST = 123; // define('FAKE_DEFINE', 456); // Variable assignments (should NOT match constant patterns) $enum = 'not an enum'; $const = 'not a constant'; $define = 'not define()'; // Function use and const use (should NOT match class use pattern) use function App\Helpers\helperFunction; use const App\Constants\SOME_CONSTANT; jacktasia-dumb-jump-d345e21/test/data/proj2-elisp/000077500000000000000000000000001514775430200217415ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj2-elisp/.dumbjump000066400000000000000000000000211514775430200235560ustar00rootroot00000000000000+../fake-library jacktasia-dumb-jump-d345e21/test/data/proj2-elisp/fake.el000066400000000000000000000003231514775430200231670ustar00rootroot00000000000000;;; fake.el --- fake file for testing dumb-jump -*- lexical-binding: t -*- (defun some-fake-function (blah) (message "heyyy %s" blah)) (defun another-fake-function (blah) (message "heyyy again, %s" blah)) jacktasia-dumb-jump-d345e21/test/data/proj2-elisp/fake2.el000066400000000000000000000011711514775430200232530ustar00rootroot00000000000000;; a totally fake file for tests -*- lexical-binding: t -*- (defun when-var-is-in-sig (my-arg2) (let* ((my-arg 22)) (if (> my-arg2 my-arg) "" (with-no-warnings (something-else my-arg2))))) (defun when-var-is-in-let () (let* ((my-arg 11) (my-arg2 22)) (if (> my-arg2 my-arg) "" (when-var-is-in-sig my-arg2)))) (defun when-var-is-in-let-repeat () (let* ((my-arg 11) (my-arg2 22) (their-my-arg2 22)) (if (> my-arg2 my-arg) (when-var-is-in-sig their-my-arg2) (when-var-is-in-sig my-arg2)))) (with-no-warnings (func-in-lib 1 2)) ;; end of file jacktasia-dumb-jump-d345e21/test/data/proj3-clj/000077500000000000000000000000001514775430200213765ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj3-clj/.dumbjump000066400000000000000000000000001514775430200232100ustar00rootroot00000000000000jacktasia-dumb-jump-d345e21/test/data/proj3-clj/file1.clj000066400000000000000000000000771514775430200230740ustar00rootroot00000000000000 (defn blah (print "hello")) (defn- foo* (print "hello")) jacktasia-dumb-jump-d345e21/test/data/proj3-clj/file2.clj000066400000000000000000000001051514775430200230650ustar00rootroot00000000000000(defn blah? (print "hello2")) (deftask foo [] (print "hello2")) jacktasia-dumb-jump-d345e21/test/data/proj3-clj/file3.clj000066400000000000000000000000361514775430200230710ustar00rootroot00000000000000 (blah?) (blah) (foo) (foo*) jacktasia-dumb-jump-d345e21/test/dumb-jump-test.el000066400000000000000000003026041514775430200220660ustar00rootroot00000000000000;;; -*- lexical-binding: t -*- (require 'f) (require 's) (require 'dash) (require 'noflet) (require 'el-mock) ;; (require 'dumb-jump) ;;; Code: ;; Utilities - locate test files ;; ----------------------------- (defun dumb-jump-output-rule-test-failures (failures) (--each failures (princ (format "\t%s\n" it)))) ;; The test data directory path is adjusted to the location of the ;; current working directory being either inside the top directory ;; where dumb-jump.el and test directory are located or inside the test ;; sub-directory where the test file and the data sub-directory are ;; located. Anywhere else is invalid. (defconst test-data-dir (if (and (f-exists? "./dumb-jump.el") (f-dir? "./test/data")) (f-expand "./test/data") (if (and (f-exists? "./dumb-jump-test.el") (f-dir? "./data")) (f-expand "./data") "INVALID-Current-Working-Directory-for-ERT-Tests!")) "Test directory.") (defconst test-dumb-jump-root-dir (if (and (f-exists? "./dumb-jump.el") (f-dir? "./test/data")) (f-expand ".") (if (and (f-exists? "./dumb-jump-test.el") (f-dir? "./data")) (f-expand "..") "INVALID-Current-Working-Directory-for-ERT-Tests!")) "Test directory.") (defconst test-data-dir-elisp (f-join test-data-dir "proj2-elisp") "Test directory.") (defconst test-data-dir-proj1 (f-join test-data-dir "proj1") "Test directory.") (defconst test-data-dir-proj3 (f-join test-data-dir "proj3-clj") "Test directory.") (defconst test-data-dir-multiproj (f-join test-data-dir "multiproj") "Test directory.") (defconst test-dumb-jump-file-path (if (and (f-exists? "./dumb-jump.el") (f-dir? "./test/data")) "dumb-jump.el" (if (and (f-exists? "./dumb-jump-test.el") (f-dir? "./data")) "../dumb-jump.el" "INVALID-Current-Working-Directory-for-dumb-jump!")) "Relative path of dumb-jump.el ") ;; --------------------------------------------------------------------------- ;; Test Setup Utilities ;; -------------------- ;; Prevent dumb-jump from prompting user during test ;; dumb-jump commands will prompt the user when a search operation finds more ;; than 1 destination candidate. This prompting cannot be performed when the ;; code is automatically tested as the test will hang if it is allowed to ;; proceed. ;; ;; The following macro must be used to wrap test code that access a dumb-jump ;; command that may prompt. The macro force test failure when dumb-jump ;; prompting function, `dumb-jump-prompt-user-for-choice', is invoked. (defmacro with-mock-forbidding-prompt (&rest body) "Test BODY. Ensure no prompting occurs; fail test if prompting did occur." (declare (indent 0)) `(with-mock (stub dumb-jump-prompt-user-for-choice => (error "Unexpected call to dumb-jump-prompt-user-for-choice")) ,@body)) ;; --------------------------------------------------------------------------- ;; Tests ;; ----- ;; Test `with-mock-forbidding-prompt': ;; - Ensure with-mock-forbidding-prompt actually detects prompts. (ert-deftest with-mock-forbidding-prompt-really-detects-prompt () "Test that `with-mock-forbidding-prompt' properly detects/fails on prompts." (should-error (with-mock-forbidding-prompt ;; This should trigger the error (dumb-jump-prompt-user-for-choice "/test/path" '((:path "a" :line 1)))))) ;; - Ensure that it does not misinterpret another exception as a prompt. (defun test-function-that-errors () "A test utility that issues an error." (error "Issued by test-function-that-errors!")) (ert-deftest with-mock-forbidding-prompt-does-not-catch-other-exceptions () "Test detection of other error signalling by `with-mock-forbidding-prompt'." (let ((err (should-error (with-mock-forbidding-prompt (test-function-that-errors))))) ;; The error description is a list, often in the format (ERROR-SYMBOL . DATA). ;; The error message string is typically the second element (car of the DATA, ;; which is the cdr of the error description). (should (string-match "Issued by test-function-that-errors!" (cadr err))))) ;; -------------------- (ert-deftest data-dir-exists-test () (should (f-dir? test-data-dir))) (ert-deftest data-dir-proj2-exists-test () (should (f-dir? test-data-dir-elisp))) (ert-deftest dumb-jump-get-lang-by-ext-test () (let ((lang1 (dumb-jump-get-language-by-filename "sldkfj.el")) (lang1b (dumb-jump-get-language-by-filename "sldkfj.el.gz")) (lang2 (dumb-jump-get-language-by-filename "/askdfjkl/somefile.js")) (lang3 (dumb-jump-get-language-by-filename "/askdfjkl/somefile.d")) (lang3b (dumb-jump-get-language-by-filename "/askdfjkl/somefile.di")) (nolang (dumb-jump-get-language-by-filename "/blah/somefile.bin"))) (should (string= lang1 "elisp")) (should (string= lang1b "elisp")) (should (string= lang2 "javascript")) (should (string= lang3 "dlang")) (should (string= lang3b "dlang")) (should (null nolang)))) (ert-deftest dumb-jump-get-lang-major-mode-test () (let* ((major-mode 'php) (lang1 (dumb-jump-get-language "blah/file.install")) (lang1b (dumb-jump-get-mode-base-name)) (lang2 (dumb-jump-get-language-by-filename "/askdfjkl/somefile.js"))) (should (string= lang1 "php")) (should (string= lang1b "php")) (should (string= lang2 "javascript")))) (ert-deftest dumb-jump-get-lang-major-mode-alias-test () (let* ((major-mode 'd-mode) (lang (dumb-jump-get-language "blah/file.install"))) (should (string= lang "dlang")))) (ert-deftest dumb-jump-current-files-results-test () (let ((results '((:path "blah") (:path "rarr"))) (expected '((:path "blah")))) (should (equal (dumb-jump-current-file-results "blah" results) expected)))) (ert-deftest dumb-jump-exclude-path-test () (let* ((expected (list (f-join test-data-dir-proj1 "ignored") (f-join test-data-dir-proj1 "ignored2"))) (config (dumb-jump-read-config test-data-dir-proj1 ".dumbjump"))) (should (equal (plist-get config :exclude) expected)))) (ert-deftest dumb-jump-include-path-test () (let* ((config (dumb-jump-read-config test-data-dir-proj1 ".dumbjump-include")) (expected (list (f-join test-data-dir-proj1 "../fake-library") "/etc/var/some/code"))) (should (equal (plist-get config :include) expected)))) (ert-deftest dumb-jump-exclude-path-blank-test () (let* ((config (dumb-jump-read-config test-data-dir-proj1 ".dumbjump-blank"))) (should (null (plist-get config :exclude))) (should (null (plist-get config :include))))) (ert-deftest dumb-jump-config-lang-test () (let* ((config (dumb-jump-read-config test-data-dir-proj1 ".dumbjump-lang"))) (should (string= "python" (plist-get config :language))))) (ert-deftest dumb-jump-language-to-ext-test () (should (-contains? (dumb-jump-get-file-exts-by-language "elisp") "el"))) (ert-deftest dumb-jump-generate-cmd-include-args () (let ((args (dumb-jump-get-ext-includes "javascript")) (expected " --include \\*.js --include \\*.jsx --include \\*.vue --include \\*.html --include \\*.css ")) (should (string= expected args)))) (defconst dumb-jump--expected-elisp-regexps-templates '("\\((defun|cl-defun|cl-defgeneric|cl-defmethod|cl-defsubst)\\s+JJJ\\j" "\\((defmacro|cl-defmacro|cl-define-compiler-macro)\\s+JJJ\\j" "\\(defhydra\\b\\s*JJJ\\j" ;; "\\(defvar(-local)?\\b\\s*JJJ\\j" "\\(defconst\\b\\s*JJJ\\j" "\\(defcustom\\b\\s*JJJ\\j" "\\(setq\\b\\s*JJJ\\j" "\\(JJJ\\s+" "\\((cl-defstruct|cl-deftype)\\s+JJJ\\j" "\\((defun|cl-defun|cl-defgeneric|cl-defmethod)\\s*.+\\(?\\s*JJJ\\j\\s*\\)?") "List of regexp templates equal to what is in dumb-jump.el.") (defun dumb-jump--elisp-expected-regexps (variant &optional type) "Return a list of elisp regexps adjusted with word boundary of VARIANT. VARIANT must be one of: ag, rg, grep, gnu-grep, git-grep, or git-grep-plus-ag." (let ((regexes (if (eq type 'elisp-functions) ;; take the first 3 regexps: used for functions (-take 3 dumb-jump--expected-elisp-regexps-templates) dumb-jump--expected-elisp-regexps-templates)) (word-boundary-regexp (symbol-value (intern (format "dumb-jump-%s-word-boundary" (if (eq variant 'git-grep-plus-ag) 'ag variant))))) (formatted-regexps '())) ;; perform translation of each regexp template (dolist (r regexes (reverse formatted-regexps)) (setq r (s-replace "JJJ" "tester" r)) (setq r (s-replace "\\j" word-boundary-regexp r)) (when (dumb-jump-use-space-bracket-exp-for variant) (setq r (s-replace "\\s" "[[:space:]]" r))) (push r formatted-regexps)))) (ert-deftest dumb-jump-generate-grep-command-no-ctx-test () (let* ((system-type 'darwin) (regexes (dumb-jump-get-contextual-regexes "elisp" nil 'grep)) ;; The grep command built by dumb-jump places each regexp inside its ;; own -e string. Each of those strings following -e must be ;; shell-quoted. (expected-regexes (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'grep))) (expected (concat "LANG=C grep -REn --include \\*.el --include \\*.el.gz" (s-join "" expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-gnu-grep-command-no-ctx-test () (let* ((system-type 'darwin) (regexes (dumb-jump-get-contextual-regexes "elisp" nil 'gnu-grep)) ;; The gnu grep command built by dumb-jump places each regexp inside ;; its own -e string. Each of those strings following -e must be ;; shell-quoted. (expected-regexes (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'gnu-grep))) (expected (concat "LANG=C grep -rEn" (s-join "" expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-gnu-grep-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-ag-command-no-ctx-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag)) (base-regexes (dumb-jump--elisp-expected-regexps 'ag)) ;; The ag tool accepts a list of regexps separated by "\\|". ;; Each of the regexp must be shell-quoted (but not "\\|"). (expected-regexes (append (-map (lambda (elem) (concat (shell-quote-argument elem) "\\|")) (-butlast base-regexes)) (list (shell-quote-argument (-last-item base-regexes))))) (expected (concat "ag --nocolor --nogroup --elisp -- " (mapconcat #'identity expected-regexes "") " ."))) (should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-ag-command-exclude-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'ag) "|")) (expected (concat "ag --nocolor --nogroup --elisp --ignore-dir this/is/excluded -- " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) (should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" '("/path/to/proj-root/this/is/excluded")))))) (ert-deftest dumb-jump-generate-git-grep-plus-ag-command-no-ctx-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'git-grep-plus-ag) "|")) (expected ;; NOTE no "--elisp" and the `-G` arg is new (concat "ag --nocolor --nogroup -G '(/path/to/proj-root/blah.el)' " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) (with-mock (mock (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg * *) => "'(/path/to/proj-root/blah.el)'") (should (string= expected (dumb-jump-generate-git-grep-plus-ag-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" nil)))))) (ert-deftest dumb-jump-generate-git-grep-plus-ag-command-exclude-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'git-grep-plus-ag) "|")) (expected ;; NOTE no "--elisp" and the `-G` arg is new (concat "ag --nocolor --nogroup -G '(/path/to/proj-root/blah.el)' --ignore-dir this/is/excluded " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) (with-mock (mock (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg * *) => "'(/path/to/proj-root/blah.el)'") (should (string= expected (dumb-jump-generate-git-grep-plus-ag-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" '("/path/to/proj-root/this/is/excluded"))))))) (ert-deftest dumb-jump-generate-rg-command-no-ctx-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'rg) "|")) (expected (concat "rg --color never --no-heading --line-number -U --pcre2 --type elisp -- " (shell-quote-argument expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-rg-command-remote-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'rg) "|")) (expected (concat "rg --color never --no-heading --line-number -U --pcre2 --type elisp -g \\!this/is/excluded -- " (shell-quote-argument expected-regexes) " /path/to/proj-root"))) (should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "/path/to/proj-root" regexes "elisp" '("/path/to/proj-root/this/is/excluded")))))) (ert-deftest dumb-jump-generate-git-grep-command-no-ctx-test () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'git-grep) "|")) (excludes '("one" "two" "three")) (expected (concat "git grep --color=never --line-number --untracked -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three"))) (should (string= expected (dumb-jump-generate-git-grep-command "tester" "blah.el" "." regexes "elisp" excludes))))) (ert-deftest dumb-jump-generate-git-grep-command-no-ctx-extra-args () (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'git-grep) "|")) (excludes '("one" "two" "three")) (dumb-jump-git-grep-search-args "--recurse-submodules") (expected (concat "git grep --color=never --line-number --untracked --recurse-submodules -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three"))) (should (string= expected (dumb-jump-generate-git-grep-command "tester" "blah.el" "." regexes "elisp" excludes))))) (ert-deftest dumb-jump-generate-ag-command-no-ctx-extra-args () ;; ag args (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'ag)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'ag) "|")) (dumb-jump-ag-search-args "--follow") (expected (concat "ag --nocolor --nogroup --follow --elisp -- " (shell-quote-argument expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-ag-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-rg-command-no-ctx-extra-args () ;; rg-args (let* ((regexes (dumb-jump-get-contextual-regexes "elisp" nil 'rg)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'rg) "|")) (dumb-jump-rg-search-args "--no-pcre2 --follow") (expected (concat "rg --color never --no-heading --line-number -U --no-pcre2 --follow --type elisp -- " (shell-quote-argument expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-rg-command "tester" "blah.el" "." regexes "elisp" nil))))) (ert-deftest dumb-jump-generate-git-grep-command-not-search-untracked-test () (let* ((dumb-jump-git-grep-search-args "") (dumb-jump-git-grep-search-untracked nil) (regexes (dumb-jump-get-contextual-regexes "elisp" nil 'git-grep)) (expected-regexes (mapconcat #'identity (dumb-jump--elisp-expected-regexps 'git-grep) "|")) (excludes '("one" "two" "three")) (expected (concat "git grep --color=never --line-number -E " (shell-quote-argument expected-regexes) " -- ./\\*.el ./\\*.el.gz \\:\\(exclude\\)one \\:\\(exclude\\)two \\:\\(exclude\\)three"))) (should (string= expected (dumb-jump-generate-git-grep-command "tester" "blah.el" "." regexes "elisp" excludes))))) (ert-deftest dumb-jump-generate-grep-command-no-ctx-funcs-only-test () (let* ((system-type 'darwin) (dumb-jump-functions-only t) (regexes (dumb-jump-get-contextual-regexes "elisp" nil 'grep)) (expected-regexes (s-join "" (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'grep 'elisp-functions)))) (expected (concat "LANG=C grep -REn" expected-regexes " .")) (zexpected (concat "LANG=C zgrep -REn" expected-regexes " ."))) (should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil))) (should (string= zexpected (dumb-jump-generate-grep-command "tester" "blah.el.gz" "." regexes "" nil))))) (ert-deftest dumb-jump-generate-grep-command-with-ctx-test () (let* ((system-type 'darwin) (ctx-type (dumb-jump-get-ctx-type-by-language "elisp" '(:left "(" :right nil))) (dumb-jump-ignore-context nil) ;; overriding the default (regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type 'grep)) (expected-regexes (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'grep 'elisp-functions))) (expected (concat "LANG=C grep -REn" (s-join "" expected-regexes) " ."))) ;; the point context being passed should match a "function" type so only the one command (should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil))))) (ert-deftest dumb-jump-generate-grep-command-on-windows-test () (noflet ((shell-quote-argument (it) (format "'%s'" it))) (let* ((system-type 'windows-nt) (ctx-type (dumb-jump-get-ctx-type-by-language "elisp" '(:left "(" :right nil))) (dumb-jump-ignore-context nil) ;; overriding the default (regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type 'grep)) (expected-regexes (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'grep 'elisp-functions))) (expected (concat "grep -REn" (s-join "" expected-regexes) " ."))) (should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil)))))) (ert-deftest dumb-jump-generate-grep-command-with-ctx-but-ignored-test () (let* ((system-type 'darwin) (ctx-type (dumb-jump-get-ctx-type-by-language "elisp" '(:left "(" :right nil))) (dumb-jump-ignore-context t) (regexes (dumb-jump-get-contextual-regexes "elisp" ctx-type nil)) (expected-regexes (--map (concat " -e " (shell-quote-argument it)) (dumb-jump--elisp-expected-regexps 'grep))) (expected (concat "LANG=C grep -REn" (s-join "" expected-regexes) " ."))) ;; the point context being passed is ignored so ALL should return (should (string= expected (dumb-jump-generate-grep-command "tester" "blah.el" "." regexes "" nil))))) (ert-deftest dumb-jump-generate-bad-grep-command-test () (should (s-blank? (dumb-jump-generate-grep-command "tester" "blah.el" "." nil "" (list "skaldjf"))))) (ert-deftest dumb-jump-generate-bad-ag-command-test () (should (s-blank? (dumb-jump-generate-ag-command "tester" "blah.el" "." nil "" (list "skaldjf"))))) (ert-deftest dumb-jump-generate-bad-rg-command-test () (should (s-blank? (dumb-jump-generate-rg-command "tester" "blah.el" "." nil "" (list "skaldjf"))))) (ert-deftest dumb-jump-generate-bad-git-grep-command-test () (should (s-blank? (dumb-jump-generate-git-grep-command "tester" "blah.el" "." nil "" (list "skaldjf"))))) (ert-deftest dumb-jump-grep-parse-test () (let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar some-var )\n./dumb-jump2.el:28:(defvar some-var)") (parsed (dumb-jump-parse-grep-response resp "dumb-jump2.el" 28)) (test-result (nth 1 parsed))) (should (= (plist-get test-result :diff) 2)) (should (= (length parsed) 2)) (should (string= (plist-get test-result :path) "dumb-jump.el")) (should (= (plist-get test-result ':line) 26)))) (ert-deftest dumb-jump-grep-parse-no-filter-test () (let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar some-var )\n") (parsed (dumb-jump-parse-grep-response resp "dumb-jump2.el" 28)) (test-result (nth 1 parsed))) (should (= (plist-get test-result :diff) 2)) (should (= (length parsed) 2)) (should (string= (plist-get test-result :path) "dumb-jump.el")) (should (= (plist-get test-result ':line) 26)))) (ert-deftest dumb-jump-ag-parse-test () (let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar some-var )\n./dumb-jump2.el:28:1:(defvar some-var)") (parsed (dumb-jump-parse-ag-response resp "dumb-jump2.el" 28)) (test-result (nth 1 parsed))) (should (= (plist-get test-result :diff) 2)) (should (= (length parsed) 2)) (should (string= (plist-get test-result :path) "dumb-jump.el")) (should (= (plist-get test-result ':line) 26)))) (ert-deftest dumb-jump-rg-parse-test () (let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar some-var )\n./dumb-jump2.el:28:1:(defvar some-var)") (parsed (dumb-jump-parse-rg-response resp "dumb-jump2.el" 28)) (test-result (nth 1 parsed))) (should (= (plist-get test-result :diff) 2)) (should (= (length parsed) 2)) (should (string= (plist-get test-result :path) "dumb-jump.el")) (should (= (plist-get test-result ':line) 26)))) (ert-deftest dumb-jump-git-grep-parse-test () (let* ((resp "./dumb-jump.el:22:(defun dumb-jump-asdf ()\n./dumb-jump.el:26:(defvar some-var )\n./dumb-jump2.el:28:1:(defvar some-var)") (parsed (dumb-jump-parse-git-grep-response resp "dumb-jump2.el" 28)) (test-result (nth 1 parsed))) (should (= (plist-get test-result :diff) 2)) (should (= (length parsed) 2)) (should (string= (plist-get test-result :path) "dumb-jump.el")) (should (= (plist-get test-result ':line) 26)))) (ert-deftest dumb-jump-run-cmd-test () (with-mock (stub dumb-jump-rg-installed? => t) (let* ((gen-funcs (dumb-jump-pick-grep-variant test-data-dir-elisp)) (parse-fn (plist-get gen-funcs :parse)) (generate-fn (plist-get gen-funcs :generate)) (searcher (plist-get gen-funcs :searcher)) (regexes (dumb-jump-get-contextual-regexes "elisp" nil searcher)) (results (dumb-jump-run-command "another-fake-function" test-data-dir-elisp regexes "" "" "blah.el" 3 parse-fn generate-fn)) (first-result (car results))) (should (s-contains? "/fake.el" (plist-get first-result :path))) (should (= (plist-get first-result :line) 6))))) (ert-deftest dumb-jump-run-cmd-fail-test () (with-mock (stub dumb-jump-rg-installed? => t) (let* ((gen-funcs (dumb-jump-pick-grep-variant test-data-dir-elisp)) (parse-fn (plist-get gen-funcs :parse)) (generate-fn (plist-get gen-funcs :generate)) (results (dumb-jump-run-command "hidden-function" test-data-dir-elisp nil "" "" "blah.el" 3 parse-fn generate-fn)) (first-result (car results))) (should (null first-result))))) (ert-deftest dumb-jump-find-proj-root-test () (let* ((js-file (f-join test-data-dir-proj1 "src" "js")) (found-project (dumb-jump-get-project-root js-file))) (should (f-exists? found-project)) (should (string= found-project test-data-dir-proj1)) (should (string= ".dumbjump" (dumb-jump-get-config found-project))))) (ert-deftest dumb-jump-find-proj-root-default-test () (with-mock (mock (locate-dominating-file * *)) (let ((found-project (dumb-jump-get-project-root "")) (expected (f-expand dumb-jump-default-project))) (should (string= found-project expected))))) (ert-deftest dumb-jump-get-point-symbol-region-active-test () (with-mock (mock (region-active-p) => t) (mock (region-beginning) => 0) (mock (region-end) => 1) (mock (buffer-substring-no-properties * *) => "blah") (dumb-jump-get-point-symbol))) (ert-deftest dumb-jump-goto-file-line-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-mock-forbidding-prompt (when (version< emacs-version "29") (mock (ring-insert * *))) (dumb-jump-goto-file-line js-file 3 0) (should (string= (buffer-file-name) js-file)) (should (= (line-number-at-pos) 3))))) (ert-deftest dumb-jump-test-grep-rules-test () (let ((rule-failures (dumb-jump-test-grep-rules))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0)))) (defun dumb-jump--noop (&rest _args) "Do nothing, return nil." nil) (when (dumb-jump-ag-installed?) (ert-deftest dumb-jump-test-ag-rules-test () ;; Some of the tests write text inside a temporary buffer and save the ;; text to a file to perform testing. That will work as long as Emacs is ;; not setup to execute `delete-trailing-whitespace' in the ;; `before-save-hook' which might be the case for users systems. ;; To prevent that from happening advice the `delete-trailing-whitespace' ;; function into something that does nothing for the duration of the test. (unwind-protect (progn (advice-add 'delete-trailing-whitespace :override 'dumb-jump--noop) (let ((rule-failures (dumb-jump-test-ag-rules))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0)))) ;; restore `delete-trailing-whitespace' (advice-remove 'delete-trailing-whitespace 'dumb-jump--noop)))) (when (dumb-jump-rg-installed?) (ert-deftest dumb-jump-test-rg-rules-test () (let ((rule-failures (dumb-jump-test-rg-rules))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0))))) (when (and (not (eq system-type 'darwin)) ; git grep is broken on macOS as of Jan 2026. (dumb-jump-git-grep-installed?)) (ert-deftest dumb-jump-test-git-grep-rules-test () (let ((rule-failures (dumb-jump-test-git-grep-rules))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0))))) (ert-deftest dumb-jump-test-grep-rules-not-test () ;; :not tests (let ((rule-failures (dumb-jump-test-grep-rules t))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0)))) (when (dumb-jump-ag-installed?) (ert-deftest dumb-jump-test-ag-rules-not-test () ;; :not tests (let ((rule-failures (dumb-jump-test-ag-rules t))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0))))) (when (dumb-jump-rg-installed?) (ert-deftest dumb-jump-test-rg-rules-not-test () ;; :not tests (let ((rule-failures (dumb-jump-test-rg-rules t))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0))))) (ert-deftest dumb-jump-test-grep-rules-fail-test () (let* ((bad-rule '(:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp" :regex "\\\(defvarJJJ\\b\\s*" :tests ("(defvar test "))) (dumb-jump-find-rules (cons bad-rule dumb-jump-find-rules)) (rule-failures (dumb-jump-test-grep-rules))) (should (= (length rule-failures) 1)))) (when (dumb-jump-ag-installed?) (ert-deftest dumb-jump-test-ag-rules-fail-test () ;; Some of the tests write text inside a temporary buffer and save the ;; text to a file to perform testing. That will work as long as Emacs is ;; not setup to execute `delete-trailing-whitespace' in the ;; `before-save-hook' which might be the case for users systems. ;; To prevent that from happening advice the `delete-trailing-whitespace' ;; function into something that does nothing for the duration of the test. (unwind-protect (progn (advice-add 'delete-trailing-whitespace :override 'dumb-jump--noop) (let* ((bad-rule '(:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp" :regex "\\\(defvarJJJ\\b\\s*" :tests ("(defvar test "))) (dumb-jump-find-rules (cons bad-rule dumb-jump-find-rules)) (rule-failures (dumb-jump-test-ag-rules))) (should (= (length rule-failures) 1)))) ;; restore `delete-trailing-whitespace' (advice-remove 'delete-trailing-whitespace 'dumb-jump--noop)))) (when (dumb-jump-rg-installed?) (ert-deftest dumb-jump-test-rg-rules-fail-test () (let* ((bad-rule '(:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp" :regex "\\\(defvarJJJ\\b\\s*" :tests ("(defvar test "))) ;; Add a bad rules to the rules normally used by dumb-jump. (dumb-jump-find-rules (cons bad-rule dumb-jump-find-rules)) ;; then test all rules to detect the ones that fail. (rule-failures (dumb-jump-test-rg-rules))) ;; No rule taken from dumb-jump.el should fail: the only one that ;; should fail should be the `bad-rule' defined above. (should (= (length rule-failures) 1))))) (when (and (not (eq system-type 'darwin)) ; git grep is broken on macOS as of Jan 2026. (dumb-jump-git-grep-installed?)) (ert-deftest dumb-jump-test-git-grep-rules-fail-test () (let* ((bad-rule '(:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp" :regex "\\\(defvarJJJ\\b\\s*" :tests ("(defvar test "))) (dumb-jump-find-rules (cons bad-rule dumb-jump-find-rules)) (rule-failures (dumb-jump-test-git-grep-rules))) (should (= (length rule-failures) 1))))) (when (and (not (eq system-type 'darwin)) ; git grep is broken on macOS as of Jan 2026. (dumb-jump-git-grep-installed?)) (ert-deftest dumb-jump-test-git-grep-rules-not-test () ;; :not tests (let ((rule-failures (dumb-jump-test-git-grep-rules t))) (dumb-jump-output-rule-test-failures rule-failures) (should (= (length rule-failures) 0))))) (ert-deftest dumb-jump-match-test () (should (not (dumb-jump-re-match nil "asdf"))) (should (dumb-jump-re-match "^asdf$" "asdf")) (should (string= (car (dumb-jump-re-match "^[0-9]+$" "123")) "123"))) (ert-deftest dumb-jump-context-point-test () (let* ((sentence "mainWindow.loadUrl('file://')") (func "loadUrl") (ctx (dumb-jump-get-point-context sentence func 11))) (should (string= (plist-get ctx :left) "mainWindow.")) (should (string= (plist-get ctx :right) "('file://')")))) (ert-deftest dumb-jump-context-point-type-test () (let* ((sentence "mainWindow.loadUrl('file://' + __dirname + '/dt/inspector.html?electron=true');") (func "loadUrl") (pt-ctx (dumb-jump-get-point-context sentence func 11)) (ctx-type (dumb-jump-get-ctx-type-by-language "javascript" pt-ctx))) (should (string= ctx-type "function")))) (ert-deftest dumb-jump-context-point-typescript-type-annotation-test () (let* ((sentence "const foo: MyType = {}") (sym "MyType") (pt-ctx (dumb-jump-get-point-context sentence sym 11)) (ctx-type (dumb-jump-get-ctx-type-by-language "typescript" pt-ctx))) (should (string= ctx-type "type")))) (ert-deftest dumb-jump-context-point-typescript-type-alias-test () (let* ((sentence "type MyType = { foo: string }") (sym "MyType") (pt-ctx (dumb-jump-get-point-context sentence sym 5)) (ctx-type (dumb-jump-get-ctx-type-by-language "typescript" pt-ctx))) (should (string= ctx-type "type")))) (ert-deftest dumb-jump-prompt-user-for-choice-correct-test () (let* ((dumb-jump-selector 'completing-read) (results '((:path "/usr/blah/test.txt" :line 54 :context "function thing()") (:path "/usr/blah/test2.txt" :line 52 :context "var thing = function()" :target "a")))) (with-mock (mock (dumb-jump--select-choice * *) => "/test2.txt:52: var thing = function()") (mock (dumb-jump-result-follow '(:path "/usr/blah/test2.txt" :line 52 :context "var thing = function()" :target "a"))) (dumb-jump-prompt-user-for-choice "/usr/blah" results)))) (ert-deftest dumb-jump-prompt-user-for-choice-correct-helm-test () (let* ((dumb-jump-selector 'helm) (results '((:path "/usr/blah/test.txt" :line 54 :context "function thing()") (:path "/usr/blah/test2.txt" :line 52 :context "var thing = function()" :target "a")))) (with-mock (mock (helm-make-source "Jump to: " 'helm-source-sync :action * :candidates * :persistent-action *)) (mock (helm * * :buffer "*helm dumb jump choices*")) (dumb-jump-prompt-user-for-choice "/usr/blah" results)))) (ert-deftest dumb-jump-prompt-user-for-choice-correct-helm-persistent-action-test () (dumb-jump-helm-persist-action (list :path test-dumb-jump-file-path :line 1 :context " (defn status")) (should (get-buffer " *helm dumb jump persistent*"))) (ert-deftest dumb-jump-prompt-user-for-choice-correct-ivy-test () (let* ((dumb-jump-selector 'ivy) (dumb-jump-ivy-jump-to-selected-function #'dumb-jump-ivy-jump-to-selected) (results '((:path "/usr/blah/test.txt" :line 54 :context "function thing()") (:path "/usr/blah/test2.txt" :line 52 :context "var thing = function()" :target "a")))) (with-mock (mock (ivy-read * * :action * :caller *) => "/test2.txt:52: var thing = function()") (dumb-jump-prompt-user-for-choice "/usr/blah" results)))) (ert-deftest dumb-jump-a-back-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock-forbidding-prompt (mock (pop-tag-mark)) (stub dumb-jump-rg-installed? => t) (with-no-warnings (dumb-jump-go)) (with-no-warnings (dumb-jump-back)))))) (ert-deftest dumb-jump-fetch-results-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 2) (forward-char 10) (with-mock (stub dumb-jump-rg-installed? => t) (let ((results (dumb-jump-fetch-file-results))) (should (string= "doSomeStuff" (plist-get results :symbol))) (should (string= "javascript" (plist-get results :lang)))))))) (ert-deftest dumb-jump-go-shell-test () (with-current-buffer (get-buffer-create "*shell*") (insert ".js doSomeStuff()") (goto-char (point-min)) (forward-char 6) (with-mock (stub dumb-jump-rg-installed? => t) (let ((results (dumb-jump-get-results))) (should (string= "doSomeStuff" (plist-get results :symbol))) (should (string= "javascript" (plist-get results :lang))))))) (ert-deftest dumb-jump-go-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js")) (go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 9)) (should (string= go-js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-other-window-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js")) (go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 9)) (should (string= go-js-file (with-no-warnings (dumb-jump-go-other-window)))))))) (ert-deftest dumb-jump-go-current-window-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js")) (go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 9)) (should (string= go-js-file (with-no-warnings (dumb-jump-go-current-window)))))))) (ert-deftest dumb-jump-quick-look-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js")) (go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock (stub dumb-jump-rg-installed? => t) (mock (dumb-jump--show-preview "/src/js/fake.js:3: function doSomeStuff() {")) (should (string= go-js-file (with-no-warnings (dumb-jump-quick-look)))))))) (ert-deftest dumb-jump-go-js2-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 11) (forward-char 76) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 7 35)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6a-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 20) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 1 4)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6b-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 21) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6c-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 22) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 5 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6d-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 23) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 10 2)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6e-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 24) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 16 2)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-js-es6-class-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "es6.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 36) (forward-char 12) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 28 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-sig-def-test () (let ((dumb-jump-aggressive t) (js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 7) (forward-char 35) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 6 25)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-sig-def2-test () (let ((dumb-jump-aggressive t) (js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 13) (forward-char 35) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 12 32)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-sig-def3-test () (let ((dumb-jump-aggressive t) (js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 20) (forward-char 35) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 19 32)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-var-let-test () (let ((dumb-jump-aggressive t) (el-file (f-join test-data-dir-elisp "fake2.el"))) (with-current-buffer (find-file-noselect el-file t) (goto-char (point-min)) (forward-line 13) (forward-char 33) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 11 10)) (should (string= el-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-var-let-repeat-test () (let ((dumb-jump-aggressive t) (el-file (f-join test-data-dir-elisp "fake2.el"))) (with-current-buffer (find-file-noselect el-file t) (goto-char (point-min)) (forward-line 21) (forward-char 33) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 18 10)) (should (string= el-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-var-arg-test () (let ((dumb-jump-aggressive t) (el-file (f-join test-data-dir-elisp "fake2.el"))) (with-current-buffer (find-file-noselect el-file t) (goto-char (point-min)) (forward-line 4) (forward-char 12) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 27)) (should (string= el-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-no-result-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 1) (forward-char 4) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-message "'%s' %s %s declaration not found." "nothing" * *)) (with-no-warnings (dumb-jump-go)))))) (ert-deftest dumb-jump-go-no-rules-test () (let ((txt-file (f-join test-data-dir-proj1 "src" "js" "nocode.txt"))) (with-current-buffer (find-file-noselect txt-file t) (goto-char (point-min)) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-message "Could not find rules for '%s'." ".txt file")) (with-no-warnings (dumb-jump-go)))))) (ert-deftest dumb-jump-go-too-long-test () (let ((txt-file (f-join test-data-dir-proj1 "src" "js" "nocode.txt")) (dumb-jump-max-find-time 0.2)) (with-current-buffer (find-file-noselect txt-file t) (goto-char (point-min)) (noflet ((dumb-jump-fetch-file-results (&optional _prompt) (with-no-warnings (if (version< emacs-version "29.1") (sleep-for 0 300) (sleep-for 0.3))) '(:results (:result)))) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-message "Took over %ss to find '%s'. Please install ag or rg, or add a .dumbjump file to '%s' with path exclusions" * * *)) (mock (dumb-jump-result-follow * * *)) (with-no-warnings (dumb-jump-go))))))) (ert-deftest dumb-jump-message-handle-results-test () (let ((dumb-jump-aggressive t) (results '((:path "src/file.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/file.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock-forbidding-prompt (mock (dumb-jump-goto-file-line "src/file.js" 62 4)) (dumb-jump-handle-results results "src/file.js" "/code/redux" "" "isNow" nil nil)))) (ert-deftest dumb-jump-message-handle-results-choices-test () (let ((results '((:path "src/file2.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/file2.js" :line 63 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/file2.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock (mock (dumb-jump-prompt-user-for-choice "/code/redux" *)) (dumb-jump-handle-results results "src/file.js" "/code/redux" "" "isNow" nil nil)))) (ert-deftest dumb-jump-grep-installed?-bsd-test () (let ((dumb-jump--grep-installed? 'unset)) (with-mock (mock (shell-command-to-string *) => "grep (BSD grep) 2.5.1-FreeBSD\n" :times 1) (should (eq (dumb-jump-grep-installed?) 'bsd))) ;; confirm memoization of the previous result (should (eq (dumb-jump-grep-installed?) 'bsd)))) (ert-deftest dumb-jump-grep-installed?-gnu-test () (let ((dumb-jump--grep-installed? 'unset)) (with-mock (mock (shell-command-to-string *) => "grep (GNU grep) 2.4.2\n" :times 1) (should (eq (dumb-jump-grep-installed?) 'gnu)) ;; confirm memoization of the previous result (should (eq (dumb-jump-grep-installed?) 'gnu))))) (ert-deftest dumb-jump-ag-installed?-test () (let ((dumb-jump--ag-installed? 'unset)) (with-mock (mock (shell-command-to-string *) => "ag version 0.33.0\n" :times 1) (should (eq (dumb-jump-ag-installed?) t)) ;; confirm memoization of the previous result (should (eq (dumb-jump-ag-installed?) t))))) (ert-deftest dumb-jump-git-grep-plus-ag-installed?-test () (let ((dumb-jump--git-grep-plus-ag-installed? 'unset) (dumb-jump--ag-installed? 'unset) (dumb-jump--git-grep-installed? 'unset)) (with-mock ;; this isn't ideal but combining the ag and git grep responses but this shouldn't matter in practice with :times 2 (mock (shell-command-to-string *) => "ag version 0.33.0\nfatal: no pattern given\n" :times 2) (should (eq (dumb-jump-git-grep-plus-ag-installed?) t)) ;; confirm memoization of the previous result (should (eq (dumb-jump-git-grep-plus-ag-installed?) t))))) (ert-deftest dumb-jump-rg-installed?-test-no () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 0.3.1\n" :times 1) (should (not (eq (dumb-jump-rg-installed?) t))) ;; confirm memoization of the previous result (should (not (eq (dumb-jump-rg-installed?) t)))))) (ert-deftest dumb-jump-rg-installed?-test-yes () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 0.10.0\n\nfeatures:+pcre2\n\n" :times 1) (should (eq (dumb-jump-rg-installed?) t)) ;; confirm memoization of the previous result (should (eq (dumb-jump-rg-installed?) t))))) (ert-deftest dumb-jump-rg-installed?-test-old () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 0.09.0\n\nfeatures:+pcre2\n\n" :times 1) (should (eq (dumb-jump-rg-installed?) nil)) ;; confirm memoization of the previous result (should (eq (dumb-jump-rg-installed?) nil))))) (ert-deftest dumb-jump-rg-installed?-test-yes-no-pcre2 () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 0.10.0\n" :times 1) (should (eq (dumb-jump-rg-installed?) nil)) ;; confirm memoization of the previous result (should (eq (dumb-jump-rg-installed?) nil))))) (ert-deftest dumb-jump-rg-installed?-test-yes2 () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 1.1.0\n\n\nfeatures:+pcre2\n" :times 1) (should (eq (dumb-jump-rg-installed?) t)) ;; confirm memoization of the previous result (should (eq (dumb-jump-rg-installed?) t))))) (ert-deftest dumb-jump-rg-installed?-test-yes2-no-pcre2 () (let ((dumb-jump--rg-installed? 'unset)) (with-mock (mock (executable-find *) => t) (mock (shell-command-to-string *) => "ripgrep 1.1.0\n" :times 1) (should (eq (dumb-jump-rg-installed?) nil)) ;; confirm memoization of the previous result (should (eq (dumb-jump-rg-installed?) nil))))) (ert-deftest dumb-jump-git-grep-installed?-test () (let ((dumb-jump--git-grep-installed? 'unset)) (with-mock (mock (shell-command-to-string *) => "fatal: no pattern given\n" :times 1) (should (eq (dumb-jump-git-grep-installed?) t)) ;; confirm memoization of the previous result (should (eq (dumb-jump-git-grep-installed?) t))))) (ert-deftest dumb-jump-go-nogrep-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-char 13) (with-mock-forbidding-prompt ;; (mock (executable-find *) => t) (mock (dumb-jump-rg-installed?) => nil) (mock (dumb-jump-ag-installed?) => nil) (mock (dumb-jump-git-grep-installed?) => nil) (mock (dumb-jump-grep-installed?) => nil) (mock (dumb-jump-message "Please install ag, rg, git grep or grep!")) (with-no-warnings (dumb-jump-go)))))) (ert-deftest dumb-jump-go-nosymbol-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 1) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-message "No symbol under point.")) (with-no-warnings (dumb-jump-go)))))) (ert-deftest dumb-jump-message-get-results-nogrep-test () (with-mock ;; (mock (executable-find *) => t) (mock (dumb-jump-rg-installed?) => nil) (mock (dumb-jump-ag-installed?) => nil) (mock (dumb-jump-git-grep-installed?) => nil) (mock (dumb-jump-grep-installed?) => nil) (let ((results (dumb-jump-get-results))) (should (eq (plist-get results :issue) 'nogrep))))) (ert-deftest dumb-jump-message-result-follow-test () (with-mock (mock (dumb-jump-goto-file-line "src/file.js" 62 4)) (let ((result '(:path "src/file.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow"))) (dumb-jump--result-follow result)))) (ert-deftest dumb-jump-message-result-follow-remote-fullpath-test () (with-mock (mock (dumb-jump-goto-file-line * * *)) (mock (file-remote-p *) => "/ssh:user@1.2.3.4#5678:") (let ((result '(:path "/usr/src/file.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow"))) (should (string= (dumb-jump--result-follow result) "/ssh:user@1.2.3.4#5678:/usr/src/file.js"))))) (ert-deftest dumb-jump-message-result-follow-remote-relative-test () (with-mock (mock (dumb-jump-goto-file-line * * *)) (mock (file-remote-p *) => "/ssh:user@1.2.3.4#5678:") (let ((result '(:path "here/is/file.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow")) (default-directory "/ssh:user@1.2.3.4#5678:/path/to/default-directory/")) (should (string= (dumb-jump--result-follow result) "/ssh:user@1.2.3.4#5678:/path/to/default-directory/here/is/file.js"))))) (ert-deftest dumb-jump-message-result-follow-tooltip-test () (with-mock (mock (dumb-jump--show-preview "/file.js:62: var isNow = true")) (let ((result '(:path "src/file.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow"))) (dumb-jump--result-follow result t "src")))) (ert-deftest dumb-jump-populate-regexes-grep-test () (should (equal (dumb-jump-populate-regexes "testvar" '("JJJ\\s*=\\s*") 'grep) '("testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "$testvar" '("JJJ\\s*=\\s*") 'grep) '("\\$testvar\\s*=\\s*")))) (ert-deftest dumb-jump-populate-regexes-ag-test () (should (equal (dumb-jump-populate-regexes "testvar" '("JJJ\\s*=\\s*") 'ag) '("testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "$testvar" '("JJJ\\s*=\\s*") 'ag) '("\\$testvar\\s*=\\s*")))) (ert-deftest dumb-jump-populate-regexes-git-grep-plus-ag-test () ;; this is effectively the same as `ag even with 'git-grep-plus-ag since that's where the regexes are used in this mode (should (equal (dumb-jump-populate-regexes "testvar" '("JJJ\\s*=\\s*") 'git-grep-plus-ag) '("testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "$testvar" '("JJJ\\s*=\\s*") 'git-grep-plus-ag) '("\\$testvar\\s*=\\s*")))) (ert-deftest dumb-jump-populate-regexes-rg-test () (should (equal (dumb-jump-populate-regexes "testvar" '("JJJ\\s*=\\s*") 'rg) '("testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "$testvar" '("JJJ\\s*=\\s*") 'rg) '("\\$testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "-testvar" '("JJJ\\s*=\\s*") 'rg) '("-testvar\\s*=\\s*")))) (ert-deftest dumb-jump-populate-regexes-git-grep-test () (should (equal (dumb-jump-populate-regexes "testvar" '("JJJ\\s*=\\s*") 'git-grep) '("testvar\\s*=\\s*"))) (should (equal (dumb-jump-populate-regexes "$testvar" '("JJJ\\s*=\\s*") 'git-grep) '("\\$testvar\\s*=\\s*")))) (ert-deftest dumb-jump-message-prin1-test () (with-mock (mock (message "%s %s" "(:path \"test\" :line 24)" "3")) (dumb-jump-message-prin1 "%s %s" '(:path "test" :line 24) 3))) (ert-deftest dumb-jump-message-test () (with-mock (mock (message "%s %s" "two" "three")) (dumb-jump-message "%s %s" "two" "three"))) (ert-deftest dumb-jump-concat-command-test () (should (string= (dumb-jump-concat-command " test1 " "test2 " " test3") "test1 test2 test3"))) (ert-deftest dumb-jump-issue-result-test () (let ((result (dumb-jump-issue-result "unsaved"))) (should (eq (plist-get result :issue) 'unsaved)))) (ert-deftest dumb-jump-process-symbol-by-lang-test () (let ((result (dumb-jump-process-symbol-by-lang "elisp" "somefunc")) (result2 (dumb-jump-process-symbol-by-lang "clojure" "myns/myfunc")) (result3 (dumb-jump-process-symbol-by-lang "ruby" ":myrubyfunc")) (result3b (dumb-jump-process-symbol-by-lang "ruby" "Health::Checks::QueueGrowth")) (result3c (dumb-jump-process-symbol-by-lang "ruby" "::Health")) (result4 (dumb-jump-process-symbol-by-lang "systemverilog" "`myvlfunc"))) (should (string= result "somefunc")) (should (string= result2 "myfunc")) (should (string= result3 "myrubyfunc")) (should (string= result3b "QueueGrowth")) (should (string= result3c "Health")) (should (string= result4 "myvlfunc")))) (ert-deftest dumb-jump--result-follow-test () (let* ((data '(:path "/usr/blah/test2.txt" :line 52 :context "var thing = function()" :target "a"))) (with-mock (mock (dumb-jump-goto-file-line "/usr/blah/test2.txt" 52 1)) (dumb-jump--result-follow data nil "/usr/blah")))) (ert-deftest dumb-jump-go-include-lib-test () (let ((el-file (f-join test-data-dir-elisp "fake2.el")) (lib-file (f-join test-data-dir-elisp "../fake-library/lib.el"))) (with-current-buffer (find-file-noselect el-file t) (goto-char (point-min)) (forward-line 23) (forward-char 19) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 4 7)) (should (string= (with-no-warnings (dumb-jump-go)) lib-file)))))) (ert-deftest dumb-jump-parse-response-line-test () (let ((t1 (dumb-jump-parse-response-line "/opt/test/foo.js:44: var test = 12;" "/opt/test/blah.js")) (t1b (dumb-jump-parse-response-line "/path/to/file.f90:1701: subroutine test(foo)" "/path/to/file2.f90")) (t2 (dumb-jump-parse-response-line "47: var test = 13;" "/opt/test/blah.js")) (t3 (dumb-jump-parse-response-line "c:\\Users\\test\\foo.js:1: var test = 14;" "c:\\Users\\test\\foo.js")) (t4 (dumb-jump-parse-response-line "c:\\Users\\test\\foo2.js:2:test = {a:1,b:1};" "c:\\Users\\test\\foo.js")) (t5 (dumb-jump-parse-response-line "/opt/test/foo1.js:41: var test = {c:3, d: 4};" "/opt/test/b2.js"))) ;; normal (should (equal t1 '("/opt/test/foo.js" "44" " var test = 12;"))) ;; normal fortran (should (equal t1b '("/path/to/file.f90" "1701" " subroutine test(foo)"))) ;; no file name in response (searched single file) (should (equal t2 '("/opt/test/blah.js" "47" " var test = 13;"))) ;; windows (should (equal t3 '("c:\\Users\\test\\foo.js" "1" " var test = 14;"))) ;; windows w/ extra : (should (equal t4 '("c:\\Users\\test\\foo2.js" "2" "test = {a:1,b:1};"))) ;; normal w/ extra : (should (equal t5 '("/opt/test/foo1.js" "41" " var test = {c:3, d: 4};"))))) (ert-deftest dumb-jump-agtype-test () (should (equal (dumb-jump-get-ag-type-by-language "python") '("python")))) (ert-deftest dumb-jump-rgtype-test () (should (equal (dumb-jump-get-rg-type-by-language "python") '("py")))) (ert-deftest dumb-jump-git-grep-type-test () (should (equal (dumb-jump-get-git-grep-type-by-language "python") '("py")))) ;; react tests (ert-deftest dumb-jump-react-test1 () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "react.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 8) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-react-test2 () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "react.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 22) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 13 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-react-test3 () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "react.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 27) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 26 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-react-test4 () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "react.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 32) (forward-char 7) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 31 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-react-test5 () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "react.js"))) (with-current-buffer (find-file-noselect js-file t) (goto-char (point-min)) (forward-line 39) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 37 6)) (should (string= js-file (with-no-warnings (dumb-jump-go)))))))) ;; c++ tests (ert-deftest dumb-jump-cpp-test1 () (let ((cpp-file (f-join test-data-dir-proj1 "src" "cpp" "test.cpp"))) (with-current-buffer (find-file-noselect cpp-file t) (goto-char (point-min)) (forward-line 8) (forward-char 14) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 3 6)) (should (string= cpp-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-cpp-test2 () (let ((cpp-file (f-join test-data-dir-proj1 "src" "cpp" "test.cpp"))) (with-current-buffer (find-file-noselect cpp-file t) (goto-char (point-min)) (forward-line 8) (forward-char 9) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 1 6)) (should (string= cpp-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-cpp-issue87 () (let ((cpp-file (f-join test-data-dir-proj1 "src" "cpp" "issue-87.cpp"))) (with-current-buffer (find-file-noselect cpp-file t) (goto-char (point-min)) (forward-line 16) (forward-char 12) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 6 18)) (should (string= cpp-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-org-test1 () (let ((org-file (f-join test-data-dir-proj1 "src" "org" "test.org")) (oldpar dumb-jump-force-searcher)) (setq dumb-jump-force-searcher 'rg) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 3) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 9 6)) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar))) (ert-deftest dumb-jump-org-test2 () (let ((org-file (f-join test-data-dir-proj1 "src" "org" "test.org")) (oldpar dumb-jump-force-searcher)) (setq dumb-jump-force-searcher 'rg) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 14) (forward-char 10) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 21 2)) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar))) (ert-deftest dumb-jump-org-issue135 () (require 'org) (require 'ob-python) (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (let ((org-file (f-join test-data-dir-proj1 "src" "org" "test.org")) (oldpar dumb-jump-force-searcher) (oldproject dumb-jump-project)) ;; in docker test AG version is 0.3 and 2.1.0 is needed (setq dumb-jump-force-searcher 'rg) ;; old version of org does not lead to point to the right directory (if (version< org-version "9") (setq dumb-jump-project (f-join test-data-dir-proj1 "src" "org"))) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 3) (forward-char 2) (org-edit-src-code) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 9 6)) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (if (version< org-version "9") (setq dumb-jump-project oldproject)))) (ert-deftest dumb-jump-org-named-block-test () "Test jumping to org named block definition" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 38) ; Line 39: "Test for uniqueblock lookup: uniqueblock" (forward-char 34) ; Position cursor on "uniqueblock" at end of line (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 41 8)) ; Line 41 is #+name: uniqueblock (col 8) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) (ert-deftest dumb-jump-org-heading-test () "Test jumping to org heading" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 65) ; Line 66: "Reference to MainTopic heading: MainTopic" (forward-char 35) ; Position cursor on "MainTopic" at end of line (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 68 4)) ; Line 68 is *** MainTopic (col 4) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) (ert-deftest dumb-jump-org-custom-id-test () "Test jumping to org CUSTOM_ID" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 57) ; Line 58: "See also the section with ID call-section for more info." (forward-char 34) ; Position cursor on "call-section" (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 55 12)) ; Line 55 is :CUSTOM_ID: call-section (col 12) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) (ert-deftest dumb-jump-org-call-test () "Test jumping from #+call reference to named block definition" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 61) ; Line 62: "#+CALL: UPPERCASE()" (forward-char 8) ; Position cursor on "UPPERCASE" (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 20 8)) ; Line 20 is #+NAME: UPPERCASE (col 8) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) (ert-deftest dumb-jump-org-named-block-nospace-test () "Test jumping to org named block definition without space after colon" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 45) ; Line 46: "Test for nospace lookup: nospace" (forward-char 28) ; Position cursor on "nospace" at end of line (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 48 7)) ; Line 48 is #+name:nospace (col 7) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) (ert-deftest dumb-jump-org-custom-id-nospace-test () "Test jumping to org CUSTOM_ID without space after colon" (let ((org-file (f-join test-data-dir-proj1 "src" "org" "named-blocks.org")) (oldpar dumb-jump-force-searcher) (old-rg-installed dumb-jump--rg-installed?)) (setq dumb-jump-force-searcher 'rg) (setq dumb-jump--rg-installed? 'unset) (with-current-buffer (find-file-noselect org-file t) (goto-char (point-min)) (forward-line 87) ; Line 88: "Reference to nospace-id custom ID: nospace-id" (forward-char 36) ; Position cursor on "nospace-id" at end of line (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 85 11)) ; Line 85 is :CUSTOM_ID:nospace-id (col 11) (should (string= org-file (with-no-warnings (dumb-jump-go)))))) (setq dumb-jump-force-searcher oldpar) (setq dumb-jump--rg-installed? old-rg-installed))) ;; This test verifies that having ".dumbjumpignore" files in the two sub-projects will make it find ;; the "multiproj" folder as project root since it has a ".dumbjump" file. The two sub-projects have ;; a dummy ".git" folder to signify it as a repository that would normally become the root without ;; the ignore file. (ert-deftest dumb-jump-multiproj () (let ((main-file (f-join test-data-dir-multiproj "subproj1" "main.cc")) (header-file (f-join test-data-dir-multiproj "subproj2" "header.h"))) (with-current-buffer (find-file-noselect main-file t) (goto-char (point-min)) (forward-line 3) (forward-char 18) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 6 6)) (should (string= header-file (with-no-warnings (dumb-jump-go)))))))) ;; This test makes sure that even though there's a local match it will jump to the external file ;; match instead. (ert-deftest dumb-jump-prefer-external () (let ((dumb-jump-aggressive t) (main-file (f-join test-data-dir-proj1 "src" "cpp" "external.cpp")) (header-file (f-join test-data-dir-proj1 "src" "cpp" "external.h"))) (with-current-buffer (find-file-noselect main-file t) (goto-char (point-min)) (forward-line 10) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 4 6)) (should (string= header-file (with-no-warnings (dumb-jump-go-prefer-external)))))))) (ert-deftest dumb-jump-prefer-only-external () (let ((main-file (f-join test-data-dir-multiproj "subproj1" "main.cc")) (header-file (f-join test-data-dir-multiproj "subproj2" "header.h"))) (with-current-buffer (find-file-noselect main-file t) (goto-char (point-min)) (forward-line 3) (forward-char 18) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 6 6)) (should (string= header-file (with-no-warnings (dumb-jump-go-prefer-external)))))))) (ert-deftest dumb-jump-prefer-external-only-current () (let ((main-file (f-join test-data-dir-proj1 "src" "cpp" "only.cpp"))) (with-current-buffer (find-file-noselect main-file t) (goto-char (point-min)) (forward-line 1) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 6 6)) (should (string= main-file (with-no-warnings (dumb-jump-go-prefer-external)))))))) (ert-deftest dumb-jump-prefer-external-other-window () (let ((dumb-jump-aggressive t) (main-file (f-join test-data-dir-proj1 "src" "cpp" "external.cpp")) (header-file (f-join test-data-dir-proj1 "src" "cpp" "external.h"))) (with-current-buffer (find-file-noselect main-file t) (goto-char (point-min)) (forward-line 10) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 4 6)) (should (string= header-file (with-no-warnings (dumb-jump-go-prefer-external-other-window)))))))) (ert-deftest dumb-jump-filter-no-start-comments () (should (equal '((:context "yield me")) (dumb-jump-filter-no-start-comments '((:context "// filter me out") (:context "yield me")) "c++")))) (ert-deftest dumb-jump-filter-no-start-comments-unknown-language () (should (equal nil (dumb-jump-filter-no-start-comments '() "unknownlanguage")))) (defun generators-valid (pl searcher) (and (eq 8 (length pl)) (functionp (plist-get pl :parse)) (functionp (plist-get pl :generate)) (functionp (plist-get pl :installed)) (eq searcher (plist-get pl :searcher)))) (ert-deftest dumb-jump-generators-by-searcher-git-grep () (let* ((searcher 'git-grep) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (ert-deftest dumb-jump-generators-by-searcher-ag () (let* ((searcher 'ag) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (ert-deftest dumb-jump-generators-by-searcher-git-grep-plus-ag () (let* ((searcher 'git-grep-plus-ag) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (ert-deftest dumb-jump-generators-by-searcher-rg () (let* ((searcher 'rg) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (ert-deftest dumb-jump-generators-by-searcher-gnu-grep () (let* ((searcher 'gnu-grep) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (ert-deftest dumb-jump-generators-by-searcher-grep () (let* ((searcher 'grep) (gen-funcs (dumb-jump-generators-by-searcher searcher))) (should (generators-valid gen-funcs searcher)))) (defun generator-plist-equal (pl1 pl2) (and (eq (length pl1) (length pl2)) (eq (plist-get pl1 :parse) (plist-get pl2 :parse)) (eq (plist-get pl1 :generate) (plist-get pl2 :generate)) (eq (plist-get pl1 :installed) (plist-get pl2 :installed)) (eq (plist-get pl1 :searcher) (plist-get pl2 :searcher)))) ;; Test the search tool selection based on the 2 user-options: ;; - `dumb-jump-prefer-searcher' ;; - `dumb-jump-force-searcher' acting as an override ;; First run simple tests that only check one combination. (ert-deftest dumb-jump-selected-grep-variant-test-nil-nil-with-nothing () (let ((dumb-jump-prefer-searcher nil) (dumb-jump-force-searcher nil)) (with-mock ;; (mock (executable-find *) => t) (mock (dumb-jump-ag-installed?) => nil) (mock (dumb-jump-rg-installed?) => nil) (mock (dumb-jump-grep-installed?) => 'bsd) (should (eq (dumb-jump-selected-grep-variant) 'grep))))) (ert-deftest dumb-jump-selected-grep-variant-test-nil-nil-with-really-nothing () (let ((dumb-jump-prefer-searcher nil) (dumb-jump-force-searcher nil)) (with-mock ;; (mock (executable-find *) => t) (mock (dumb-jump-ag-installed?) => nil) (mock (dumb-jump-rg-installed?) => nil) (mock (dumb-jump-grep-installed?) => nil) ;; [:todo 2026-01-14, by Pierre Rouleau: When dumb-jump-grep-installed? ;; returns nil the selection is still 'grep. Is this OK??] (should (eq (dumb-jump-selected-grep-variant) 'grep))))) (ert-deftest dumb-jump-selected-grep-variant-test-nil-nil-with-ag () (let ((dumb-jump-prefer-searcher nil) (dumb-jump-force-searcher nil)) (with-mock (mock (dumb-jump-ag-installed?) => t) (should (eq (dumb-jump-selected-grep-variant) 'ag))))) (ert-deftest dumb-jump-selected-grep-variant-test-nil-nil-with-rg () (let ((dumb-jump-prefer-searcher nil) (dumb-jump-force-searcher nil)) (with-mock ;; (mock (executable-find *) => t) (mock (dumb-jump-ag-installed?) => nil) (mock (dumb-jump-rg-installed?) => t) (should (eq (dumb-jump-selected-grep-variant) 'rg))))) (ert-deftest dumb-jump-selected-grep-variant-test-ag-nil () (let ((dumb-jump-prefer-searcher 'ag) (dumb-jump-force-searcher nil)) (with-mock (mock (dumb-jump-ag-installed?) => t) (should (eq (dumb-jump-selected-grep-variant) 'ag))))) (ert-deftest dumb-jump-selected-grep-variant-test-rg-nil () (let ((dumb-jump-prefer-searcher 'rg) (dumb-jump-force-searcher nil)) (with-mock (mock (dumb-jump-rg-installed?) => t) (should (eq (dumb-jump-selected-grep-variant) 'rg))))) (ert-deftest dumb-jump-selected-grep-variant-test-rg-grep () (let ((dumb-jump-prefer-searcher 'rg) (dumb-jump-force-searcher 'grep)) (should (eq (dumb-jump-selected-grep-variant) 'grep)))) (ert-deftest dumb-jump-selected-grep-variant-test-grep-nil () (let ((dumb-jump-prefer-searcher 'grep) (dumb-jump-force-searcher nil)) (should (eq (dumb-jump-selected-grep-variant) 'grep)))) (ert-deftest dumb-jump-selected-grep-variant-test-gnu-grep-nil () (let ((dumb-jump-prefer-searcher 'gnu-grep) (dumb-jump-force-searcher nil)) (should (eq (dumb-jump-selected-grep-variant) 'gnu-grep)))) ;; Run a test that go through all combinations (defvar dumb-jump-search-selector-tester-choice nil "What `dumb-jump-search-selector-tester' returns.") (defun dumb-jump-search-selector-tester (_dir) "Mocker for a user-supplied selector as override. Ignore DIR." dumb-jump-search-selector-tester-choice) (ert-deftest dumb-jump-selected-grep-variant-tests () (let ((dumb-jump-prefer-searcher nil) (dumb-jump-force-searcher nil)) (with-mock ;; (mock (executable-find *) => t) (mock (dumb-jump-ag-installed?) => t) (mock (dumb-jump-rg-installed?) => t) (mock (dumb-jump-grep-installed?) => 'gnu) (mock (dumb-jump-git-grep-installed?) => t) ;; [:todo 2026-01-14, by Pierre Rouleau: the next one is never called. Why?] ;; (mock (dumb-jump--git-grep-plus-ag-installed?) => t) (dolist (dumb-jump-prefer-searcher '(ag rg grep gnu-grep git-grep git-grep-plus-ag)) ;; ;; When there is no overriding, the preference is honoured. (setq dumb-jump-force-searcher nil) (should (eq (dumb-jump-selected-grep-variant) dumb-jump-prefer-searcher)) ;; ;; when there is an overriding of the old/deprecated style, ;; the preference is ignored. (dolist (dumb-jump-force-searcher '(ag rg grep gnu-grep git-grep git-grep-plus-ag)) (should (eq (dumb-jump-selected-grep-variant) dumb-jump-force-searcher))) ;; ;; When the overriding is provided by a user-specified function, that ;; function determines the selection. Drive user selection via the ;; `dumb-jump-search-selector-tester-choice' variable in this test: (setq dumb-jump-force-searcher #'dumb-jump-search-selector-tester) (dolist (dumb-jump-search-selector-tester-choice '(ag rg grep gnu-grep git-grep git-grep-plus-ag)) (should (eq (dumb-jump-selected-grep-variant) dumb-jump-search-selector-tester-choice))) ;; ;; When the provided overriding is based on directories: the identified ;; directories in the list are requesting the use of git-grep but only ;; inside those directories (setq dumb-jump-force-searcher (list (f-expand "."))) (should (eq (dumb-jump-selected-grep-variant (f-expand ".")) 'git-grep)) ;; ;; When overriding for a directory that is not the current directory, ;; then this overriding does not take effect and the ;; `dumb-jump-prefer-searcher' value is used. (setq dumb-jump-force-searcher '("/some/non/existing/directory")) (should (eq (dumb-jump-selected-grep-variant (f-expand ".")) dumb-jump-prefer-searcher)))))) ;; -- (ert-deftest dumb-jump-pick-grep-variant-force () (let* ((dumb-jump-force-searcher 'grep) (gen-funcs (dumb-jump-generators-by-searcher 'grep)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) ;; The following test no longer represents what the searcher selection logic ;; does but what it used to do: always select git-grep when the project ;; directory is a Git repo even when `dumb-jump-force-searcher' was nil. ;; With the new logic, `dumb-jump-force-searcher' must be set to a user ;; function that selects Git Grep or the project directory is identified to ;; override it to Git Grep. ;; Therefore, the following test should be removed. ;; - For now I keep it to show the evolution. ;; The real test is now done by `dumb-jump-selected-grep-variant-tests' above. ;; ;; (ert-deftest dumb-jump-pick-grep-variant-git-grep-in-git-repo () ;; (let* ((dumb-jump-force-searcher nil) ;; (gen-funcs (dumb-jump-generators-by-searcher 'git-grep)) ;; (variant (dumb-jump-pick-grep-variant (f-expand ".")))) ;; (should (generator-plist-equal gen-funcs variant)))) (ert-deftest dumb-jump-pick-grep-variant-prefer () (let* ((dumb-jump-force-searcher nil) (dumb-jump-prefer-searcher 'grep) (gen-funcs (dumb-jump-generators-by-searcher 'grep)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) (ert-deftest dumb-jump-pick-grep-variant-fallback-ag () (let* ((dumb-jump-force-searcher nil) (dumb-jump-prefer-searcher nil) (dumb-jump--ag-installed? t) (dumb-jump--rg-installed? nil) (gen-funcs (dumb-jump-generators-by-searcher 'ag)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) (ert-deftest dumb-jump-pick-grep-variant-fallback-rg () (let* ((dumb-jump-force-searcher nil) (dumb-jump-prefer-searcher nil) (dumb-jump--ag-installed? nil) (dumb-jump--rg-installed? t) (gen-funcs (dumb-jump-generators-by-searcher 'rg)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) (ert-deftest dumb-jump-pick-grep-variant-fallback-gnu-grep () (let* ((dumb-jump-force-searcher nil) (dumb-jump-prefer-searcher nil) (dumb-jump--ag-installed? nil) (dumb-jump--rg-installed? nil) (dumb-jump--grep-installed? 'gnu) (gen-funcs (dumb-jump-generators-by-searcher 'gnu-grep)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) (ert-deftest dumb-jump-pick-grep-variant-fallback-grep () (let* ((dumb-jump-force-searcher nil) (dumb-jump-prefer-searcher nil) (dumb-jump--ag-installed? nil) (dumb-jump--rg-installed? nil) (dumb-jump--grep-installed? 'bsd) (gen-funcs (dumb-jump-generators-by-searcher 'grep)) (variant (dumb-jump-pick-grep-variant))) (should (generator-plist-equal gen-funcs variant)))) ;; This test makes sure that if the `cur-file' is absolute but results are relative, then it must ;; still find and sort results correctly. (ert-deftest dumb-jump-handle-results-relative-current-file-test () (let ((dumb-jump-aggressive t) (results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/absfile.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock (mock (dumb-jump-goto-file-line "relfile.js" 62 4)) (dumb-jump-handle-results results "/code/redux/relfile.js" "/code/redux" "" "isNow" nil nil)))) ;; Make sure it jumps aggressively, i.e. normally. (ert-deftest dumb-jump-handle-results-aggressively-test () (let ((dumb-jump-aggressive t) (results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/absfile.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock (mock (dumb-jump-goto-file-line "relfile.js" 62 4)) (dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" nil nil)))) ;; Make sure non-aggressive mode shows choices when more than one possibility. (ert-deftest dumb-jump-handle-results-non-aggressively-test () (let ((dumb-jump-aggressive nil) (results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/absfile.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock (mock (dumb-jump-prompt-user-for-choice "/code/redux" *)) (dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" nil nil)))) (ert-deftest dumb-jump-handle-results-non-aggressively-quick-look-test () (let ((dumb-jump-aggressive nil) (results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow") (:path "src/absfile.js" :line 69 :context "isNow = false" :diff 0 :target "isNow")))) (with-mock (mock (dumb-jump--select-choice '("relfile.js:62: var isNow = true" "src/absfile.js:69: isNow = false") "Matches: ") => "src/absfile.js:69: isNow = false") (mock (dumb-jump--show-preview "src/absfile.js:69: isNow = false") :times 1) (dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" t nil)))) ;; Make sure it jumps when there's only one possibility in non-aggressive mode. (ert-deftest dumb-jump-handle-results-non-aggressive-do-jump-test () (let ((dumb-jump-aggressive nil) (results '((:path "relfile.js" :line 62 :context "var isNow = true" :diff 7 :target "isNow")))) (with-mock (mock (dumb-jump-goto-file-line "relfile.js" 62 4)) (dumb-jump-handle-results results "relfile.js" "/code/redux" "" "isNow" nil nil)))) (ert-deftest dumb-jump-shell-command-switch-zsh-test () (let ((shell-file-name "/usr/bin/zsh")) (should (string-equal "-icf" (dumb-jump-shell-command-switch))))) (ert-deftest dumb-jump-shell-command-switch-csh-test () (let ((shell-file-name "/usr/bin/csh")) (should (string-equal "-icf" (dumb-jump-shell-command-switch))))) (ert-deftest dumb-jump-shell-command-switch-tcsh-test () (let ((shell-file-name "/usr/bin/zsh")) (should (string-equal "-icf" (dumb-jump-shell-command-switch))))) (ert-deftest dumb-jump-shell-command-switch-bash-test () (let ((shell-file-name "/usr/bin/bash")) (should (string-equal "-c" (dumb-jump-shell-command-switch))))) (ert-deftest dumb-jump-shell-command-switch-unknown-test () (let ((shell-file-name "/usr/bin/thisshelldoesnotexist")) (should (string-equal shell-command-switch (dumb-jump-shell-command-switch))))) (ert-deftest dumb-jump-go-clojure-question-mark-test () (let ((clj-jump-file (f-join test-data-dir-proj3 "file3.clj")) (clj-to-file (f-join test-data-dir-proj3 "file2.clj"))) (with-current-buffer (find-file-noselect clj-jump-file t) (funcall 'lisp-mode) ;; need a built in lisp mode so `?` is part of a symbol (goto-char (point-min)) (forward-line 2) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 1 6)) (should (string= clj-to-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-clojure-no-question-mark-test () (let ((clj-jump-file (f-join test-data-dir-proj3 "file3.clj")) (clj-to-file (f-join test-data-dir-proj3 "file1.clj"))) (with-current-buffer (find-file-noselect clj-jump-file t) (funcall 'lisp-mode) ;; need a built in lisp mode so `?` is part of a symbol (goto-char (point-min)) (forward-line 3) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 2 6)) (should (string= clj-to-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-clojure-no-asterisk-test () (let ((clj-jump-file (f-join test-data-dir-proj3 "file3.clj")) (clj-to-file (f-join test-data-dir-proj3 "file2.clj"))) (with-current-buffer (find-file-noselect clj-jump-file t) (funcall 'lisp-mode) ;; need a built in lisp mode so `?` is part of a symbol (goto-char (point-min)) (forward-line 4) (forward-char 2) (with-mock-forbidding-prompt ;; (stub dumb-jump-ag-installed? => t) (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 4 9)) (should (string= clj-to-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-go-clojure-asterisk-test () (let ((clj-jump-file (f-join test-data-dir-proj3 "file3.clj")) (clj-to-file (f-join test-data-dir-proj3 "file1.clj"))) (with-current-buffer (find-file-noselect clj-jump-file t) (funcall 'lisp-mode) ;; need a built in lisp mode so `?` is part of a symbol (goto-char (point-min)) (forward-line 5) (forward-char 2) (with-mock-forbidding-prompt (stub dumb-jump-rg-installed? => t) (mock (dumb-jump-goto-file-line * 5 7)) (should (string= clj-to-file (with-no-warnings (dumb-jump-go)))))))) (ert-deftest dumb-jump-format-files-as-ag-arg-test () (let* ((fake-files '("one" "two" "three")) (result (dumb-jump-format-files-as-ag-arg fake-files "path")) (expected "'(path/one|path/two|path/three)'")) (should (string= result expected)))) (ert-deftest dumb-jump-get-git-grep-files-matching-symbol-test () (with-mock (mock (shell-command-to-string "git grep --full-name -F -c symbol path") => "fileA:1\nfileB:2\n") (should (equal (dumb-jump-get-git-grep-files-matching-symbol "symbol" "path") '("fileA" "fileB"))))) (ert-deftest dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg-test () (with-mock (mock (shell-command-to-string "git grep --full-name -F -c symbol path") => "fileA:1\nfileB:2\n") (should (string= (dumb-jump-get-git-grep-files-matching-symbol-as-ag-arg "symbol" "path") "'(path/fileA|path/fileB)'")))) ;; --------------------------------------------------------------------------- ;; Tests for `dumb-jump-use-space-bracket-exp-for' (ert-deftest dumb-jump-use-space-bracket-exp-when-forced-on-grep () "Test dumb-jump-use-space-bracket-exp-for returned value." ;; When `dumb-jump-force-using-space-bracket-exp' is t (like on Windows): (let ((dumb-jump-force-using-space-bracket-exp t)) ;; It should return t for grep based tools to prevent problem when the ;; system uses an old version of grep that did not support \s (should (dumb-jump-use-space-bracket-exp-for 'grep)) (should (dumb-jump-use-space-bracket-exp-for 'gnu-grep)) (should (dumb-jump-use-space-bracket-exp-for 'git-grep)) (should (dumb-jump-use-space-bracket-exp-for 'git-grep-plus-ag)) ;; The other tools, ag, rg are not affected by this problem, so they can ;; use \s in their regular expressions. (should-not (dumb-jump-use-space-bracket-exp-for 'ag)) (should-not (dumb-jump-use-space-bracket-exp-for 'rg)) )) (ert-deftest dumb-jump-use-space-bracket-exp-when-not-forced () "Test that dumb-jump-use-space-bracket-exp-for returns nil when not forced." (let ((dumb-jump-force-using-space-bracket-exp nil)) (should-not (dumb-jump-use-space-bracket-exp-for 'grep)) (should-not (dumb-jump-use-space-bracket-exp-for 'gnu-grep)) (should-not (dumb-jump-use-space-bracket-exp-for 'git-grep)) (should-not (dumb-jump-use-space-bracket-exp-for 'ag)) (should-not (dumb-jump-use-space-bracket-exp-for 'rg)))) ;; --------------------------------------------------------------------------- ;; Tests space bracket expansion done by `dumb-jump-populate-regex' (ert-deftest dumb-jump-populate-regex-space-bracket-for-grep-tools-when-forced () "Test that \\s is replaced with [[:space:]] only for grep tools when forced." (let ((dumb-jump-force-using-space-bracket-exp t)) ;; When forced, the bracket space should only be used in grep tools (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-1" 'gnu-grep) "\\(defun[[:space:]]+test-1($|[^a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-2" 'grep) "\\(defun[[:space:]]+test-2($|[^a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-3" 'git-grep) "\\(defun[[:space:]]+test-3($|[^a-zA-Z0-9\\?\\*-])")) ;; but not for the others. ;; Note: ag uses a different regex (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-4" 'ag) "\\(defun\\s+test-4(?![a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-5" 'rg) "\\(defun\\s+test-5($|[^a-zA-Z0-9\\?\\*-])")))) (ert-deftest dumb-jump-populate-regex-space-bracket-for-no-tools-when-not-forced () "Test that \\s is replaced with [[:space:]] only for grep tools when forced." (let ((dumb-jump-force-using-space-bracket-exp nil)) ;; When not forced, the bracket space should not be used by any tool (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-1" 'gnu-grep) "\\(defun\\s+test-1($|[^a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-2" 'grep) "\\(defun\\s+test-2($|[^a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-3" 'git-grep) "\\(defun\\s+test-3($|[^a-zA-Z0-9\\?\\*-])")) ;; Note: ag uses a different regex (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-4" 'ag) "\\(defun\\s+test-4(?![a-zA-Z0-9\\?\\*-])")) (should (string= (dumb-jump-populate-regex "\\(defun\\s+JJJ\\j" "test-5" 'rg) "\\(defun\\s+test-5($|[^a-zA-Z0-9\\?\\*-])")))) ;;; jacktasia-dumb-jump-d345e21/test/github-actions-setup.sh000066400000000000000000000007761514775430200233060ustar00rootroot00000000000000 sudo apt-get -qq update || ls sudo apt-get install -y --no-install-recommends software-properties-common curl sudo apt-get -qq update || ls sudo apt-get install -y --no-install-recommends silversearcher-ag git python ruby sudo curl -LO https://github.com/BurntSushi/ripgrep/releases/download/0.10.0/ripgrep_0.10.0_amd64.deb && sudo dpkg -i ripgrep_0.10.0_amd64.deb #ENV PATH="/root/.evm/bin:$PATH" #ENV PATH="/root/.cask/bin:$PATH" sudo apt-get install -y --no-install-recommends make libgtk2.0-0 libsm-dev jacktasia-dumb-jump-d345e21/test/release.sh000077500000000000000000000204301514775430200206400ustar00rootroot00000000000000#!/usr/bin/env bash # test/release.sh # # Release workflow for dumb-jump: # - validate release prerequisites # - bump version when needed # - tag the current commit # - push branch + tag # - create GitHub release # # Usage: # bash test/release.sh check # bash test/release.sh release # bash test/release.sh dry-run set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" cd "${REPO_ROOT}" GH="${GH:-gh}" RELEASE_REPO="${RELEASE_REPO:-jacktasia/dumb-jump}" RELEASE_BRANCH="${RELEASE_BRANCH:-master}" RELEASE_NOTES_FILE="${RELEASE_NOTES_FILE:-}" RELEASE_GENERATE_NOTES="${RELEASE_GENERATE_NOTES:-1}" RELEASE_VERSION="${RELEASE_VERSION:-}" RELEASE_BUMP="${RELEASE_BUMP:-}" usage() { echo "Usage: bash test/release.sh [check|release|dry-run]" >&2 } require_cmd() { local cmd="$1" if ! command -v "${cmd}" >/dev/null 2>&1; then echo "error: ${cmd} is required." >&2 exit 1 fi } validate_semver() { local version="$1" if ! printf '%s' "${version}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "error: version '${version}' is not semver (X.Y.Z)." >&2 exit 1 fi } read_version() { local version version="$(sed -n 's/^;; Version:[[:space:]]*//p' dumb-jump.el | head -n 1)" if [[ -z "${version}" ]]; then echo "error: could not read version from dumb-jump.el." >&2 exit 1 fi validate_semver "${version}" printf '%s' "${version}" } version_to_tag() { local version="$1" printf '%s' "${RELEASE_TAG:-v${version}}" } bump_version() { local version="$1" local bump="$2" local major minor patch IFS='.' read -r major minor patch <<<"${version}" case "${bump}" in patch) patch=$((patch + 1)) ;; minor) minor=$((minor + 1)) patch=0 ;; major) major=$((major + 1)) minor=0 patch=0 ;; *) echo "error: RELEASE_BUMP must be one of: patch minor major." >&2 exit 1 ;; esac printf '%s.%s.%s' "${major}" "${minor}" "${patch}" } tag_exists_locally() { local tag="$1" git rev-parse -q --verify "refs/tags/${tag}" >/dev/null } tag_exists_on_origin() { local tag="$1" git ls-remote --tags --exit-code origin "refs/tags/${tag}" >/dev/null 2>&1 } tag_exists_anywhere() { local tag="$1" tag_exists_locally "${tag}" || tag_exists_on_origin "${tag}" } resolve_target_version() { local current_version current_tag current_version="$(read_version)" if [[ -n "${RELEASE_VERSION}" ]]; then validate_semver "${RELEASE_VERSION}" printf '%s' "${RELEASE_VERSION}" return fi if [[ -n "${RELEASE_BUMP}" ]]; then printf '%s' "$(bump_version "${current_version}" "${RELEASE_BUMP}")" return fi current_tag="$(version_to_tag "${current_version}")" if tag_exists_anywhere "${current_tag}"; then echo "info: ${current_tag} already exists; auto-bumping patch." >&2 printf '%s' "$(bump_version "${current_version}" "patch")" return fi printf '%s' "${current_version}" } update_version_file() { local new_version="$1" local tmp_file tmp_file="$(mktemp "${TMPDIR:-/tmp}/dumb-jump-version-XXXXXX")" if ! awk -v version="${new_version}" ' BEGIN { updated = 0 } { if (!updated && $0 ~ /^;; Version:[[:space:]]*/) { print ";; Version: " version updated = 1 } else { print $0 } } END { if (!updated) exit 2 } ' dumb-jump.el >"${tmp_file}"; then rm -f "${tmp_file}" echo "error: failed to update dumb-jump.el version." >&2 exit 1 fi mv "${tmp_file}" dumb-jump.el } commit_version_bump() { local version="$1" git add dumb-jump.el git commit -m "bump version to ${version}" >/dev/null echo "Committed version bump: ${version}" >&2 } prepare_version_for_release() { local current_version target_version current_version="$(read_version)" target_version="$(resolve_target_version)" if [[ "${target_version}" == "${current_version}" ]]; then echo "Release version: ${target_version}" >&2 printf '%s' "${target_version}" return fi echo "Bumping version from ${current_version} to ${target_version}" >&2 update_version_file "${target_version}" commit_version_bump "${target_version}" printf '%s' "${target_version}" } assert_on_release_branch() { local current_branch current_branch="$(git rev-parse --abbrev-ref HEAD)" if [[ "${current_branch}" != "${RELEASE_BRANCH}" ]]; then echo "error: checkout '${RELEASE_BRANCH}' before releasing." >&2 exit 1 fi } assert_clean_tree() { if [[ -n "$(git status --porcelain)" ]]; then echo "error: working tree is not clean." >&2 exit 1 fi } assert_tag_does_not_exist() { local tag="$1" if tag_exists_locally "${tag}"; then echo "error: local tag '${tag}' already exists." >&2 exit 1 fi if tag_exists_on_origin "${tag}"; then echo "error: remote tag '${tag}' already exists on origin." >&2 exit 1 fi } assert_gh_authenticated() { if ! "${GH}" auth status >/dev/null 2>&1; then echo "error: not authenticated with GitHub CLI (${GH})." >&2 exit 1 fi } release_check() { local current_version target_version tag require_cmd git require_cmd "${GH}" assert_on_release_branch assert_clean_tree current_version="$(read_version)" target_version="$(resolve_target_version)" tag="$(version_to_tag "${target_version}")" if [[ "${target_version}" != "${current_version}" ]]; then echo "Release check: would bump ${current_version} -> ${target_version}" fi assert_tag_does_not_exist "${tag}" assert_gh_authenticated echo "Release check passed for ${tag}" } release_create() { local target_version tag require_cmd git require_cmd "${GH}" assert_on_release_branch assert_clean_tree target_version="$(prepare_version_for_release)" tag="$(version_to_tag "${target_version}")" assert_tag_does_not_exist "${tag}" assert_gh_authenticated echo "Tagging ${tag} at $(git rev-parse --short HEAD)" git tag "${tag}" echo "Pushing ${RELEASE_BRANCH} and ${tag} to origin" git push origin "HEAD:refs/heads/${RELEASE_BRANCH}" git push origin "${tag}" echo "Creating GitHub release ${tag}" if [[ -n "${RELEASE_NOTES_FILE}" ]]; then "${GH}" release create "${tag}" \ --repo "${RELEASE_REPO}" \ --target "${RELEASE_BRANCH}" \ --title "${tag}" \ --notes-file "${RELEASE_NOTES_FILE}" elif [[ "${RELEASE_GENERATE_NOTES}" == "1" ]]; then "${GH}" release create "${tag}" \ --repo "${RELEASE_REPO}" \ --target "${RELEASE_BRANCH}" \ --title "${tag}" \ --generate-notes else "${GH}" release create "${tag}" \ --repo "${RELEASE_REPO}" \ --target "${RELEASE_BRANCH}" \ --title "${tag}" fi } release_dry_run() { local current_version target_version tag current_branch ready require_cmd git require_cmd "${GH}" current_version="$(read_version)" target_version="$(resolve_target_version)" tag="$(version_to_tag "${target_version}")" current_branch="$(git rev-parse --abbrev-ref HEAD)" ready=1 echo "Release dry run:" echo " current version: ${current_version}" echo " target version : ${target_version}" echo " target tag : ${tag}" echo " release branch : ${RELEASE_BRANCH}" echo " release repo : ${RELEASE_REPO}" if [[ -n "${RELEASE_NOTES_FILE}" ]]; then echo " release notes : file (${RELEASE_NOTES_FILE})" elif [[ "${RELEASE_GENERATE_NOTES}" == "1" ]]; then echo " release notes : generated" else echo " release notes : empty body" fi if [[ "${current_branch}" == "${RELEASE_BRANCH}" ]]; then echo " branch check : OK (${current_branch})" else echo " branch check : FAIL (current=${current_branch})" ready=0 fi if [[ -n "$(git status --porcelain)" ]]; then echo " tree check : FAIL (working tree is dirty)" ready=0 else echo " tree check : OK (clean)" fi if tag_exists_locally "${tag}"; then echo " local tag : FAIL (${tag} exists)" ready=0 else echo " local tag : OK (missing)" fi if tag_exists_on_origin "${tag}"; then echo " remote tag : FAIL (${tag} exists on origin)" ready=0 else echo " remote tag : OK (missing on origin)" fi if "${GH}" auth status >/dev/null 2>&1; then echo " gh auth : OK" else echo " gh auth : FAIL (not authenticated)" ready=0 fi echo " tests : not run automatically" if [[ "${ready}" -eq 1 ]]; then echo "Result: ready to run release." else echo "Result: not ready." exit 1 fi } main() { if [[ $# -ne 1 ]]; then usage exit 1 fi case "$1" in check) release_check ;; release) release_create ;; dry-run) release_dry_run ;; *) usage exit 1 ;; esac } main "$@" jacktasia-dumb-jump-d345e21/test/run-in-container.sh000077500000000000000000000037351514775430200224210ustar00rootroot00000000000000#!/usr/bin/env bash # test/run-in-container.sh # # Container entrypoint for running tests locally in Docker. # Executed inside a Docker container built from test/Dockerfile.local, # which is based on silex/emacs:-ci-cask. # # Emacs, Cask, git, and make are already in the base image. # Cask dependencies are installed during docker build. # This script verifies the toolchain and runs the tests. set -euo pipefail echo "========================================" echo " dumb-jump local Docker test runner " echo " $(emacs --version | head -1) " echo "========================================" echo "" echo "==> Toolchain versions:" echo -n " emacs : "; emacs --version | head -1 echo -n " rg : "; rg --version | head -1 echo -n " ag : "; ag --version | head -1 echo -n " git : "; git --version echo "" echo "" echo "==> Running ERT tests..." cd /repo # The built-in 'ert' reporter only fires after a test ends, making hangs # invisible. We write a small shim file and load it via --load so a # test-started hook prints each test name before it runs — a hang then # shows exactly which test is stuck. SHIM=$(mktemp /tmp/ert-runner-shim-XXXXXX.el) cat > "$SHIM" <<'EOF' (add-hook 'ert-runner-reporter-test-started-functions (lambda (stats test) (ert-runner-message "running: %S\n" (ert-test-name test)))) EOF # stdbuf -oL: force line-buffered stdout so each line appears immediately # rather than being held in the C stdio buffer until exit. # -ci-cask as the base image (Emacs + Cask pre-installed). # On Apple Silicon, Docker Desktop emulates amd64 via Rosetta 2 automatically. # # Usage: # bash test/run-tests-locally.sh [EMACS_VERSION] [TEST_PATTERN] # make test-docker # make test-docker EMACS_VERSION=28.2 # make test-this-docker dumb-jump-test-rg-rules-test # # Arguments: # EMACS_VERSION Emacs version to test against (default: 29.4) # Must be one of: 26.3 27.2 28.2 29.4 30.2 # TEST_PATTERN Optional ert-runner -p regex to run a filtered subset # # Examples: # bash test/run-tests-locally.sh # uses default (29.4) # bash test/run-tests-locally.sh 28.2 # bash test/run-tests-locally.sh 29.4 "dumb-jump-test-rg-rules-test" set -euo pipefail # ── Container engine detection ──────────────────────────────────────────────── # Prefer docker; fall back to podman (covers podman-docker installations where # the 'docker' shim may not be on PATH or the daemon socket differs). if command -v docker &>/dev/null; then DOCKER=docker elif command -v podman &>/dev/null; then DOCKER=podman else echo "ERROR: Neither docker nor podman found on PATH." >&2 echo "Install Docker Desktop: https://www.docker.com/products/docker-desktop/" >&2 echo "Or install Podman: https://podman.io/getting-started/installation" >&2 exit 1 fi # ── Configuration ───────────────────────────────────────────────────────────── # Positional arg takes priority over env var; env var is the Make-friendly path. EMACS_VERSION="${1:-${EMACS_VERSION:-29.4}}" TEST_PATTERN="${2:-${TEST_PATTERN:-}}" REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DOCKERFILE="${REPO_ROOT}/test/Dockerfile.local" # Tag images per Emacs version so different versions don't clobber each other's # Docker layer cache. IMAGE_TAG="dumb-jump-test:emacs-${EMACS_VERSION}" # Emacs versions matching the CI matrix (from .github/workflows/test.yml) SUPPORTED_VERSIONS="26.3 27.2 28.2 29.4 30.2" # ── Validation ──────────────────────────────────────────────────────────────── if ! "$DOCKER" info &>/dev/null; then echo "ERROR: ${DOCKER} daemon is not running. Please start it before running tests." >&2 exit 1 fi version_ok=0 for v in $SUPPORTED_VERSIONS; do if [[ "$v" == "$EMACS_VERSION" ]]; then version_ok=1 break fi done if [[ $version_ok -eq 0 ]]; then echo "ERROR: Emacs version '${EMACS_VERSION}' is not a supported version." >&2 echo "Supported versions: ${SUPPORTED_VERSIONS}" >&2 exit 1 fi # ── Info ────────────────────────────────────────────────────────────────────── echo "==> Running tests locally in Docker (engine: ${DOCKER})" echo " Emacs version : ${EMACS_VERSION}" echo " Docker image : ${IMAGE_TAG}" echo " Repo root : ${REPO_ROOT}" if [[ -n "$TEST_PATTERN" ]]; then echo " Test pattern : ${TEST_PATTERN}" fi echo "" # ── Build image ─────────────────────────────────────────────────────────────── # Pass EMACS_VERSION as a build arg so the Dockerfile pulls the matching # silex/emacs base image. Build context is repo root so the Dockerfile can # COPY test/run-in-container.sh. # # On Apple Silicon, the silex/emacs images are amd64-only; Docker Desktop # handles the emulation via Rosetta 2 (--platform linux/amd64 is set in # the Dockerfile's FROM line). # # Docker layer caching means subsequent builds for the same Emacs version are # fast. Source changes invalidate the repo snapshot layer only. echo "==> Building image for Emacs ${EMACS_VERSION}..." echo " (First pull of silex/emacs:${EMACS_VERSION}-ci-cask takes ~1-2 min;" echo " subsequent runs use Docker's layer cache)" "$DOCKER" build \ --file "${DOCKERFILE}" \ --tag "${IMAGE_TAG}" \ --build-arg "EMACS_VERSION=${EMACS_VERSION}" \ "${REPO_ROOT}" echo "" # ── Run tests ───────────────────────────────────────────────────────────────── # The image already contains a snapshot of the repo from build time. # --rm cleans up the container after it exits. echo "==> Launching test container..." # Note: no --tty here. Emacs runs in batch/noninteractive mode and spawns # subprocesses (ag, rg, grep) via shell-command. With --tty, those child # processes inherit the pseudo-TTY and can block waiting for terminal input # instead of exiting when done. Plain pipe I/O (no --tty) keeps them clean. docker_run_args=(--rm) if [[ -n "$TEST_PATTERN" ]]; then docker_run_args+=(--env "TEST_PATTERN=${TEST_PATTERN}") fi "$DOCKER" run "${docker_run_args[@]}" "${IMAGE_TAG}" jacktasia-dumb-jump-d345e21/test/test-helper.el000066400000000000000000000005011514775430200214340ustar00rootroot00000000000000;;; -*- lexical-binding: t -*- (require 'ert) (require 'undercover) (undercover "*.el" (:exclude "*-test.el") (:send-report t) (:report-file "/tmp/undercover-report.json")) (require 'dumb-jump) (require 'el-mock) (eval-when-compile (require 'cl-lib)) ;;; test-helper.el ends here