[
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    {one line to give the program's name and a brief idea of what it does.}\n    Copyright (C) {year}  {name of author}\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    {project}  Copyright (C) {year}  {fullname}\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n\n"
  },
  {
    "path": "README.org",
    "content": "[[http://melpa.org/#/link-hint][file:http://melpa.org/packages/link-hint-badge.svg]]\n\n* Demonstration\nUsing this package to install this package:\n[[http://noctuid.github.io/link-hint.el/assets/paradox_demonstration.gif][http://noctuid.github.io/link-hint.el/assets/paradox_demonstration.gif]]\n\n* About\n=link-hint.el= is inspired by the link hinting functionality in vim-like browsers and browser plugins such as pentadactyl. It provides commands for using avy to open, copy, or take a user-defined action on \"links.\"\n\nCurrently the following types of links are supported:\n\n- Plain text urls (e.g. =http://github.com=; includes irc urls and mailto)\n- File paths\n- Shr urls (e.g. elfeed links, links in html mu4e and gnus messages, eww urls, etc.)\n- Org mode urls (includes =mailto:= links)\n- Markdown links (including \"wiki links\"; see =markdown-enable-wiki-links=)\n- Mu4e links (urls and mailto addresses)\n- Mu4e attachments\n- Gnus html mail rendered with gnus-w3m or emacs-w3m (instead of shr)\n- Help mode links\n- Info mode links\n- Package menu links (describe package, install package, keyword buttons, etc.)\n- Compilation mode links\n- W3m links (urls, email addresses, etc.)\n- Customize links\n- Nov.el links\n- notmuch-hello links\n- Deadgrep matches\n- Other button links (e.g. WoMan/Man/Dictionary links, ag mode, epa-key-list-mode, etc.)\n- Completion List candidates (better put it before /link-hint-file-link/ for *project.el*)\n- Dired filenames\n- Org Agenda items\n- Xref items\n- Bug reference mode links\n\nFeel free to request support for any useful link type I may have missed. Also, if you think it would be beneficial to have a more specific link type split from a more generic link type, feel free to make an issue. For example, there may be some specific type of button you want to ignore or use in a custom command without affecting other buttons.\n\n** Similar\n*** Ace-link\nThere is also [[https://github.com/abo-abo/ace-link][ace-link]] which I didn't know about when writing this package. The main functional differences at the time of writing are as follows:\n\n- link-hint supports more link types\n- link-hint supports operating on multiple different types of links with the same command in the same buffer; types are optionally tied to major modes, but generic link support is also provided (e.g. buttons and file paths)\n- link-hint supports easily adding more link types and actions\n- link-hint supports operating on multiple links at a time\n\n*** Embark\nThere is some overlap with embark since both packages provide multiple actions for different types of things.  Here is a comparison:\n\n- Link-hint is mainly focused on links/buttons rather than types of =completing-reading= candidates\n- Link-hint is more focused on selecting links anywhere visible using avy\n- Both embark and link-hint can take different actions on different types of things at the point in a buffer; link-hint can actually fall back to using =embark-dwim= (see [[#at-point-fallback-commands][At Point Fallback Commands]])\n- If there is interest, link-hint can provide better integration with embark (provide feedback on issue #38 if interested)\n  - Add completing-read support (with support for choosing an action with embark or running =embark-collect=)\n  - Add a builtin link-hint action that just calls =embark-act= on the link position\n\n** Basic Setup\nBasic usage of this package only requires making key bindings for ~link-hint-open-link~ or other commands. Here is an example configuration using [[https://github.com/jwiegley/use-package][use-package]]:\n#+begin_src emacs-lisp\n(use-package link-hint\n  :ensure t\n  :bind\n  (\"C-c l o\" . link-hint-open-link)\n  (\"C-c l c\" . link-hint-copy-link))\n#+end_src\n\nHere is an example configuration for evil:\n#+begin_src emacs-lisp\n(use-package link-hint\n  :ensure t\n  :defer t)\n\n(define-key evil-normal-state-map (kbd \"SPC f\") 'link-hint-open-link)\n#+end_src\n\n** Browser Choice\n~browse-url~ is used for opening urls, so in the case that the desired browser is not being used by default, the user can set ~browse-url-browser-function~:\n\n#+begin_src emacs-lisp\n;; Use chromium to open urls\n(setq browse-url-browser-function 'browse-url-chromium)\n\n;; Use firefox to open urls\n(setq browse-url-browser-function 'browse-url-firefox)\n\n;; Use qutebrowser to open urls\n(setq browse-url-browser-function 'browse-url-generic)\n(setq browse-url-generic-program \"qutebrowser\")\n;; Open urls in a new tab instead of window; can also be set in the config file\n(setq browse-url-generic-args '(\"--target\" \"tab\"))\n#+end_src\n\n** Provided Commands\nThis package provides the following commands for operating on links:\n- ~link-hint-open-link-at-point~ - Open the link at point.\n- ~link-hint-copy-link-at-point~ - Copy the link at point to the kill ring (and optionally to the clipboard/primary).\n- ~link-hint-open-link~ - Use avy to select and open a single visible link. If only one link is currently visible, it will be automatically opened without the need for selection.\n- ~link-hint-open-multiple-links~ - Use avy to select multiple visible links and open them as soon as a key that does not correspond to a link (a key not in the avy overlay) is pressed (like pentadactyl's =g;=).\n- ~link-hint-open-all-links~ - Opens all links visible in the buffer.\n- ~link-hint-copy-link~ - Use avy to select and copy a single visible link to the kill ring. ~select-enable-clipboard~ and ~select-enable-clipboard~ can each be set to a non-nil value to also use the clipboard and/or primary.\n\n~link-hint-copy-multiple-links~ and ~link-hint-copy-all-links~ also exist, but they may not be useful very often.\n\nThis package does not bind any commands by default.\n\n** At Point Fallback Commands\n:PROPERTIES:\n:CUSTOM_ID: at-point-fallback-commands\n:END:\n\nWhile the main purpose of link-hint is remote link selection with avy, it does provide commands to operate on a link at point (since it already has the necessary code to do so).  =link-hint-open-link-at-point=, for example, can be used as a sort of global \"act on the point\" command.  If there is not a link at the point, you can make it fall back to another command by setting =link-hint-action-fallback-commands=.  Some potentially useful fallback commands would be =embark-dwim= and =action-key= (hyperbole).\n\nTo still get the \"no links found\" error message when nothing happens, fallback command should return nil if it also fails to do anything.\n#+begin_src emacs-lisp\n(setq link-hint-action-fallback-commands\n      (list :open (lambda ()\n                    (condition-case _\n                        (progn\n                          (embark-dwim)\n                          t)\n                      (error\n                       nil)))))\n#+end_src\n\nHere is a more complex example that will try to jump to the definition in programming modes where possible before falling back to hyperbole.  If you want something like this, you will probably need to tweak this rather than use it as-is.\n#+begin_src emacs-lisp\n(defun noct-open ()\n  \"Open the thing at point.\nTry with lsp or smart jump (if in a prog-mode buffer) then with hyperbole.\"\n  (interactive)\n  (or (when (derived-mode-p 'prog-mode)\n        (cond ((bound-and-true-p lsp-mode)\n               (not (stringp (lsp-find-definition))))\n              ((fboundp 'smart-jump-go)\n               ;; return nil instead of prompting when there is no definition\n               ;; at point\n               (cl-letf (((symbol-function 'xref--prompt-p) #'ignore))\n                 (smart-jump-go)))))\n      (when (fboundp 'action-key)\n        (action-key))))\n\n(setq link-hint-action-fallback-commands (list :open #'noct-open))\n#+end_src\n\n** Overriding Avy Settings\n=link-hint.el= supports overriding avy's settings. For example, if you want to use a different avy style just for link hinting, you can set ~link-hint-avy-style~:\n\n#+begin_src emacs-lisp\n(setq link-hint-avy-style 'pre)\n#+end_src\n\nThis will cause the overlays to be displayed before the links (and not cover them). Note that using the =post= style will not put the overlay at the end of links. I don't think this style makes much sense for links, but feel free to open an issue if you would like this style to be supported.\n\nHere is the full list of settings:\n- =link-hint-avy-style=\n- =link-hint-avy-keys=\n- =link-hint-avy-all-windows=\n- =link-hint-avy-all-windows-alt=\n- =link-hint-avy-background=\n- =link-hint-avy-ignored-modes=\n\nBy default, these variables are not bound, and avy's corresponding settings are used. =avy-styles-alist= and =avy-keys-alist= are also supported for the provided commands (as well as ~avy-resume~).\n\n** Messaging\nBy default, link-hint will print a message in the echo area when an action is performed. =link-hint-message= can be set to =nil= to disable this behavior. It can also be set to a custom message function such as ~lv-message~.\n\n=link-hint-action-messages= is a plist that is used for the default description of each action keyword (e.g. =:open \"Opened\"=).\n\n** Point/Window Restoration\nLink hint will move the point (and sometimes the window; see =avy-all-windows=) when acting on a link. When =link-hint-restore= is a non-nil value, link-hint will automatically restore the point and window when the link action does not intentionally change the point/window. For example, if =link-hint-avy-all-windows= is a non-nil value, and the user copies a link in a different window, the point will stay the same in the buffer containing the link, and the selected window will stay the same. On the other hand, if the user opens a url in ~eww~ in a new window, the ~eww~ window will be selected, but the point in the link buffer will be restored. Similarly, if the user opens an org link to a local (same buffer) heading, the point and window will not be restored.\n\n** Defining New Link Types and Actions\n~link-hint-define-type~ is the helper function used to define new link types. ~link-hint-define-type~ is just simple helper to alter the symbol plist of =link-hint-<type>= (though it is recommended to use it directly in case the implementation changes). For example, here is how =shr-url= could be defined if it did not already exist:\n#+begin_src emacs-lisp\n(link-hint-define-type 'shr-url\n  :next #'link-hint--next-shr-url\n  :at-point-p #'link-hint--shr-url-at-point-p\n  :open #'browse-url\n  :copy #'kill-new)\n\n(push 'link-hint-shr-url link-hint-types)\n#+end_src\n\nAll link hint types are defined in this way, so see the source code for more examples.\n\n*** Mandatory Keywords\n=:next=\n- should be a function that returns the position of the next link /after/ the point (i.e. if there is a link at the point, it should not return the point)\n- should not move the point (wrap your code in ~save-excursion~ if you move the point)\n- arglist: =(bound)= - one argument for the end bound for searching\n\n=:at-point-p=\n- should be a function that returns a non-nil value if there is a link at the point\n- its return value can be used in the action functions\n- arglist: =()= - not passed any arguments\n\n*** Predicate Keywords\nThese keywords are used to determine when a type is active. If these keywords are specified, link-hint will only check for the link type if the buffer meets the requirements. These are not strictly necessary but can be used, for example, to help performance (this is usually not an issue except for \"overlay button\" links currently - woman buttons, dictionary mode buttons, etc.).\n\n=:predicates= should be a list of functions that should each return true if the link type passes/is valid in the current buffer.\n\n=:vars= should be a list of variables and/or major modes. If at least one of them is bound and true or the current major mode, the link type passes.\n\n=:not-vars= should be a list of variables and/or major modes. If any of them are bound and true or the current major mode, the link type does not pass.\n\nAll of these checks must pass for the link type to be considered active. It is also possible to create commands that only operate on specific link types by binding =link-hint-types= (e.g. ~(let ((link-hint-types ...)))~).\n\n*** Action Keywords\nThe main actions supported by default are =:open= and =:copy=. Custom action keywords can have any name not already used by link-hint, but you may want to give your keywords some unique prefix to ensure they do not clash in case link-hint adds new action types (e.g. =:my-<action>=).\n\n=:<action>= (e.g. =:open=)\n- should be function that will perform an action on a link (e.g. open it in the case of =:open=)\n- arglist: =(<at-point-p return list item 1> <at-point-p return list item 2> ...)= or =(<at-point-p return value as single argument>)= or =()=; the function is not required to take a specific number of arguments\n  - if you want to use information obtained in the =:at-point-p= call, you can give the action implementation function a non-empty arglist\n    - if the =:at-point-p= function returns a list, you can use multiple arguments (one for each item in the list)\n    - if your =:at-point-p= function returns a single value, you should use a single argument, e.g. the text-url link type's =:at-point-p= function returns the url to open as a string, so the =:open= function can just be ~browse-url~ (which takes a url as an argument)\n  - if you use an empty arglist, the function should operate at the link at point\n\nLink types are not required to support all action keywords. If a link type does not support a particular action keyword, it will just be ignored for that action.\n\n*** Action Modifier Keywords\n=:parse= should be a function that takes two arguments: the return value of the link type's =:at-point-p= function and the action keyword. It should return a valid input for the action function. This can be useful, for example, if the =at-point-p= function returns a plist, struct, etc. and each action function only needs part of it (see the definition of =package-link= for a concrete example).\n\n=:<action>-multiple= should be a boolean value corresponding to whether it makes sense to perform the action on multiple links in a row.\n\n=:<action>-message= should be a string that will be used instead of the normal message string. For example, =:open-message \"Installed\"= is specified for the =package-install-link= type.\n\n=:describe= should be a function that returns a string representation of the link to be used when messaging. If not set, the return value of the =:at-point-p= function is used directly.\n\n** Creating New Commands\nThe user can create new commands to do something other than copy or open a link using the ~link-hint--one~, ~link-hint--multiple~, and ~link-hint--all~ helper functions. Each takes a single action keyword as an argument.\n\nHere is an example of adding a command that downloads a url:\n#+begin_src emacs-lisp\n;; `link-hint-define-type' can be used to add new keywords\n(link-hint-define-type 'text-url\n  :download #'w3m-download)\n\n(link-hint-define-type 'w3m-link\n  :download #'w3m-download)\n\n...\n\n(defun link-hint-download-link ()\n  \"Use avy to select and download a text URL with download-region.el.\"\n  (interactive)\n  (avy-with link-hint-download-link\n    (link-hint--one :download)))\n#+end_src\n\n** Using for Links in Terminal with Tmux\nThis may seem like a strange use for this package, but I've been doing this due to lack of a better alternative. Unfortunately, most of the methods for generically opening urls in a terminal running tmux (e.g. urlscan, urlview, w3m, terminal keybindings, tmux-urlview, and tmux-open) aren't very quick or customizable. [[https://github.com/tmux/tmux][tmux-fingers]] looks more promising but currently only supports copying, doesn't allow for customizable hint keys, and is slow for me.\n\nI've started using this keybinding on the rare occasion that I need to open a url from somewhere other than emacs:\n#+begin_src shell\nbind-key f capture-pane \\; save-buffer /tmp/tmux-buffer \\; \\\n\tnew-window 'emacsclient -t -e \"(find-file \\\"/tmp/tmux-buffer\\\")\" -e \"(goto-address-mode)\" -e \"(link-hint-open-link)\" -e \"(kill-this-buffer)\" -e \"(delete-frame)\"'\n#+end_src\n\nI kill the buffer to ensure that emacs won't prompt to revert the file on later invocations in the case that auto-revert-mode is off.\n\nOne downside (shared by most other methods) is that it may be a bit disorienting to have the positions of links moved when opening a new tmux window. In this regard, having link-opening functionality directly in a terminal is nice.\n\n"
  },
  {
    "path": "link-hint.el",
    "content": ";;; link-hint.el --- Use avy to open, copy, etc. visible links -*- lexical-binding: t -*-\n\n;; Author: Fox Kiester <noct@posteo.net>\n;; URL: https://github.com/noctuid/link-hint.el\n;; Keywords: convenience url avy link links hyperlink\n;; Package-Requires: ((avy \"0.4.0\") (emacs \"24.4\"))\n;; Version: 0.1\n\n;; This file is not part of GNU Emacs.\n\n;; This program is free software: you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n;;; Commentary:\n;; This packages provides commands for operating on visible links with avy. It\n;; is inspired by link hinting from vim-like browsers and browser plugins such\n;; as pentadactyl. For example, `link-hint-open-link' will use avy to select and\n;; open a visible link. A link is not limited to a url but can also be a file\n;; link, button, org link, info link, help link, mu4e attachment, mailto\n;; address, etc. Commands are also provided for copying links to the kill ring\n;; (and optionally the clipboard and/or primary) and for opening multiple links\n;; at once like with pentadactyl's \"g;\" or qutebrowser's \"--rapid\" flag. It is\n;; possible for the user to add both new link types and new link actions.\n\n;; For more information, see the link-hint.el README/documentation.\n\n;;; Code:\n(require 'cl-lib)\n(require 'avy)\n(require 'thingatpt)\n(require 'browse-url)\n(require 'goto-addr)\n(require 'ffap)\n(require 'rx)\n\n;; * Options\n(defgroup link-hint nil\n  \"Provides commands for operating on visible links with avy.\"\n  :group 'convenience\n  :prefix \"link-hint-\")\n\n(defcustom link-hint-types\n  '(link-hint-shr-url\n    ;; mode specific\n    link-hint-org-link\n    link-hint-markdown-link\n    link-hint-mu4e-url\n    link-hint-mu4e-attachment\n    link-hint-gnus-w3m-url\n    link-hint-gnus-w3m-image-url\n    link-hint-deadgrep\n    link-hint-help-link\n    link-hint-info-link\n    link-hint-overlay-button\n    link-hint-package-link\n    link-hint-package-keyword-link\n    link-hint-package-install-link\n    link-hint-epkg-button\n    link-hint-compilation-link\n    link-hint-w3m-link\n    link-hint-w3m-message-link\n    link-hint-treemacs\n    link-hint-nov-link\n    link-hint-customize-widget\n    link-hint-notmuch-hello\n    link-hint-completion-list-candidate\n    link-hint-dired-filename\n    link-hint-org-agenda-item\n    link-hint-xref-item\n    link-hint-bug-reference\n    ;; generic\n    link-hint-button\n    link-hint-text-url\n    link-hint-file-link)\n  \"Link types to check for.\"\n  :type '(repeat :tag \"Types\"\n                 (choice\n                  (const :tag \"Button\" link-hint-button)\n                  (const :tag \"Completion List\" link-hint-completion-list-candidate)\n                  (const :tag \"Compilation Link\" link-hint-compilation-link)\n                  (const :tag \"Customize Widget\" link-hint-customize-widget)\n                  (const :tag \"Deadgrep\" link-hint-deadgrep)\n                  (const :tag \"Dired filename\" link-hint-dired-filename)\n                  (const :tag \"Epkg Button\" link-hint-epkg-button)\n                  (const :tag \"File Link\" link-hint-file-link)\n                  (const :tag \"Gnus W3m Image Url\" link-hint-gnus-w3m-image-url)\n                  (const :tag \"Gnus W3m Url\" link-hint-gnus-w3m-url)\n                  (const :tag \"Help Link\" link-hint-help-link)\n                  (const :tag \"Info Link\" link-hint-info-link)\n                  (const :tag \"Markdown Link\" link-hint-markdown-link)\n                  (const :tag \"Mu4e Attachment\" link-hint-mu4e-attachment)\n                  (const :tag \"Mu4e Url\" link-hint-mu4e-url)\n                  (const :tag \"Notmuch Hello\" link-hint-notmuch-hello)\n                  (const :tag \"Nov Link\" link-hint-nov-link)\n                  (const :tag \"Org Agenda\" link-hint-org-agenda-item)\n                  (const :tag \"Org Link\" link-hint-org-link)\n                  (const :tag \"Overlay Button\" link-hint-overlay-button)\n                  (const :tag \"Package Install Link\" link-hint-package-install-link)\n                  (const :tag \"Package Keyword Link\" link-hint-package-keyword-link)\n                  (const :tag \"Package Link\" link-hint-package-link)\n                  (const :tag \"Shr Url\" link-hint-shr-url)\n                  (const :tag \"Text Url\" link-hint-text-url)\n                  (const :tag \"Treemacs\" link-hint-treemacs)\n                  (const :tag \"W3m Link\" link-hint-w3m-link)\n                  (const :tag \"W3m Message Link\" link-hint-w3m-message-link)\n                  (const :tag \"Xref Item\" link-hint-xref-item)\n                  (const :tag \"Bug Reference\" link-hint-bug-reference)\n                  (symbol :tag \"Custom Type\"))))\n\n(defcustom link-hint-action-fallback-commands nil\n  \"Plist of action to fallback command pairs.\nIf no link is detected at point when running an at-point command like\n`link-hint-open-link-at-point', check this plist and run the fallback command\ninstead if any is matched.  For example, set this to (list :open #'<command>)\nwhere <command> is something like `embark-dwim', `action-key' (hyperbole), or\n`smart-jump-go' (e.g. conditionally in a `prog-mode' buffer).  See the\ndocumentation for a more complex example.  To still get a message that there is\nno supported link at point on failure, the fallback command should return nil if\nthey also don't find anything.\"\n  :type '(plist\n          :key-type (sexp :tag \"Action\")\n          :value-type (function :tag \"Fallback command\")))\n\n(defcustom link-hint-action-messages\n  (list :copy \"Copied\"\n        :open \"Opened\"\n        :browse-url \"Browsed\")\n  \"Plist of action to description message pairs.\"\n  :type '(plist :options ((:copy (string :tag \"Copy\" :value \"Copied\"))\n                          (:open (string :tag \"Open\" :value \"Opened\"))\n                          (:browse-url (string :tag \"Browse Url\" :value \"Browsed\")))\n                :key-type (sexp :tag \"Action\")\n                :value-type (string :tag \"Description\")))\n\n(defcustom link-hint-message #'message\n  \"The function to use to message information or nil.\"\n  :type '(choice\n          (const :tag \"Don't message\" nil)\n          (function-item :tag \"Message\" message)\n          (function :tag \"Custom function\")))\n\n(defcustom link-hint-url-regexp\n  goto-address-url-regexp\n  \"Regexp used to determine what constitutes a text url.\nDefaults to `goto-address-url-regxp'.\n\nThis is used for searching for urls and checking if there is a match at point,\nbut the regexp only needs to match the beginning of the url. `thingatpt' is used\nto obtain the full url.\n\nNote that this is used for text urls only in modes that don't have some\nmechanism for supporting urls. This won't affect link-hint's behavior in\n`org-mode' or modes that use shr.el for urls, for example.\"\n  :type 'regexp)\n\n(defcustom link-hint-maybe-file-regexp\n  (rx (or bol blank) (zero-or-one (or \"~\" (seq (char alpha) \":\"))) \"/\" (1+ not-newline))\n  \"Regexp used to determine what constitutes a potential file link.\"\n  :type 'regexp)\n\n(defcustom link-hint-delete-trailing-paren t\n  \"Whether to delete a ) at the end of a url.\nThis is a workaround for Emacs libraries including unwanted parens in urls.\nSee issue #15 for more information.\"\n  :type 'boolean)\n\n(defcustom link-hint-restore t\n  \"Whether to restore the point and window after opening a link.\nNote that the point will never be restored if the action intentionally moves the\npoint within the link buffer (e.g. opening a local org heading link). Similarly,\nthe window will never be restored if the action intentionally opens/selects a\nnew window (e.g. opening a url in `eww').\"\n  :type 'boolean)\n\n;; ** Avy Settings\n;;  these only have an effect if bound by the user\n(defvar link-hint-avy-style)\n\n(defvar link-hint-avy-keys)\n\n(defvar link-hint-avy-all-windows)\n\n(defvar link-hint-avy-all-windows-alt)\n\n(defvar link-hint-avy-background)\n\n(defvar link-hint-avy-ignored-modes)\n\n;; * Link Finding Helper Functions\n(defun link-hint--find-regexp (search-regexp start-bound end-bound)\n  \"Find the first occurrence of SEARCH-REGEXP.\nOnly search the range between just after START-BOUND and END-BOUND.\"\n  (save-excursion\n    (let (case-fold-search)\n      (goto-char start-bound)\n      (ignore-errors (forward-char))\n      (when (re-search-forward search-regexp end-bound t)\n        (match-beginning 0)))))\n\n(defun link-hint--next-regexp (search-regexp bound)\n  \"Find the next occurrence of SEARCH-REGEXP.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--find-regexp search-regexp (point) bound))\n\n(declare-function widget-forward \"ext:wid-edit\")\n(defun link-hint--next-widget (bound)\n  \"Find the next widget location. Currently only used for custom mode.\nOnly search the range between just after the point and BOUND.\"\n  (save-excursion\n    (save-restriction\n      (narrow-to-region (point) bound)\n      ;; Emacs <30 will raise an error when there is no widget forward\n      ;; of point.  Emacs 30 introduced code that no longer raises an\n      ;; error in this case, and it doesn't move point either.\n      ;; Therefore we return nil if an error is raised (Emacs <30),\n      ;; but we also return nil if `widget-forward' doesn't move point\n      ;; (Emacs 30).\n      (ignore-errors\n        (let ((start (point))\n              (new-pos (progn\n                         (widget-forward 1)\n                         (point))))\n          (when (> new-pos start)\n            new-pos))))))\n\n(defun link-hint--find-property-with-value\n    (property value start-bound end-bound)\n  \"Find the first location where PROPERTY has VALUE.\nIf VALUE is nil, find the first location where PROPERTY exists. Only search the\nrange from between just after the START-BOUND and END-BOUND.\"\n  (let (first-non-match-pos)\n    (setq first-non-match-pos\n          (funcall (if value\n                       #'text-property-not-all\n                     #'text-property-any)\n                   start-bound end-bound property value))\n    (when first-non-match-pos\n      (funcall (if value\n                   #'text-property-any\n                 #'text-property-not-all)\n               first-non-match-pos end-bound property value))))\n\n(defun link-hint--property-text\n    (property &optional before-bound after-bound)\n  \"Return all text around the point for which PROPERTY stays the same.\nSearch only before the point to BEFORE-BOUND and after the point to AFTER-BOUND.\nIf the property does not change in this range, return the text between\nBEFORE-BOUND and AFTER-BOUND.\"\n  ;; TODO are these default bounds reasonable?\n  ;; links can be split with a newline (e.g. Info-mode)\n  (let ((before-bound (or before-bound\n                          (save-excursion\n                            (goto-char (window-start))\n                            (forward-line -5)\n                            (point))))\n        (after-bound (or after-bound\n                         (save-excursion\n                           (goto-char (window-end nil t))\n                           (forward-line 5)\n                           (point)))))\n    (buffer-substring-no-properties\n     (previous-single-property-change (1+ (point)) property nil before-bound)\n     (next-single-property-change (point) property nil after-bound))))\n\n(defun link-hint--next-property-with-value (property value end-bound)\n  \"Find the next location where PROPERTY has VALUE.\nOnly search the range from between just after the point and END-BOUND.\"\n  (link-hint--find-property-with-value property value (point) end-bound))\n\n(defun link-hint--find-property (property start-bound end-bound)\n  \"Find the first location where PROPERTY exists.\nOnly search the range from between just after the START-BOUND and the\nEND-BOUND.\"\n  (link-hint--find-property-with-value property nil start-bound end-bound))\n\n(defun link-hint--next-property (property bound)\n  \"Find the next location where PROPERTY exists.\nOnly search the range from between just after the point and BOUND.\"\n  (link-hint--find-property property (point) bound))\n\n;; * Link Type Definition\n(defun link-hint- (symbol)\n  \"Preface SYMBOL with \\\"link-hint-\\\".\"\n  (intern (format \"link-hint-%S\" symbol)))\n\n;;;###autoload\n(defun link-hint-define-type (name &rest properties)\n  \"Add a new type of link called NAME to link-hint.el.\nPROPERTIES should be property value pairs to add to the symbol plist of\nlink-hint-NAME.\"\n  (declare (indent defun))\n  (let ((type (link-hint- name)))\n    (cl-loop for (prop value)\n             on properties by 'cddr\n             do (put type prop value))))\n\n;; ** Helpers\n(defun link-hint--min (&rest numbers)\n  \"Find the minimum from the list NUMBERS, ignoring nil values.\"\n  (setq numbers (remq nil numbers))\n  (when numbers\n    (apply #'min numbers)))\n\n(defun link-hint--var-valid-p (var)\n  \"Return t if VAR is bound and true or is the current major mode.\"\n  (or (eq var major-mode)\n      (and (boundp var)\n           (symbol-value var))))\n\n(defun link-hint--type-valid-p (type)\n  \"Return whether TYPE is a valid type for the current buffer.\nThis is done by checking that all its predicates hold, that at least one of its\nvariables is bound and true or the current `major-mode', and that none of its\n\\\"not\\\" variables are true (if bound) or the current `major-mode'.\"\n  (let ((predicates (get type :predicates))\n        (vars (get type :vars))\n        (not-vars (get type :not-vars)))\n    ;; note: cl-every will always return t for a null seq but cl-some will not\n    ;; however, this behavior is not documented (hence or)\n    (and (or (null predicates)\n             (cl-every (lambda (pred)\n                         (funcall pred))\n                       predicates))\n         (or (null vars)\n             (cl-some #'link-hint--var-valid-p vars))\n         (or (null not-vars)\n             (not (cl-some #'link-hint--var-valid-p not-vars))))))\n\n;; ** Text Url\n(defun link-hint--next-text-url (bound)\n  \"Find the next text url.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-regexp link-hint-url-regexp bound))\n\n(defun link-hint--text-url-at-point-p ()\n  \"Return the text url at the point or nil.\"\n  (let ((url (thing-at-point-url-at-point t)))\n    (and url\n         ;; this should filter out any lax matches that aren't actually urls;\n         ;; note that thingatpt will add missing schemes (www -> http://www)\n         (string-match-p link-hint-url-regexp url)\n         url)))\n\n(defun link-hint--process-url (url _action)\n  \"Return URL without any trailing parentheses.\"\n  (if link-hint-delete-trailing-paren\n      (replace-regexp-in-string \")*$\" \"\" url)\n    url))\n\n(link-hint-define-type 'text-url\n  :next #'link-hint--next-text-url\n  :at-point-p #'link-hint--text-url-at-point-p\n  :not-vars '(org-mode\n              ;; modes that use shr.el\n              mu4e-view-mode\n              elfeed-show-mode\n              eww-mode)\n  :parse #'link-hint--process-url\n  :open #'browse-url\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** File Link\n(defun link-hint--find-file-link (start-bound end-bound)\n  \"Find the first file link.\nOnly search the range between just after START-BOUND and END-BOUND.\"\n  (save-excursion\n    (let (file-link-pos)\n      (goto-char start-bound)\n      (while (and\n              (setq file-link-pos\n                    (link-hint--find-regexp link-hint-maybe-file-regexp\n                                            (point) end-bound))\n              (progn\n                (goto-char file-link-pos)\n                (when (looking-at (rx blank))\n                  (forward-char)\n                  (setq file-link-pos (point)))\n                t)\n              (not (ffap-file-at-point))))\n      (when (and file-link-pos\n                 (ffap-file-at-point))\n        file-link-pos))))\n\n(defun link-hint--next-file-link (bound)\n  \"Find the next file link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--find-file-link (point) bound))\n\n(link-hint-define-type 'file-link\n  :next #'link-hint--next-file-link\n  :at-point-p #'ffap-file-at-point\n  ;; TODO consider making file links opt-in (use :vars)\n  :not-vars '(org-mode Info-mode)\n  :open #'find-file-at-point\n  :copy #'kill-new)\n\n;; ** Generic Button\n(defun link-hint--next-button (bound)\n  \"Find the next button.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'button bound))\n\n(defun link-hint--button-at-point-p ()\n  \"Return the button at the point or nil.\"\n  (let ((button (button-at (point))))\n    (when button\n      (button-label button))))\n\n(link-hint-define-type 'button\n  :next #'link-hint--next-button\n  :at-point-p #'link-hint--button-at-point-p\n  ;; TODO add more\n  :not-vars '(woman-mode treemacs-mode Man-mode dictionary-mode fanyi-mode)\n  :open #'push-button\n  :copy #'kill-new)\n\n;; ** Shr Url\n(defun link-hint--next-shr-url (bound)\n  \"Find the next shr url.\nOnly search the range between just after the point and BOUND.\"\n  ;; `shr-next-link' just uses text properties as well\n  (link-hint--next-property 'shr-url bound))\n\n(defun link-hint--shr-url-at-point-p ()\n  \"Return the shr url at the point or nil.\"\n  (get-text-property (point) 'shr-url))\n\n(link-hint-define-type 'shr-url\n  :next #'link-hint--next-shr-url\n  :at-point-p #'link-hint--shr-url-at-point-p\n  ;; would need a comprehensive list of all modes that use shr.el\n  ;; :vars\n  :not-vars '(mastodon-mode nov-mode)\n  :open #'browse-url\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Org Link\n(defun link-hint--next-org-link (bound)\n  \"Find the next org link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'htmlize-link bound))\n\n(defun link-hint--org-link-at-point-p ()\n  \"Return the org link at the point or nil.\"\n  ;; note: org uses :uri even for elisp forms, shell commands, etc.\n  ;; note: org doesn't provide a property for the text in [[url][text]]\n  (plist-get (get-text-property (point) 'htmlize-link) :uri))\n\n(declare-function org-open-at-point \"org\")\n(declare-function org-open-link-from-string \"org\")\n(defun link-hint--open-org-link (uri)\n  \"Open the org link URI.\"\n  ;; org-open-at-point won't work e.g. for =http://address.com= even\n  ;; though `org-next-link' will jump to it\n  (condition-case nil\n      (org-open-at-point-global)\n    (error (if (fboundp 'org-link-open-from-string)\n               (org-link-open-from-string uri)\n             (org-open-link-from-string uri)))))\n\n(link-hint-define-type 'org-link\n  :next #'link-hint--next-org-link\n  :at-point-p #'link-hint--org-link-at-point-p\n  :vars '(org-mode org-journal-mode org-agenda-mode org-link-minor-mode orglink-mode org-roam-mode)\n  :open #'link-hint--open-org-link\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Treemacs Link\n(declare-function treemacs-visit-node-in-most-recently-used-window \"ext:treemacs\")\n(declare-function treemacs-visit-node-default \"ext:treemacs\")\n(declare-function treemacs-button-get \"ext:treemacs\")\n(declare-function treemacs-node-at-point \"ext:treemacs\")\n(defun link-hint--open-treemacs-button ()\n  \"Open an entry in a treemacs buffer.\"\n  (if (string-prefix-p \" *Treemacs-\" (buffer-name))\n      (treemacs-visit-node-in-most-recently-used-window)\n    (treemacs-visit-node-default)))\n\n(defun link-hint--copy-treemacs ()\n  \"Copy an entry in a treemacs buffer.\"\n  (kill-new (format \"%s\"\n                    (treemacs-button-get\n                     (treemacs-node-at-point) :key))))\n\n(defun link-hint--treemacs-at-point-p ()\n  \"`:at-point-p' for treemacs buffers.\"\n  (let ((node (treemacs-node-at-point)))\n    (when node\n      (format \"%s\" (treemacs-button-get node :key)))))\n\n(link-hint-define-type 'treemacs\n  :next #'link-hint--next-button\n  :at-point-p #'link-hint--treemacs-at-point-p\n  :vars '(treemacs-mode)\n  :open #'link-hint--open-treemacs-button\n  :open-multiple t\n  :copy #'link-hint--copy-treemacs)\n\n;; ** Markdown Link\n(declare-function markdown-next-link \"ext:markdown-mode\")\n(defun link-hint--next-markdown-link (bound)\n  \"Find the next markdown link.\nOnly search the range between just after the point and BOUND.\"\n  ;; `markdown-next-link' does not use text properties\n  (let ((start (point)))\n    (save-excursion\n      (let ((match-pos (markdown-next-link)))\n        (when (and match-pos\n                   (< start match-pos bound))\n          match-pos)))))\n\n(declare-function markdown-link-at-pos \"ext:markdown-mode\")\n(declare-function markdown-wiki-link-p \"ext:markdown-mode\")\n(declare-function markdown-wiki-link-link \"ext:markdown-mode\")\n(defun link-hint--markdown-link-at-point-p ()\n  \"Return the markdown link at the point or nil.\"\n  (if (markdown-wiki-link-p)\n      (markdown-wiki-link-link)\n    (let ((link (markdown-link-at-pos (point))))\n      (unless (cl-every #'null link)\n        link))))\n\n(defun link-hint--parse-markdown-link (link action)\n  \"Alter LINK so that it can be passed to the ACTION function.\"\n  (cl-case action\n    ((:describe :copy) (if (listp link)\n                           (nth 3 link)\n                         link))\n    (t link)))\n\n(declare-function markdown-follow-link-at-point \"ext:markdown-mode\")\n(declare-function markdown-follow-wiki-link \"ext:markdown-mode\")\n(defun link-hint--open-markdown-link (link)\n  \"Open the markdown link at the point or LINK.\"\n  (if (listp link)\n      (markdown-follow-link-at-point)\n    (markdown-follow-wiki-link link)))\n\n(link-hint-define-type 'markdown-link\n  :next #'link-hint--next-markdown-link\n  :at-point-p #'link-hint--markdown-link-at-point-p\n  :vars '(markdown-mode gfm-mode markdown-view-mode)\n  :parse #'link-hint--parse-markdown-link\n  :open #'link-hint--open-markdown-link\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Mu4e Url\n(defun link-hint--next-mu4e-url (bound)\n  \"Find the next mu4e url.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'mu4e-url bound))\n\n(defun link-hint--mu4e-url-at-point-p ()\n  \"Return the mu4e url at the point or nil.\"\n  (get-text-property (point) 'mu4e-url))\n\n(declare-function mu4e~view-browse-url-from-binding \"ext:mu4e-view\")\n(declare-function mu4e--view-browse-url-from-binding \"ext:mu4e-view\")\n(defun link-hint--open-mu4e-url (url)\n  \"Open the mu4e URL.\"\n  ;; note: browse-url also supports mailto\n  (if (fboundp 'mu4e--view-browse-url-from-binding)\n      (mu4e--view-browse-url-from-binding url)\n    (mu4e~view-browse-url-from-binding url)))\n\n(link-hint-define-type 'mu4e-url\n  :next #'link-hint--next-mu4e-url\n  :at-point-p #'link-hint--mu4e-url-at-point-p\n  :vars '(mu4e-view-mode)\n  :open #'link-hint--open-mu4e-url\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Mu4e Attachment\n(defun link-hint--next-mu4e-attachment (bound)\n  \"Find the next mu4e attachment.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'mu4e-attnum bound))\n\n(defun link-hint--mu4e-attachment-at-point-p ()\n  \"Return the mu4e attachment number at the point or nil.\"\n  (get-text-property (point) 'mu4e-attnum))\n\n(declare-function mu4e-view-open-attachment \"ext:mu4e-view\")\n(defun link-hint--open-mu4e-attachment (attnum)\n  \"Open the mu4e attachment having number ATTNUM.\"\n  (mu4e-view-open-attachment nil attnum))\n\n(declare-function mu4e-view-save-attachment-single \"ext:mu4e-view\")\n(defun link-hint--copy-mu4e-attachment (attnum)\n  \"Save the mu4e attachment having number ATTNUM.\"\n  (mu4e-view-save-attachment-single nil attnum))\n\n(link-hint-define-type 'mu4e-attachment\n  :next #'link-hint--next-mu4e-attachment\n  :at-point-p #'link-hint--mu4e-attachment-at-point-p\n  :vars '(mu4e-view-mode)\n  :open #'link-hint--open-mu4e-attachment\n  :copy #'link-hint--copy-mu4e-attachment)\n\n;; ** Gnus w3m Url\n;; only applicable when `mm-text-html-renderer' is gnus-w3m; shr is the default\n(defun link-hint--next-gnus-w3m-url (bound)\n  \"Find the next gnus-w3m url.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'gnus-string bound))\n\n(defun link-hint--gnus-w3m-url-at-point-p ()\n  \"Return the gnus-w3m url at the point or nil.\"\n  (get-text-property (point) 'gnus-string))\n\n(link-hint-define-type 'gnus-w3m-url\n  :next #'link-hint--next-gnus-w3m-url\n  :at-point-p #'link-hint--gnus-w3m-url-at-point-p\n  :vars '(gnus-article-mode)\n  :open #'browse-url\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Gnus w3m Image Url\n;; only applicable when `mm-text-html-renderer' is gnus-w3m; shr is the default\n(defun link-hint--next-gnus-w3m-image-url (bound)\n  \"Find the next gnus-w3m image url.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'image-url bound))\n\n(defun link-hint--gnus-w3m-image-url-at-point-p ()\n  \"Return the gnus-w3m image url at the point or nil.\"\n  (get-text-property (point) 'image-url))\n\n(link-hint-define-type 'gnus-w3m-image-url\n  :next #'link-hint--next-gnus-w3m-image-url\n  :at-point-p #'link-hint--gnus-w3m-image-url-at-point-p\n  :vars '(gnus-article-mode)\n  :open #'browse-url\n  :open-multiple t\n  :copy #'kill-new)\n\n;; ** Help Link\n(defun link-hint--next-help-link (bound)\n  \"Find the next help link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'help-args bound))\n\n(defun link-hint--help-link-at-point-p ()\n  \"Return the name of the help link at the point or nil.\"\n  (let ((help-link (get-text-property (point) 'help-args)))\n    (when help-link\n      (format \"%s\" help-link))))\n\n(link-hint-define-type 'help-link\n  :next #'link-hint--next-help-link\n  :at-point-p #'link-hint--help-link-at-point-p\n  :vars '(help-mode)\n  :open #'push-button\n  :copy #'kill-new)\n\n;; ** Info Link\n(declare-function Info-follow-nearest-node \"info\")\n(defun link-hint--next-info-link (bound)\n  \"Find the next info link.\nOnly search the range between just after the point and BOUND.\"\n  ;; Info-next-reference doesn't work for all links and uses\n  ;; `next-single-char-property-change'\n  (link-hint--min (link-hint--next-property-with-value\n                   'font-lock-face 'info-xref bound)\n                  ;; visited links have a different face\n                  (link-hint--next-property-with-value\n                   'font-lock-face 'info-xref-visited bound)))\n\n(defun link-hint--info-link-at-point-p ()\n  \"Return the name of the info link at the point or nil.\"\n  ;; (Info-extract-pointer \"next\")\n  (when (or (eq (get-text-property (point) 'font-lock-face)\n                'info-xref)\n            (eq (get-text-property (point) 'font-lock-face)\n                'info-xref-visited))\n    ;; note: Info-mode doesn't use buttons\n    (link-hint--property-text 'font-lock-face)))\n\n(defun link-hint--open-info-link (_)\n  \"Open the info link at the point.\"\n  (Info-follow-nearest-node))\n\n(link-hint-define-type 'info-link\n  :next #'link-hint--next-info-link\n  :at-point-p #'link-hint--info-link-at-point-p\n  :vars '(Info-mode)\n  :open #'link-hint--open-info-link\n  :copy #'kill-new)\n\n;; ** Package Link\n(defun link-hint--next-package-link (bound)\n  \"Find the next package link.\nOnly search the range between just after the point and BOUND.\"\n  ;; (link-hint--next-property-with-value\n  ;;  'action 'package-menu-describe-package bound)\n  (link-hint--next-property 'package-desc bound))\n\n(defun link-hint--package-link-at-point-p ()\n  \"Return the name of the package at the point or nil.\"\n  (get-text-property (point) 'package-desc))\n\n(declare-function package-desc-name \"ext:package\")\n(declare-function package-desc-extras \"ext:package\")\n(defun link-hint--parse-package-link (package-desc action)\n  \"Alter PACKAGE-DESC so that it can be passed to the ACTION function.\"\n  (cl-case action\n    (:browse-url (cdr (assq :url (package-desc-extras package-desc))))\n    ((:describe :copy) (symbol-name (package-desc-name package-desc)))\n    (t package-desc)))\n\n(link-hint-define-type 'package-link\n  :next #'link-hint--next-package-link\n  :at-point-p #'link-hint--package-link-at-point-p\n  :vars '(package-menu-mode paradox-menu-mode)\n  :parse #'link-hint--parse-package-link\n  :open #'describe-package\n  :browse-url #'browse-url\n  :browse-multiple t\n  :copy #'kill-new)\n\n;; ** Package Home Page Link (paradox only)\n;; TODO\n\n;; ** Package Keyword Link\n(defun link-hint--next-package-keyword-link (bound)\n  \"Find the next package keyword link.\nOnly search the range between just after the point and BOUND.\"\n  ;; (link-hint--next-property-with-value\n  ;;  'action 'package-keyword-button-action bound)\n  (link-hint--next-property 'package-keyword bound))\n\n(defun link-hint--package-keyword-link-at-point-p ()\n  \"Return the name of the package keywords at the point or nil.\"\n  (get-text-property (point) 'package-keyword))\n\n(link-hint-define-type 'package-keyword-link\n  :next #'link-hint--next-package-keyword-link\n  :at-point-p #'link-hint--package-keyword-link-at-point-p\n  :vars '(help-mode)\n  :open #'push-button\n  :copy #'kill-new)\n\n;; ** Package Install Link\n(defun link-hint--next-package-install-link (bound)\n  \"Find the next package installation link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property-with-value\n   'action 'package-install-button-action bound))\n\n(defun link-hint--package-install-link-at-point-p ()\n  \"If there is a package link at the point, return its name.\"\n  (when (eq (get-text-property (point) 'action)\n            'package-install-button-action)\n    (package-desc-name (get-text-property (point) 'package-desc))))\n\n(link-hint-define-type 'package-install-link\n  :next #'link-hint--next-package-install-link\n  :at-point-p #'link-hint--package-install-link-at-point-p\n  :vars '(help-mode)\n  :open #'push-button\n  :open-message \"Installed\")\n\n;; ** epkg Button\n(declare-function epkg-list-keyworded-packages \"ext:epkg\")\n(declare-function epkg-list-packages-by-author \"ext:epkg\")\n(declare-function epkg-describe-package \"ext:epkg\")\n(defun link-hint--overlay-epkg-category (overlay)\n  \"If OVERLAY contains a category of epkg, return it.\"\n  (let ((category (overlay-get overlay 'category)))\n    (when (and category (require 'epkg nil t))\n      (catch 'category\n        (dolist (type '(epkg-package\n                        epkg-author\n                        epkg-keyword\n                        epkg-library))\n          (when (eq category (button-category-symbol type))\n            (throw 'category type)))))))\n\n(defun link-hint--next-epkg-button (bound)\n  \"Find the next epkg button.\nOnly search the range between just after the point and BOUND.\"\n  (catch 'found\n    (save-restriction\n      (let (pos)\n        (narrow-to-region (point) (or bound (point-max)))\n        (save-excursion\n          (while (and (setq pos (next-overlay-change (point)))\n                      (< pos (point-max)))\n            (dolist (ol (overlays-at pos))\n              (let ((category (link-hint--overlay-epkg-category ol)))\n                (when category\n                  (throw 'found pos))))\n            (goto-char pos))\n          nil)))))\n\n(defun link-hint--at-epkg-button-p ()\n  \"If the point is at an epkg button, return its label.\"\n  (catch 'text\n    (dolist (ol (overlays-at (point)))\n      (when (link-hint--overlay-epkg-category ol)\n        (throw 'text (buffer-substring-no-properties\n                      (overlay-start ol) (overlay-end ol)))))))\n\n(defun link-hint--open-epkg-button ()\n  \"Open an epkg button at point.\"\n  (let ((label (link-hint--at-epkg-button-p)))\n    (cl-case (link-hint--overlay-epkg-category (car (overlays-at (point))))\n      (epkg-package\n       (epkg-describe-package label))\n      (epkg-author\n       (epkg-list-packages-by-author label))\n      (epkg-keyword\n       (epkg-list-keyworded-packages (intern label)))\n      (epkg-library\n       (find-library label)))))\n\n(link-hint-define-type 'epkg-button\n  :next #'link-hint--next-epkg-button\n  :at-point-p #'link-hint--at-epkg-button-p\n  :vars '(help-mode)\n  :open #'link-hint--open-epkg-button\n  :open-message \"Following\"\n  :copy #'kill-new)\n\n;; ** Compilation Link\n(declare-function compile-goto-error \"compile\")\n(defun link-hint--next-compilation-link (bound)\n  \"Find the next compilation link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'compilation-message bound))\n\n(defun link-hint--compilation-link-at-point-p ()\n  \"Return the compilation link message at the point or nil.\"\n  (get-text-property (point) 'compilation-message))\n\n(link-hint-define-type 'compilation-link\n  :next #'link-hint--next-compilation-link\n  :at-point-p #'link-hint--compilation-link-at-point-p\n  :vars '(compilation-mode compilation-minor-mode compilation-shell-minor-mode)\n  ;; no simple way to get message for copying\n  :open #'compile-goto-error)\n\n;; ** w3m Link\n(defun link-hint--next-w3m-link (bound)\n  \"Find the next w3m link.\nOnly search the range between just after the point and BOUND.\"\n  ;; `w3m-goto-next-link' also uses text properties\n  (link-hint--next-property 'w3m-href-anchor bound))\n\n(defun link-hint--w3m-link-at-point-p ()\n  \"Return the w3m link at the point or nil.\"\n  (get-text-property (point) 'w3m-href-anchor))\n\n(declare-function w3m-view-this-url \"ext:w3m\")\n(link-hint-define-type 'w3m-link\n  :next #'link-hint--next-w3m-link\n  :at-point-p #'link-hint--w3m-link-at-point-p\n  :vars '(w3m-mode)\n  :open #'w3m-view-this-url\n  :copy #'kill-new)\n\n;; ** w3m Message Link\n;; w3m can be used for rendering email (e.g. `mm-text-html-renderer' is w3m)\n;; same as w3m link but with different open action\n(link-hint-define-type 'w3m-message-link\n  :next #'link-hint--next-w3m-link\n  :at-point-p #'link-hint--w3m-link-at-point-p\n  :vars '(gnus-article-mode notmuch-show-mode)\n  :open #'browse-url\n  :copy #'kill-new)\n\n;; ** Overlay Button\n;; Although potentially it might work in more modes, because this function\n;; uses `next-single-char-property-change', which is slow, it’s only used for\n;; woman, man, and dictionary modes.\n(defun link-hint--find-overlay-button (start-bound end-bound)\n  \"Find the first button location returned from `next-button’.\nOnly search the range between just after START-BOUND and END-BOUND.\"\n  (let (button)\n    (save-restriction\n      (narrow-to-region start-bound end-bound)\n      (setq button (next-button (point)))\n      (when button\n        (button-start button)))))\n\n(defun link-hint--next-overlay-button (bound)\n  \"Find the next overlay button location.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--find-overlay-button (point) bound))\n\n(link-hint-define-type 'overlay-button\n  :next #'link-hint--next-overlay-button\n  :at-point-p #'link-hint--button-at-point-p\n  :vars '(dictionary-mode\n          epa-key-list-mode\n          fanyi-mode\n          Man-mode\n          notmuch-show-mode\n          woman-mode)\n  :open #'push-button\n  :copy #'kill-new)\n\n;; ** Nov.el Link\n(declare-function nov-browse-url \"ext:nov\")\n(defun link-hint--nov-browse ()\n  \"Call `nov-browse-url' with no args.\"\n  (nov-browse-url))\n\n(link-hint-define-type 'nov-link\n  :next #'link-hint--next-shr-url\n  :at-point-p #'link-hint--shr-url-at-point-p\n  :vars '(nov-mode)\n  :open #'link-hint--nov-browse\n  :copy #'kill-new)\n\n;; ** Deadgrep matches\n(declare-function deadgrep-visit-result \"ext:deadgrep\")\n(defun link-hint--next-deadgrep-link (bound)\n  \"Find the next deadgrep link.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property-with-value 'face 'deadgrep-meta-face bound))\n\n(defun link-hint--deadgrep-link-at-point-p ()\n  \"Return the source location at the point.\"\n  (let ((filename (get-text-property (point) 'deadgrep-filename))\n        (line-number (get-text-property (point) 'deadgrep-line-number)))\n    (when (and filename line-number)\n      (format \"%s:%s\" filename line-number))))\n\n(link-hint-define-type 'deadgrep\n  :next #'link-hint--next-deadgrep-link\n  :at-point-p #'link-hint--deadgrep-link-at-point-p\n  :vars '(deadgrep-mode)\n  :open #'deadgrep-visit-result)\n\n;; ** Customize Widget\n;; (customize-link (and (eq major-mode 'Custom-mode)\n;;                      (button-at (point))))\n;; (customize-field (and (eq major-mode 'Custom-mode)\n;;                       (eq (car (widget-tabable-at))\n;;                           'editable-field)))\n\n(declare-function Custom-newline \"cus-edit\")\n(defun link-hint--open-customize-widget ()\n  \"Open the customize widget at the point.\"\n  (Custom-newline (point)))\n\n(defun link-hint--customize-widget-at-point-p ()\n  \"Return button text of the customize widget at the point or nil.\"\n  (let ((button (get-char-property (point) 'button)))\n    (when button\n      (plist-get (cdr button) :tag))))\n\n(link-hint-define-type 'customize-widget\n  :next #'link-hint--next-widget\n  :at-point-p #'link-hint--customize-widget-at-point-p\n  :vars '(Custom-mode)\n  :open #'link-hint--open-customize-widget\n  :copy #'kill-new)\n\n;; ** notmuch-hello widgets\n(defun link-hint--widget-button-at-point-p ()\n  \"Return point of the customize widget at the point or nil.\"\n  (when (get-char-property (point) 'button) (point)))\n\n(defun link-hint--next-widget-button (bound)\n  \"Return pos of the next widget up to BOUND.\"\n  (let ((start (point)))\n    (save-excursion\n      (widget-forward 1)\n      (while (not (link-hint--widget-button-at-point-p))\n        (widget-forward 1))\n      (when (and (link-hint--widget-button-at-point-p)\n                 (> (point) start)\n                 (< (point) bound))\n        (point)))))\n\n(defun link-hint--copy-widget (pos)\n  \"Copy the text of the button at POS.\"\n  (kill-new (widget-get (widget-at pos) :value)))\n\n(link-hint-define-type 'notmuch-hello\n  :next #'link-hint--next-widget-button\n  :at-point-p #'link-hint--widget-button-at-point-p\n  :vars '(notmuch-hello-mode)\n  :open #'widget-button-press\n  :copy #'link-hint--copy-widget)\n\n;; ** Completion List candidate\n(defun link-hint--next-completion-list-candidate (bound)\n  \"Find the next completion list candidate location.\nOnly search the range between just after the point and BOUND.\"\n  (save-excursion\n    (let ((start (point)))\n      (next-completion 1)\n      (let ((pos (point)))\n        (when (or (< start pos bound)\n                  ;; edge case where `next-completion' will not move the point\n                  ;; the first time it's called\n                  (and (boundp 'completions-header-format)\n                       (null completions-header-format)\n\t\t       (null completion-show-help)\n                       (= start (point-min))))\n          pos)))))\n\n(defun link-hint--open-completion-list-candidate (&rest _ignore)\n  \"Select completion list candidate at point.\"\n  (choose-completion))\n\n(defun link-hint--completion-list-candidate-at-point-p ()\n  \"Return the completion list candidate at the point or nil.\"\n  (get-text-property (point) 'completion--string))\n\n(link-hint-define-type 'completion-list-candidate\n  :next #'link-hint--next-completion-list-candidate\n  :vars '(completion-list-mode)\n  :open #'link-hint--open-completion-list-candidate\n  :at-point-p #'link-hint--completion-list-candidate-at-point-p\n  :copy #'kill-new)\n\n;; ** Dired filename\n(defun link-hint--next-dired-filename (bound)\n  \"Find the next dired filename location.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'dired-filename bound))\n\n(defun link-hint--dired-filename-at-point-p ()\n  \"Return the dired filename at the point or nil.\"\n  (when (get-text-property (point) 'dired-filename)\n    (link-hint--property-text 'dired-filename)))\n\n(declare-function dired-find-file \"dired\")\n\n(link-hint-define-type 'dired-filename\n  :next #'link-hint--next-dired-filename\n  :at-point-p #'link-hint--dired-filename-at-point-p\n  :vars '(dired-mode)\n  :open #'dired-find-file\n  :copy #'kill-new)\n\n;; ** Org Agenda item\n(defun link-hint--next-org-agenda-item (bound)\n  \"Find the next org agenda item.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'org-marker bound))\n\n(declare-function org-agenda-switch-to \"org-agenda\")\n\n(defun link-hint--open-org-agenda-item (&rest _ignore)\n  \"Open org agenda item at point.\"\n  (org-agenda-switch-to))\n\n(defun link-hint--org-agenda-item-at-point-p ()\n  \"Return the org agenda at the point or nil.\"\n  (get-text-property (point) 'txt))\n\n(link-hint-define-type 'org-agenda-item\n  :next #'link-hint--next-org-agenda-item\n  :vars '(org-agenda-mode)\n  :open #'link-hint--open-org-agenda-item\n  :at-point-p #'link-hint--org-agenda-item-at-point-p\n  :copy #'kill-new)\n\n;; ** Xref item\n(defun link-hint--next-xref-item (bound)\n  \"Find the next xref item.\nOnly search the range between just after the point and BOUND.\"\n  (link-hint--next-property 'xref-item bound))\n\n(declare-function xref-goto-xref \"xref\")\n(declare-function xref--item-at-point \"xref\")\n(declare-function xref-item-summary \"xref\")\n\n(defun link-hint--copy-xref-item ()\n  \"Copy a xref item in a xref buffer.\"\n  (kill-new (xref-item-summary (xref--item-at-point))))\n\n(link-hint-define-type 'xref-item\n  :next #'link-hint--next-xref-item\n  :vars '(xref--xref-buffer-mode)\n  :open #'xref-goto-xref\n  :at-point-p #'xref--item-at-point\n  :copy #'link-hint--copy-xref-item)\n\n;; ** bug-reference-mode item\n(defun link-hint--next-bug-reference (bound)\n  \"Find the next bug-reference.\"\n  (let ((next (next-single-char-property-change\n               (point) 'bug-reference-url nil bound)))\n    (unless (eq next bound)\n      ;; check 'bug-reference-url is set at next - if it is then return\n      ;; this\n      (catch 'found\n        (dolist (overlay (overlays-at next))\n          (when (overlay-get overlay 'bug-reference-url)\n            (throw 'found next)))\n        ;; otherwise find the next one\n        (setq next\n              (next-single-char-property-change\n               next 'bug-reference-url nil bound))\n        (unless (eq next bound) next)))))\n\n(defun link-hint--bug-reference-at-point-p ()\n  \"Return the bug-reference url at the point or nil.\"\n  (car (get-char-property-and-overlay (point) 'bug-reference-url)))\n\n(link-hint-define-type 'bug-reference\n  :next #'link-hint--next-bug-reference\n  :at-point-p #'link-hint--bug-reference-at-point-p\n  :vars '(bug-reference-mode bug-reference-prog-mode)\n  :open #'browse-url\n  :copy #'kill-new)\n\n;; * Avy/Action Helper Functions\n(defun link-hint--collect (start end type)\n  \"Between START and END in the current buffer, collect all links of TYPE.\"\n  (save-excursion\n    (goto-char start)\n    (let ((current-window (get-buffer-window))\n          (next-func (get type :next))\n          (at-point-p (get type :at-point-p))\n          links\n          link-pos)\n      ;; as all \"next-\" functions are designed to look after the point,\n      ;; check if there is a link at the point the first time, in order\n      ;; to catch links that are at the start bound,\n      ;; TODO explain this better and retest\n      ;; as the eol of an invisible line can be visible in org buffers,\n      ;; don't do this if the point is at the eol\n      ;; TODO make this a do while instead if find a way around this\n      (when (and (not (looking-at (rx eol)))\n                 (funcall at-point-p))\n        (push (list :pos (point)\n                    :win current-window\n                    :args (funcall at-point-p)\n                    :type type)\n              links))\n      (while (setq link-pos (funcall next-func end))\n        (goto-char link-pos)\n        (push (list :pos link-pos\n                    :win current-window\n                    :args (funcall at-point-p)\n                    :type type)\n              links))\n      links)))\n\n;; WORKAROUND for avy--find-visible-regions sometimes excluding visible ranges\n;; (which may be org's fault)\n;; (defun avy--next-invisible-point ()\n;;   \"Return the next closest point with 'invisible property.\"\n;;   (let ((s (point)))\n;;     (while (and (not (= (point-max) (setq s (next-overlay-change s))))\n;;                 (let ((invisible-property (get-char-property s 'invisible)))\n;;                   (or (not invisible-property)\n;;                       (equal invisible-property 'org-link)))))\n;;     s))\n\n;; other way\n;; modified version of avy--find-visible-regions\n\n;; TODO retest avy--find-visible-regions and make a bug report if necessary\n;; TODO consistency (start end vs beg end)\n(defun link-hint--find-visible-regions (rbeg rend)\n  \"Return a list of all visible regions between RBEG and REND.\"\n  (setq rbeg (max rbeg (point-min)))\n  (setq rend (min rend (point-max)))\n  (when (< rbeg rend)\n    (let (visibles beg)\n      (save-excursion\n        (save-restriction\n          (narrow-to-region rbeg rend)\n          (setq beg (goto-char (point-min)))\n          (while (not (= (point) (point-max)))\n            (goto-char (or (link-hint--next-property 'invisible (point-max))\n                           (point-max)))\n            (push (cons beg (point)) visibles)\n            (setq beg (goto-char\n                       (or (next-single-property-change\n                            (point)\n                            'invisible)\n                           (point-max)))))\n          (nreverse visibles))))))\n\n(defun link-hint--equal (x y)\n  \"Return whether links X and Y are equal based on their window and position.\"\n  (and (= (plist-get x :pos)\n          (plist-get y :pos))\n       (eq (plist-get x :win)\n           (plist-get y :win))))\n\n(defun link-hint--< (x y)\n  \"Return whether link X's position is before link Y's.\"\n  (< (plist-get x :pos) (plist-get y :pos)))\n\n(defun link-hint--collect-visible-links ()\n  \"Collect all visible links in the current buffer.\"\n  (let (all-link-positions)\n    (dolist (bounds (link-hint--find-visible-regions (window-start)\n                                                     (window-end nil t)))\n      (dolist (type link-hint-types)\n        (when (link-hint--type-valid-p type)\n          (setq all-link-positions\n                (append all-link-positions\n                        (link-hint--collect (car bounds) (cdr bounds) type))))))\n    (sort (cl-delete-duplicates all-link-positions\n                                :test #'link-hint--equal\n                                ;; types earlier in `link-hint-types' have\n                                ;; higher priority\n                                :from-end t)\n          #'link-hint--<)))\n\n(cl-defun link-hint--get-links ()\n  \"Return a list of all visible links (potentially in multiple windows).\"\n  (let ((avy-all-windows (if (boundp 'link-hint-avy-all-windows)\n                             link-hint-avy-all-windows\n                           avy-all-windows))\n        (avy-all-windows-alt (if (boundp 'link-hint-avy-all-windows-alt)\n                                 link-hint-avy-all-windows-alt\n                               avy-all-windows-alt))\n        (avy-ignored-modes (if (boundp 'link-hint-avy-ignored-modes)\n                               link-hint-avy-ignored-modes\n                             avy-ignored-modes))\n        links)\n    (avy-dowindows current-prefix-arg\n      (setq links (append links (link-hint--collect-visible-links))))\n    (if links\n        links\n      (when link-hint-message\n        (funcall link-hint-message \"No links found.\"))\n      nil)))\n\n(defun link-hint--process (links)\n  \"Select a link from LINKS using avy.\nIf there is only one link in LINKS and `avy-single-candidate-jump' is non-nil,\nreturn it.\"\n  (let ((avy-background (if (boundp 'link-hint-avy-background)\n                            link-hint-avy-background\n                          avy-background))\n        (avy-keys (if (boundp 'link-hint-avy-keys)\n                      link-hint-avy-keys\n                    avy-keys))\n        ;; prevent window from shifting avy overlays out of view\n        (scroll-margin 0))\n    (if (or (cdr links)\n            (not avy-single-candidate-jump))\n        (save-selected-window\n          (let* ((avy-action #'identity)\n                 (pos (avy-process\n                       (mapcar (lambda (x) (cons (plist-get x :pos)\n                                                 (plist-get x :win)))\n                               links)\n                       (avy--style-fn (if (boundp 'link-hint-avy-style)\n                                          link-hint-avy-style\n                                        avy-style)))))\n            (if (numberp pos)\n                (cl-find (list :pos pos :win (get-buffer-window))\n                         links\n                         :test #'link-hint--equal)\n              (when link-hint-message\n                (funcall link-hint-message \"Aborted link selection.\"))\n              nil)))\n      (car links))))\n\n(defun link-hint--apply (func args &optional parser action)\n  \"Try to call FUNC with ARGS.\nIf PARSER is specified, first change ARGS by passing PARSER ARGS and ACTION.\nFirst try `apply'. If there is an error (ARGS is the wrong number of arguments\nfor FUNC), `funcall' FUNC with ARGS. Finally, call FUNC alone.\"\n  (when parser\n    (setq args (funcall parser args action)))\n  ;; TODO is there a way to know how many arguments a function takes?\n  (condition-case nil\n      (apply func args)\n    (error (condition-case nil\n               (funcall func args)\n             (error (funcall func))))))\n\n(defun link-hint--message (action &optional link-description type)\n  \"Display a message about an ACTION performed on a link.\n`link-hint-message' holds the function to use to message (or is nil if there\nshould be no messaging). LINK-DESCRIPTION can either be a number corresponding\nto the number of links acted upon or a description of a single link. Custom\nmessages for ACTION can be created by altering `link-hint-action-messages' or\nadding an :<action>-message property to the link TYPE.\"\n  (when link-hint-message\n    (funcall link-hint-message \"%s %s\"\n             (or (when type\n                   (get type (intern (format \"%s-message\" action))))\n                 (plist-get link-hint-action-messages action)\n                 (format \"Called %s on\" action))\n             (or (when (numberp link-description)\n                   (format \"%s links\" link-description))\n                 link-description\n                 \"a link\"))))\n\n(defun link-hint--action (action link)\n  \"Take ACTION on LINK.\nIf the point/window are not intentionally changed by the action, restore them.\"\n  (let* ((original-win (get-buffer-window))\n         link-buffer\n         link-buffer-original-pos\n         (link-pos (plist-get link :pos))\n         (link-win (plist-get link :win))\n         new-win-buffer\n         (type (plist-get link :type))\n         (parser (get type :parse))\n         (args (plist-get link :args))\n         (link-description (link-hint--apply\n                            (or (get type :describe) #'identity)\n                            args\n                            parser\n                            :describe))\n         ret)\n    (select-window link-win)\n    (setq link-buffer (current-buffer)\n          link-buffer-original-pos (point))\n    (goto-char link-pos)\n    (setq ret (link-hint--apply (get type action) args parser action))\n    (when link-hint-restore\n      ;; note: selected window can change without current buffer changing, so\n      ;; check selected window\n      (setq new-win-buffer (window-buffer (selected-window)))\n      (cond ((and (eq new-win-buffer link-buffer)\n                  (= (point) link-pos))\n             ;; when the buffer doesn't change and the point is still at the\n             ;; link, restore the position and window (no side effects have\n             ;; occurred)\n             (goto-char link-buffer-original-pos)\n             (when (window-valid-p original-win)\n               (select-window original-win)))\n            ((and (buffer-live-p link-buffer)\n                  (not (eq new-win-buffer link-buffer)))\n             ;; when the buffer changes and the old buffer still exists, restore\n             ;; the original position in the old buffer\n             (if (and\n                  ;; old window still exists\n                  (window-valid-p link-win)\n                  ;; old window still holds original buffer\n                  (eq link-buffer (window-buffer link-win)))\n                 ;; restore the point in that window\n                 (set-window-point link-win link-buffer-original-pos)\n               ;; `save-excursion' to prevent altering the current window's\n               ;; point; only set the buffer's point since it is no longer\n               ;; displayed in the old window\n               ;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Point.html#Point\n               (save-excursion\n                 (with-current-buffer link-buffer\n                   (goto-char link-buffer-original-pos)))))\n            ;; when buffer doesn't change but position does (e.g. local org\n            ;; link), do nothing\n            ))\n    (link-hint--message action link-description type)\n    ret))\n\n(defun link-hint--links-action (action links)\n  \"Take ACTION on every link in LINKS.\"\n  (dolist (link links)\n    (let (link-hint-message)\n      (link-hint--action action link)))\n  (link-hint--message action (length links)))\n\n(defun link-hint--valid-types (&rest properties)\n  \"Return a list of valid link hint types based on PROPERTIES.\"\n  (cl-loop for type in link-hint-types\n           when (cl-every (lambda (prop) (get type prop))\n                          properties)\n           collect type))\n\n(defun link-hint--one (action)\n  \"Take ACTION on one visible link selected with avy.\"\n  (let* ((link-hint-types (link-hint--valid-types action))\n         (links (link-hint--get-links))\n         link)\n    (when links\n      (setq link (link-hint--process links))\n      (when link\n        (link-hint--action action link)))))\n\n(defun link-hint--multiple (action)\n  \"Take ACTION on multiple visible links selected with avy.\"\n  (let* ((multiple-action (intern (format \"%s-multiple\" action)))\n         (link-hint-types (link-hint--valid-types action multiple-action))\n         (links (link-hint--get-links))\n         link\n         chosen-links)\n    (while (setq link (link-hint--process links))\n      (push link chosen-links))\n    (link-hint--links-action action (nreverse chosen-links))))\n\n(defun link-hint--all (action)\n  \"Take ACTION on all visible links.\"\n  (let* ((multiple-action (intern (format \"%s-multiple\" action)))\n         (link-hint-types (link-hint--valid-types action multiple-action))\n         (links (link-hint--get-links)))\n    (link-hint--links-action action links)))\n\n;; * User Commands\n;; ** Avy Commands\n;;;###autoload\n(defun link-hint-open-link ()\n  \"Use avy to open a visible link.\"\n  (interactive)\n  (avy-with link-hint-open-link\n    (link-hint--one :open)))\n\n;;;###autoload\n(defun link-hint-copy-link ()\n  \"Copy a visible link of a supported type to the kill ring with avy.\n`select-enable-clipboard' and `select-enable-primary' can be set to non-nil\nvalues to copy the link to the clipboard and/or primary as well.\"\n  (interactive)\n  (avy-with link-hint-copy-link\n    (link-hint--one :copy)))\n\n;;;###autoload\n(defun link-hint-open-multiple-links ()\n  \"Use avy to open multiple visible links at once.\"\n  (interactive)\n  (avy-with link-hint-open-multiple-links\n    (link-hint--multiple :open)))\n\n;;;###autoload\n(defun link-hint-copy-multiple-links ()\n  \"Use avy to copy multiple visible links at once to the kill ring.\"\n  (interactive)\n  (avy-with link-hint-copy-multiple-links\n    (link-hint--multiple :copy)))\n\n;;;###autoload\n(defun link-hint-open-all-links ()\n  \"Open all visible links.\"\n  (interactive)\n  (avy-with link-hint-open-all-links\n    (link-hint--all :open)))\n\n;;;###autoload\n(defun link-hint-copy-all-links ()\n  \"Copy all visible links.\"\n  (interactive)\n  (avy-with link-hint-copy-all-links\n    (link-hint--all :copy)))\n\n;; ** At Point Commands\n(defun link-hint--get-link-at-point ()\n  \"Return the link with the highest priority at the point or nil.\"\n  (let (args)\n    (cl-dolist (type link-hint-types)\n      (when (and (link-hint--type-valid-p type)\n                 (setq args (funcall (get type :at-point-p))))\n        (cl-return (list :pos (point)\n                         :win (get-buffer-window)\n                         :args args\n                         :type type))))))\n\n(defun link-hint--action-at-point (action)\n  \"Take ACTION on the highest priority link at the point.\"\n  (let ((link-hint-types (link-hint--valid-types action))\n        (link (link-hint--get-link-at-point)))\n    (if link\n        (link-hint--action action link)\n      (let ((fallback (plist-get link-hint-action-fallback-commands action)))\n        (unless (or (and fallback (funcall fallback))\n                    (not link-hint-message))\n          (funcall link-hint-message\n                   \"There is no link supporting the %s action at the point.\"\n                   action))))))\n\n;;;###autoload\n(defun link-hint-open-link-at-point ()\n  \"Open the link with the highest priority at the point.\"\n  (interactive)\n  (link-hint--action-at-point :open))\n\n;;;###autoload\n(defun link-hint-copy-link-at-point ()\n  \"Copy the link with the highest priority at the point.\"\n  (interactive)\n  (link-hint--action-at-point :copy))\n\n(provide 'link-hint)\n;;; link-hint.el ends here\n"
  }
]