├── .dir-locals.el ├── .github └── workflows │ └── compile.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.org └── elx.el /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((nil 2 | (indent-tabs-mode . nil)) 3 | (makefile-mode 4 | (indent-tabs-mode . t)) 5 | (git-commit-mode 6 | (git-commit-major-mode . git-commit-elisp-text-mode))) 7 | -------------------------------------------------------------------------------- /.github/workflows/compile.yml: -------------------------------------------------------------------------------- 1 | name: Compile 2 | on: [push, pull_request] 3 | jobs: 4 | compile: 5 | name: Compile 6 | uses: emacscollective/workflows/.github/workflows/compile.yml@main 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.elc 2 | /*-autoloads.el 3 | /.config.mk 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | -include .config.mk 2 | 3 | PKG = elx 4 | 5 | ELS = $(PKG).el 6 | ELCS = $(ELS:.el=.elc) 7 | 8 | DEPS = compat 9 | DEPS += llama 10 | DEPS += seq 11 | 12 | EMACS ?= emacs 13 | EMACS_ARGS ?= 14 | 15 | LOAD_PATH ?= $(addprefix -L ../,$(DEPS)) 16 | LOAD_PATH += -L . 17 | 18 | all: lisp 19 | 20 | help: 21 | $(info make all - generate byte-code and autoloads) 22 | $(info make lisp - generate byte-code and autoloads) 23 | $(info make redo - re-generate byte-code and autoloads) 24 | $(info make clean - remove generated files) 25 | @printf "\n" 26 | 27 | redo: clean lisp 28 | 29 | lisp: $(ELCS) loaddefs check-declare 30 | 31 | loaddefs: $(PKG)-autoloads.el 32 | 33 | %.elc: %.el 34 | @printf "Compiling $<\n" 35 | @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) -f batch-byte-compile $< 36 | 37 | check-declare: 38 | @printf " Checking function declarations\n" 39 | @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) \ 40 | --eval "(check-declare-directory default-directory)" 41 | 42 | CLEAN = $(ELCS) $(PKG)-autoloads.el 43 | 44 | clean: 45 | @printf " Cleaning...\n" 46 | @rm -rf $(CLEAN) 47 | 48 | $(PKG)-autoloads.el: $(ELS) 49 | @printf " Creating $@\n" 50 | @$(EMACS) -Q --batch -l autoload -l cl-lib --eval "\ 51 | (let ((file (expand-file-name \"$@\"))\ 52 | (autoload-timestamps nil) \ 53 | (backup-inhibited t)\ 54 | (version-control 'never)\ 55 | (coding-system-for-write 'utf-8-emacs-unix))\ 56 | (write-region (autoload-rubric file \"package\" nil) nil file nil 'silent)\ 57 | (cl-letf (((symbol-function 'progress-reporter-do-update) (lambda (&rest _)))\ 58 | ((symbol-function 'progress-reporter-done) (lambda (_))))\ 59 | (let ((generated-autoload-file file))\ 60 | (update-directory-autoloads default-directory))))" \ 61 | 2>&1 | sed "/^Package autoload is deprecated$$/d" 62 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * Extracts information from Emacs Lisp libraries 2 | 3 | This package extends the built-in ~lisp-mnt~, which is only 4 | suitable for libraries that closely follow the header conventions. 5 | Unfortunately there are many libraries that do not - this library 6 | tries to cope with that. 7 | 8 | It also defines some new extractors not available in ~lisp-mnt~, 9 | and some generalizations of extractors available in the latter. 10 | 11 | #+html:

12 | #+html: Compile 13 | #+html: MELPA Stable 14 | #+html: MELPA 15 | -------------------------------------------------------------------------------- /elx.el: -------------------------------------------------------------------------------- 1 | ;;; elx.el --- Extract information from Emacs Lisp libraries -*- lexical-binding:t -*- 2 | 3 | ;; Copyright (C) 2008-2025 Jonas Bernoulli 4 | 5 | ;; Includes code from Emacs, which is 6 | ;; Copyright (C) 1985-2022 Free Software Foundation, Inc. 7 | 8 | ;; Author: Jonas Bernoulli 9 | ;; Homepage: https://github.com/emacscollective/elx 10 | ;; Keywords: docs libraries packages 11 | 12 | ;; Package-Version: 2.2.2 13 | ;; Package-Requires: ( 14 | ;; (emacs "26.1") 15 | ;; (compat "30.1") 16 | ;; (llama "0.6.3") 17 | ;; (seq "2.24")) 18 | 19 | ;; SPDX-License-Identifier: GPL-3.0-or-later 20 | 21 | ;; This file is free software: you can redistribute it and/or modify 22 | ;; it under the terms of the GNU General Public License as published 23 | ;; by the Free Software Foundation, either version 3 of the License, 24 | ;; or (at your option) any later version. 25 | ;; 26 | ;; This file is distributed in the hope that it will be useful, 27 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | ;; GNU General Public License for more details. 30 | ;; 31 | ;; You should have received a copy of the GNU General Public License 32 | ;; along with this file. If not, see . 33 | 34 | ;;; Commentary: 35 | 36 | ;; This package extracts information from Emacs Lisp libraries. It 37 | ;; extends built-in `lisp-mnt', which is only suitable for libraries 38 | ;; that closely follow the header conventions. Unfortunately there 39 | ;; are many libraries that do not - this library tries to cope with 40 | ;; that. 41 | 42 | ;; It also defines some new extractors not available in `lisp-mnt', 43 | ;; and some generalizations of extractors available in the latter. 44 | 45 | ;;; Code: 46 | 47 | (require 'compat) 48 | (require 'json) 49 | (require 'lisp-mnt) 50 | (require 'llama) 51 | (require 'package) 52 | (require 'seq) 53 | (require 'subr-x) 54 | 55 | (defgroup elx nil 56 | "Extract information from Emacs Lisp libraries." 57 | :group 'maint 58 | :link '(url-link :tag "Homepage" "https://github.com/emacscollective/elx")) 59 | 60 | ;;; Extract Summary 61 | 62 | (defun elx-summary (&optional file sanitize) 63 | "Return the one-line summary of file FILE. 64 | If optional FILE is nil return the summary of the current buffer 65 | instead. When optional SANITIZE is non-nil a trailing period is 66 | removed and the first word is upcases." 67 | (lm-with-file file 68 | (and (cl-flet ((summary-match () 69 | (and (looking-at lm-header-prefix) 70 | (progn (goto-char (match-end 0)) 71 | (looking-at "[^ ]+[ \t]+--+[ \t]+\\(.*\\)"))))) 72 | (or (summary-match) 73 | ;; Some people put the -*- specification on a separate 74 | ;; line, pushing the summary to the second or third line. 75 | (progn (forward-line) (summary-match)) 76 | (progn (forward-line) (summary-match)))) 77 | (let ((summary (match-string-no-properties 1))) 78 | (and (not (equal summary "")) 79 | (progn 80 | ;; Strip off -*- specifications. 81 | (when (string-match "[ \t]*-\\*-.*-\\*-" summary) 82 | (setq summary (substring summary 0 (match-beginning 0)))) 83 | (when sanitize 84 | (when (string-suffix-p "." summary) 85 | (setq summary (substring summary 0 -1))) 86 | (when (string-match "^[a-z]" summary) 87 | (setq summary 88 | (concat (upcase (substring summary 0 1)) 89 | (substring summary 1))))) 90 | (and (not (equal summary "")) 91 | summary))))))) 92 | 93 | ;;; Extract Keywords 94 | 95 | (defcustom elx-remap-keywords nil 96 | "List of keywords that should be replaced or dropped by `elx-keywords'. 97 | If function `elx-keywords' is called with a non-nil SANITIZE 98 | argument it checks this variable to determine if keywords should 99 | be dropped from the return value or replaced by another. If the 100 | cdr of an entry is nil then the keyword is dropped; otherwise it 101 | will be replaced with the keyword in the cadr." 102 | :group 'elx 103 | :type '(repeat (list string (choice (const :tag "drop" nil) 104 | (string :tag "replacement"))))) 105 | 106 | (defvar elx-keywords-regexp "^[- a-z]+$") 107 | 108 | (defun elx-keywords-list (&optional file sanitize symbols) 109 | "Return list of keywords given in file FILE. 110 | If optional FILE is nil return keywords given in the current 111 | buffer instead. If optional SANITIZE is non-nil replace or 112 | remove some keywords according to option `elx-remap-keywords'. 113 | If optional SYMBOLS is non-nil return keywords as symbols, 114 | else as strings." 115 | (lm-with-file file 116 | (let (keywords) 117 | (dolist (line (lm-header-multiline "keywords")) 118 | (dolist (keyword (split-string 119 | (downcase line) 120 | (concat "\\(" 121 | (if (string-search "," line) 122 | ",[ \t]*" 123 | "[ \t]+") 124 | "\\|[ \t]+and[ \t]+\\)") 125 | t)) 126 | (when sanitize 127 | (when-let ((remap (assoc keyword elx-remap-keywords))) 128 | (setq keyword (cadr remap))) 129 | (when (and keyword (string-match elx-keywords-regexp keyword)) 130 | (push keyword keywords))))) 131 | (setq keywords (delete-dups (sort keywords 'string<))) 132 | (if symbols (mapcar #'intern keywords) keywords)))) 133 | 134 | ;;; Extract Commentary 135 | 136 | (defun elx-commentary (&optional file sanitize) 137 | "Return the commentary in file FILE, or current buffer if FILE is nil. 138 | Return the value as a string. In the file, the commentary 139 | section starts with the tag `Commentary' or `Documentation' and 140 | ends just before the next section. If the commentary section is 141 | absent, return nil. 142 | 143 | If optional SANITIZE is non-nil cleanup the returned string. 144 | Leading and trailing whitespace is removed from the returned 145 | value but it always ends with exactly one newline. On each line 146 | the leading semicolons and exactly one space are removed, 147 | likewise leading \"\(\" is replaced with just \"(\". Lines 148 | consisting only of whitespace are converted to empty lines." 149 | (lm-with-file file 150 | (and-let* ((start (lm-section-start lm-commentary-header t))) 151 | (progn ; debbugs#31840 152 | (goto-char start) 153 | (let ((commentary (buffer-substring-no-properties 154 | start (lm-commentary-end)))) 155 | (when sanitize 156 | (mapc (lambda (elt) 157 | (setq commentary (replace-regexp-in-string 158 | (car elt) (cdr elt) commentary))) 159 | '(("^;+ ?" . "") 160 | ("^\\\\(" . "(") 161 | ("^ \n" . "") 162 | ("^[\n\t\s]\n$" . "\n") 163 | ("\\`[\n\t\s]*" . "") 164 | ("[\n\t\s]*\\'" . ""))) 165 | (setq commentary 166 | (and (string-match "[^\s\t\n]" commentary) 167 | (concat commentary "\n")))) 168 | commentary))))) 169 | 170 | ;;; Extract and Update Package-Requires 171 | 172 | (defun elx-package-requires (&optional file extra) 173 | "Extract the value of the Package-Requires header of the specified package. 174 | If optional EXTRA is non-nil, then return (VALUE BEG END INDENT), 175 | where INDENT is either nil, if the value was specified on a 176 | single line, or the prefix used on continuation lines." 177 | (pcase-let ((`(,lines ,beg ,end ,indent) 178 | (lm-with-file file 179 | (elx--header-multiline "package-requires" t)))) 180 | (and-let* ((lines lines) 181 | (value (funcall (cond 182 | ((fboundp 'lm--prepare-package-dependencies) 183 | 'lm--prepare-package-dependencies) 184 | ((fboundp 'package--prepare-dependencies) 185 | 'package--prepare-dependencies) 186 | ((error "elx-package-requires: BUG"))) 187 | (package-read-from-string 188 | (string-join lines " "))))) 189 | (if extra (list value beg end indent) value)))) 190 | 191 | (defun elx-update-package-requires (&optional file updates indent noerror) 192 | (pcase-let* ((`(,value ,beg ,end ,i) (elx-package-requires file t)) 193 | (indent (or i (and indent (make-string indent ?\s))))) 194 | (if (not value) 195 | (unless noerror 196 | (error "Cannot update Package-Requires; cannot be found")) 197 | (setq value (elx--update-dependencies value updates)) 198 | (save-excursion 199 | (goto-char beg) 200 | (delete-region beg end) 201 | (insert ";; Package-Requires: (") 202 | (setq value (mapcar (##format "%S" %) value)) 203 | (if (not indent) 204 | (insert (string-join value " ") ")\n") 205 | (insert "\n") 206 | (while-let ((line (pop value))) 207 | (insert ";;" indent line (if value "\n" ")\n")))))))) 208 | 209 | (defun elx--update-dependencies (value updates) 210 | (pcase-dolist (`(,pkg ,ver) updates) 211 | (when (alist-get pkg value) 212 | (setf (alist-get pkg value) 213 | (list ver)))) 214 | (cl-sort value 215 | (lambda (a b) 216 | (pcase (list a b) 217 | (`(emacs ,_) t) 218 | (`(,_ emacs) nil) 219 | (`(compat ,_) t) 220 | (`(,_ compat) nil) 221 | (_ (string< a b)))) 222 | :key #'car)) 223 | 224 | ;;; Extract Pages 225 | 226 | (defun elx-wikipage (&optional file) 227 | "Extract the Emacswiki page of the specified package." 228 | (when-let ((page (lm-with-file file (lm-header "Doc URL")))) 229 | (and (string-match 230 | "^?$" 231 | page) 232 | (match-string 1 page)))) 233 | 234 | ;;; Extract License 235 | 236 | (defconst elx-gnu-permission-statement-regexp 237 | (string-replace 238 | "\s" "[\s\t\n;]+" 239 | ;; is free software[.,:;]? \ 240 | ;; you can redistribute it and/or modify it under the terms of the \ 241 | "\ 242 | GNU \\(?1:Lesser \\| Library \\|Affero \\|Free \\)?\ 243 | General Public Licen[sc]e[.,:;]? \ 244 | \\(?:as published by the \\(?:Free Software Foundation\\|FSF\\)[.,:;]? \\)?\ 245 | \\(?:either \\)?\ 246 | \\(?:GPL \\)?\ 247 | version \\(?2:[0-9.]*[0-9]\\)[.,:;]?\ 248 | \\(?: of the Licen[sc]e[.,:;]?\\)?\ 249 | \\(?3: or \\(?:(?at your option)? \\)?any later version\\)?")) 250 | 251 | (defconst elx-bsd-permission-statement-regexp 252 | (string-replace 253 | "%" "[-0-4).*\s\t\n;]+" 254 | (string-replace 255 | "\s" "[\s\t\n;]+" 256 | ;; Copyright (c) , 257 | ;; All rights reserved. 258 | "\ 259 | Redistribution and use in source and binary forms, with or without \ 260 | modification, are permitted provided that the following conditions are met: \ 261 | %Redistributions of source code must retain the above copyright \ 262 | notice, this list of conditions and the following disclaimer\\. 263 | \ 264 | %Redistributions in binary form must reproduce the above copyright \ 265 | notice, this list of conditions and the following disclaimer in the \ 266 | documentation and/or other materials provided with the distribution\\. \ 267 | \ 268 | \\(?3:\\(?4:%All advertising materials mentioning features or use of this software \ 269 | must display the following acknowledgement: \ 270 | \ 271 | This product includes software developed by .+?\\. \\)?\ 272 | %\\(?:Neither the name of .+? nor the names of its contributors may\\|\ 273 | The name of the University may not\\) \ 274 | be used to endorse or promote products \ 275 | derived from this software without specific prior written permission\\. \\)?\ 276 | \ 277 | THIS SOFTWARE IS PROVIDED BY \ 278 | \\(?:THE \\(UNIVERSITY\\|COPYRIGHT HOLDERS?\\|COPYRIGHT OWNERS?\\)\ 279 | \\(?: \\(?:AND\\|OR\\) CONTRIBUTORS\\)?\\|.+?\\) \ 280 | [\"'`]*AS IS[\"'`]* AND ANY \ 281 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 282 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \ 283 | DISCLAIMED. IN NO EVENT SHALL \ 284 | \\(?:THE \\(UNIVERSITY\\|COPYRIGHT HOLDERS?\\|COPYRIGHT OWNERS?\\)\ 285 | \\(?: \\(?:AND\\|OR\\) CONTRIBUTORS\\)?\\|.+?\\) \ 286 | BE LIABLE FOR ANY \ 287 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \ 288 | \(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \ 289 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND \ 290 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \ 291 | \(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \ 292 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\\."))) 293 | 294 | (defconst elx-mit-permission-statement-regexp 295 | (string-replace 296 | "\s" "[\s\t\n;]+" 297 | ;; Copyright (c) 298 | ;; 299 | "\ 300 | Permission is hereby granted, free of charge, to any person obtaining a copy \ 301 | of this software and associated documentation files\\(?: (the \"Software\")\\)?, \ 302 | to deal \ 303 | in the Software without restriction, including without limitation the rights \ 304 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ 305 | copies of the Software, and to permit persons to whom the Software is \ 306 | furnished to do so, subject to the following conditions: \ 307 | \ 308 | The above copyright notice and this permission notice shall be included in all \ 309 | copies or substantial portions of the Software\\. \ 310 | \ 311 | THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \ 312 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \ 313 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\\. IN NO EVENT SHALL THE \ 314 | \\(?:AUTHORS OR COPYRIGHT HOLDERS\\|.+?\\) \ 315 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \ 316 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \ 317 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE \ 318 | SOFTWARE\\.\ 319 | \\( \ 320 | Except as contained in this notice, \ 321 | the names? \\(?:of the above copyright holders\\|.+?\\) shall not be 322 | used in advertising or otherwise to promote the sale, use or other dealings in 323 | this Software without prior written authorization\\)?" 324 | ;; "." or "from ." 325 | )) 326 | 327 | (defconst elx-isc-permission-statement-regexp 328 | (string-replace 329 | "\s" "[\s\t\n;]+" 330 | ;; Copyright 331 | ;; 332 | "\ 333 | Permission to use, copy, modify, and\\(/or\\)? distribute this software \ 334 | for any purpose with or without fee is hereby granted, provided \ 335 | that the above copyright notice and this permission notice appear \ 336 | in all copies\\. \ 337 | \ 338 | THE SOFTWARE IS PROVIDED [\"'`]*AS IS[\"'`]* AND THE AUTHOR \ 339 | DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING \ 340 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\\. IN NO \ 341 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, \ 342 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER \ 343 | RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION \ 344 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF \ 345 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE\\.")) 346 | 347 | (defconst elx-cc-permission-statement-regexp 348 | (string-replace 349 | "\s" "[\s\t\n;]+" 350 | ;; This work is 351 | "\ 352 | licensed under the Creative Commons \ 353 | \\(Attribution\ 354 | \\|Attribution-ShareAlike\ 355 | \\|Attribution-NonCommercial\ 356 | \\|Attribution-NoDerivs\ 357 | \\|Attribution-NonCommercial-ShareAlike\ 358 | \\|Attribution-NonCommercial-NoDerivs\ 359 | \\) \ 360 | \\([0-9.]+\\) .*?Licen[sc]e\\." 361 | ;; To view a copy of this license, visit" 362 | )) 363 | 364 | (defconst elx-wtf-permission-statement-regexp 365 | (string-replace 366 | "\s" "[\s\t\n;]+" 367 | ;; This program is 368 | "\ 369 | free software. It comes without any warranty, to \ 370 | the extent permitted by applicable law\\. You can redistribute it \ 371 | and/or modify it under the terms of the Do What The Fuck You Want \ 372 | To Public License, Version 2, as published by Sam Hocevar\\.")) 373 | 374 | (defconst elx-gnu-license-keyword-regexp "\ 375 | \\(?:GNU \\(?1:Lesser \\|Library \\|Affero \\|Free \\)?General Public Licen[sc]e ?\ 376 | \\|\\(?4:[laf]?gpl\\)[- ]?\ 377 | \\)\ 378 | \\(?5:>= \\)?\ 379 | \\(?:\\(?:[vV]\\|version \\)?\\(?2:[0-9.]*[0-9]\\)\\)?\ 380 | \\(?3:\\(?:\\+\ 381 | \\|,? or \\(?:(at your option) \\)?\\(?:any \\)?later\\(?: version\\)?\ 382 | \\|,? or newer\ 383 | \\|,? or whatever newer comes along\ 384 | \\)\\)?") 385 | 386 | (defconst elx-gnu-non-standard-permission-statement-alist 387 | `(;; SPDX: 388 | ("GPL-3.0-or-later" . "^;\\{1,4\\} Licensed under the same terms as Emacs") 389 | ("GPL-2.0-or-later" . "^;; :licence: GPL 2 or later (free software)") 390 | ("GPL-2.0-only" . ,(string-replace "\s" "[\s\n;]+" "\ 391 | This file is free software; you can redistribute it and/or \ 392 | modify it under the terms of version 2 of the GNU General \ 393 | Public License as published by the Free Software Foundation\\.")) ; lmselect, tiger 394 | ;; non-SPDX: 395 | ("GPL" . "^;; Copyright (c) [-0-9]+ Jason Milkins (GNU/GPL Licence)") 396 | ("GPL" . "^;; GPL'ed under GNU'S public license") 397 | )) 398 | 399 | (defconst elx-non-gnu-license-keyword-alist 400 | '(;; SPDX: 401 | ("Apache-2.0" . "apache-2\\.0") 402 | ("Artistic-1.0" . "Artistic-1.0") 403 | ("BSD-3-Clause" . "BSD Licen[sc]e 2\\.0") 404 | ("BSD-3-Clause" . "\\(Revised\\|New\\|Modified\\) BSD\\( Licen[sc]e\\)?") 405 | ("BSD-3-Clause" . "BSD[-v]?3") 406 | ("BSD-3-Clause" . "BSD[- ]3-clause\\( license\\)?") 407 | ("BSD-2-Clause" . "BSD[-v]?2") 408 | ("BSD-2-Clause" . "BSD[- ]2-clause\\( license\\)?") 409 | ("BSD-2-Clause" . "Simplified BSD\\( Licen[sc]e\\)?") 410 | ("BSD-2-Clause" . "The same license terms as Ruby") 411 | ("CC0-1.0" . "CC0") 412 | ("MIT" . "mit") 413 | ("WTFPL" . "WTFPL .+?http://sam\\.zoy\\.org/wtfpl") 414 | ("WTFPL" . "WTFPL") 415 | ("CECILL-2.1" . "CeCILL Free Software License Agreement v2.1") ; lambdapi-mode 416 | ("CECILL-B" . "CeCILL-B") 417 | ("MS-PL" . "MS-PL") 418 | ("Unlicense" . "Unlicense") 419 | ("Beerware" . "BEER-WARE") 420 | ;; non-SPDX: 421 | ("as-is" . "as-?is") 422 | ("as-is" . "free for all usages/modifications/distributions/whatever.") ; darkroom-mode, w32-fullscreen 423 | ("public-domain" . "public[- ]domain") 424 | )) 425 | 426 | (defconst elx-non-gnu-license-keyword-regexp "\ 427 | \\`\\(?4:[a-z]+\\)\\(?:\\(?:v\\|version \\)?\\(?2:[0-9.]*[0-9]\\)\\)?\\'") 428 | 429 | (defconst elx-permission-statement-alist 430 | `(;; SPDX: 431 | ("Apache-2.0" . "^;.* Apache Licen[sc]e, Version 2\\.0") 432 | ("MIT" . "^;.* mit licen[sc]e") 433 | ("MIT" . "^;; This file is free software (MIT License)$") 434 | ("MIT-0" . "^;; terms of the MIT No Attribution license\\.") ; logpad 435 | ("GPL-3.0-or-later" . "^;; Licensed under the same terms as Emacs\\.$") 436 | ("GPL-3.0-or-later" . "^;; This file may be distributed under the same terms as GNU Emacs\\.$") 437 | ("GPL-3.0-or-later" . "^;; Licensed under the same terms as Org-mode") 438 | ("GPL-3.0-or-later" . "^;; Standard GPL v3 or higher license applies\\.") 439 | ("GPL-3.0-only" . "^;; This file is free software (GPLv3 License)$") 440 | ("GPL-3.0-only" . "^;; This software is licensed under the GPL version 3") 441 | ("GPL-3.0-only" . "^;; This software can be redistributed\\. GPL v3 applies\\.$") 442 | ("GPL-3.0-only" . "^;; This file is licensed under GPLv3\\.$") ; metapost-mode+ 443 | ("GPL-2.0-or-later" . "^;; choice of the GNU General Public License (version 2 or later),$") ; uuid 444 | ("GPL-2.0-only" . "^;; This software can be redistributed\\. GPL v2 applies\\.$") 445 | ("WTFPL" . "do what the fuck you want to public licen[sc]e,? version 2") 446 | ("WTFPL" . "do what the fuck you want to") 447 | ("WTFPL" . "wtf public licen[sc]e") 448 | ("BSD-2-Clause" . "^;; Simplified BSD Licen[sc]e$") 449 | ("BSD-2-Clause" . "This software can be treated with: ``The 2-Clause BSD License''") ; yatex 450 | ("BSD-3-Clause" . "^;; 3-clause \"new bsd\"") 451 | ("BSD-3-Clause" . "freely distributable under the terms of a new BSD licence") ; tinysegmenter 452 | ("BSD-3-Clause" . "^; Distributed under the OSI-approved BSD 3-Clause License") ; cmake-mode 453 | ("BSD-3-Clause" . "Licensed under the BSD-3-[cC]lause [lL]icense\\.$") ; gsettings, gvariant 454 | ("BSD-3-Clause" . "Licensed under the 3-[cC]lause BSD [lL]icense\\.$") ; balanced-windows 455 | ("Artistic-2.0" . "^;; .*Artistic Licen[sc]e 2\\.0") 456 | ("CeCILL-B" . "^;; It is a free software under the CeCILL-B license\\.$") 457 | ("MS-PL" . "^;; This code is distributed under the MS-Public License") 458 | ("MS-PL" . "licensed under the Ms-PL") 459 | ("Ruby" . "^;;; Use and distribution subject to the terms of the Ruby license\\.$") ; rcodetools 460 | ("Beerware" . "^;; If you like this package and we meet in the future, you can buy me a 461 | ;; beer\\. Otherwise, if we don't meet, drink a beer anyway\\.") ; distel-completion-lib 462 | ("CC-BY-SA-4.0" . "^;; This file is distributed under the Creative Commons 463 | ;; Attribution-ShareAlike 4\\.0 International Public License") ; sicp-info 464 | ("CC-BY-NC-SA-3.0" . "^;; \\[CC BY-NC-SA 3\\.0\\](http://creativecommons\\.org/licenses/by-nc-sa/3\\.0/)") ; vimgolf 465 | ("Unicode-TOU" . "covered by the Unicode copyright terms") ; uni-confusables 466 | ;; non-SPDX: 467 | ("GPL" . "^;; Released under the GPL") 468 | ("GPL" . "^;; Licensed under the GPL") 469 | ("COPYLOVE" . "^;; Copying is an act of love, please copy\\.") 470 | ("public-domain" . "^;.*in\\(to\\)? the public[- ]domain") 471 | ("public-domain" . "^;+ +Public domain") 472 | ("public-domain" . "^;+ This program belongs to the public domain") 473 | ("public-domain" . "^;; This file is public domain") 474 | ("public-domain" . "placed in the Public\n;;;? Domain") ; manued 475 | ("public-domain" . "^;; No license, this code is under public domain, do whatever you want") ; company-go 476 | ("as-is" . "\"as is\"*") 477 | ("as-is" . "\\*as is\\*") 478 | ("as-is" . "‘as-is’") 479 | ("as-is" . "^;;; ada-ref-man\\.el --- Ada Reference Manual 2012$") ; ada-ref-man 480 | ("as-is" . "^;.* \\(\\(this\\|the\\) \\(software\\|file\\) is \\)\ 481 | \\(provided\\|distributed\\) \ 482 | \\(by the \\(author?\\|team\\|copyright holders\\)\\( and contributors\\)? \\)?\ 483 | [\"'`]*as\\(\n;;\\)?[- ]is[\"'`]*") 484 | )) 485 | 486 | (defconst elx-spdx-license-identifiers 487 | '( 488 | ;; (progn 489 | ;; (insert ?\n) 490 | ;; (zap-up-to-char 1 ?\)) 491 | ;; (mapc (lambda (license) (insert (format " %S\n" license))) 492 | ;; (sort (mapcar 493 | ;; (lambda (elt) (cdr (assoc 'licenseId elt))) 494 | ;; (with-temp-buffer 495 | ;; (url-insert-file-contents 496 | ;; "https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json") 497 | ;; (cdr (assoc 'licenses (json-read))))) 498 | ;; #'string<))) 499 | "0BSD" 500 | "AAL" 501 | "ADSL" 502 | "AFL-1.1" 503 | "AFL-1.2" 504 | "AFL-2.0" 505 | "AFL-2.1" 506 | "AFL-3.0" 507 | "AGPL-1.0" 508 | "AGPL-1.0-only" 509 | "AGPL-1.0-or-later" 510 | "AGPL-3.0" 511 | "AGPL-3.0-only" 512 | "AGPL-3.0-or-later" 513 | "AMDPLPA" 514 | "AML" 515 | "AMPAS" 516 | "ANTLR-PD" 517 | "ANTLR-PD-fallback" 518 | "APAFML" 519 | "APL-1.0" 520 | "APSL-1.0" 521 | "APSL-1.1" 522 | "APSL-1.2" 523 | "APSL-2.0" 524 | "Abstyles" 525 | "Adobe-2006" 526 | "Adobe-Glyph" 527 | "Afmparse" 528 | "Aladdin" 529 | "Apache-1.0" 530 | "Apache-1.1" 531 | "Apache-2.0" 532 | "Artistic-1.0" 533 | "Artistic-1.0-Perl" 534 | "Artistic-1.0-cl8" 535 | "Artistic-2.0" 536 | "BSD-1-Clause" 537 | "BSD-2-Clause" 538 | "BSD-2-Clause-FreeBSD" 539 | "BSD-2-Clause-NetBSD" 540 | "BSD-2-Clause-Patent" 541 | "BSD-2-Clause-Views" 542 | "BSD-3-Clause" 543 | "BSD-3-Clause-Attribution" 544 | "BSD-3-Clause-Clear" 545 | "BSD-3-Clause-LBNL" 546 | "BSD-3-Clause-Modification" 547 | "BSD-3-Clause-No-Military-License" 548 | "BSD-3-Clause-No-Nuclear-License" 549 | "BSD-3-Clause-No-Nuclear-License-2014" 550 | "BSD-3-Clause-No-Nuclear-Warranty" 551 | "BSD-3-Clause-Open-MPI" 552 | "BSD-4-Clause" 553 | "BSD-4-Clause-Shortened" 554 | "BSD-4-Clause-UC" 555 | "BSD-Protection" 556 | "BSD-Source-Code" 557 | "BSL-1.0" 558 | "BUSL-1.1" 559 | "Bahyph" 560 | "Barr" 561 | "Beerware" 562 | "BitTorrent-1.0" 563 | "BitTorrent-1.1" 564 | "BlueOak-1.0.0" 565 | "Borceux" 566 | "C-UDA-1.0" 567 | "CAL-1.0" 568 | "CAL-1.0-Combined-Work-Exception" 569 | "CATOSL-1.1" 570 | "CC-BY-1.0" 571 | "CC-BY-2.0" 572 | "CC-BY-2.5" 573 | "CC-BY-2.5-AU" 574 | "CC-BY-3.0" 575 | "CC-BY-3.0-AT" 576 | "CC-BY-3.0-DE" 577 | "CC-BY-3.0-NL" 578 | "CC-BY-3.0-US" 579 | "CC-BY-4.0" 580 | "CC-BY-NC-1.0" 581 | "CC-BY-NC-2.0" 582 | "CC-BY-NC-2.5" 583 | "CC-BY-NC-3.0" 584 | "CC-BY-NC-3.0-DE" 585 | "CC-BY-NC-4.0" 586 | "CC-BY-NC-ND-1.0" 587 | "CC-BY-NC-ND-2.0" 588 | "CC-BY-NC-ND-2.5" 589 | "CC-BY-NC-ND-3.0" 590 | "CC-BY-NC-ND-3.0-DE" 591 | "CC-BY-NC-ND-3.0-IGO" 592 | "CC-BY-NC-ND-4.0" 593 | "CC-BY-NC-SA-1.0" 594 | "CC-BY-NC-SA-2.0" 595 | "CC-BY-NC-SA-2.0-FR" 596 | "CC-BY-NC-SA-2.0-UK" 597 | "CC-BY-NC-SA-2.5" 598 | "CC-BY-NC-SA-3.0" 599 | "CC-BY-NC-SA-3.0-DE" 600 | "CC-BY-NC-SA-3.0-IGO" 601 | "CC-BY-NC-SA-4.0" 602 | "CC-BY-ND-1.0" 603 | "CC-BY-ND-2.0" 604 | "CC-BY-ND-2.5" 605 | "CC-BY-ND-3.0" 606 | "CC-BY-ND-3.0-DE" 607 | "CC-BY-ND-4.0" 608 | "CC-BY-SA-1.0" 609 | "CC-BY-SA-2.0" 610 | "CC-BY-SA-2.0-UK" 611 | "CC-BY-SA-2.1-JP" 612 | "CC-BY-SA-2.5" 613 | "CC-BY-SA-3.0" 614 | "CC-BY-SA-3.0-AT" 615 | "CC-BY-SA-3.0-DE" 616 | "CC-BY-SA-4.0" 617 | "CC-PDDC" 618 | "CC0-1.0" 619 | "CDDL-1.0" 620 | "CDDL-1.1" 621 | "CDL-1.0" 622 | "CDLA-Permissive-1.0" 623 | "CDLA-Permissive-2.0" 624 | "CDLA-Sharing-1.0" 625 | "CECILL-1.0" 626 | "CECILL-1.1" 627 | "CECILL-2.0" 628 | "CECILL-2.1" 629 | "CECILL-B" 630 | "CECILL-C" 631 | "CERN-OHL-1.1" 632 | "CERN-OHL-1.2" 633 | "CERN-OHL-P-2.0" 634 | "CERN-OHL-S-2.0" 635 | "CERN-OHL-W-2.0" 636 | "CNRI-Jython" 637 | "CNRI-Python" 638 | "CNRI-Python-GPL-Compatible" 639 | "CPAL-1.0" 640 | "CPL-1.0" 641 | "CPOL-1.02" 642 | "CUA-OPL-1.0" 643 | "Caldera" 644 | "ClArtistic" 645 | "Condor-1.1" 646 | "Crossword" 647 | "CrystalStacker" 648 | "Cube" 649 | "D-FSL-1.0" 650 | "DOC" 651 | "DRL-1.0" 652 | "DSDP" 653 | "Dotseqn" 654 | "ECL-1.0" 655 | "ECL-2.0" 656 | "EFL-1.0" 657 | "EFL-2.0" 658 | "EPICS" 659 | "EPL-1.0" 660 | "EPL-2.0" 661 | "EUDatagrid" 662 | "EUPL-1.0" 663 | "EUPL-1.1" 664 | "EUPL-1.2" 665 | "Entessa" 666 | "ErlPL-1.1" 667 | "Eurosym" 668 | "FSFAP" 669 | "FSFUL" 670 | "FSFULLR" 671 | "FTL" 672 | "Fair" 673 | "Frameworx-1.0" 674 | "FreeBSD-DOC" 675 | "FreeImage" 676 | "GD" 677 | "GFDL-1.1" 678 | "GFDL-1.1-invariants-only" 679 | "GFDL-1.1-invariants-or-later" 680 | "GFDL-1.1-no-invariants-only" 681 | "GFDL-1.1-no-invariants-or-later" 682 | "GFDL-1.1-only" 683 | "GFDL-1.1-or-later" 684 | "GFDL-1.2" 685 | "GFDL-1.2-invariants-only" 686 | "GFDL-1.2-invariants-or-later" 687 | "GFDL-1.2-no-invariants-only" 688 | "GFDL-1.2-no-invariants-or-later" 689 | "GFDL-1.2-only" 690 | "GFDL-1.2-or-later" 691 | "GFDL-1.3" 692 | "GFDL-1.3-invariants-only" 693 | "GFDL-1.3-invariants-or-later" 694 | "GFDL-1.3-no-invariants-only" 695 | "GFDL-1.3-no-invariants-or-later" 696 | "GFDL-1.3-only" 697 | "GFDL-1.3-or-later" 698 | "GL2PS" 699 | "GLWTPL" 700 | "GPL-1.0" 701 | "GPL-1.0+" 702 | "GPL-1.0-only" 703 | "GPL-1.0-or-later" 704 | "GPL-2.0" 705 | "GPL-2.0+" 706 | "GPL-2.0-only" 707 | "GPL-2.0-or-later" 708 | "GPL-2.0-with-GCC-exception" 709 | "GPL-2.0-with-autoconf-exception" 710 | "GPL-2.0-with-bison-exception" 711 | "GPL-2.0-with-classpath-exception" 712 | "GPL-2.0-with-font-exception" 713 | "GPL-3.0" 714 | "GPL-3.0+" 715 | "GPL-3.0-only" 716 | "GPL-3.0-or-later" 717 | "GPL-3.0-with-GCC-exception" 718 | "GPL-3.0-with-autoconf-exception" 719 | "Giftware" 720 | "Glide" 721 | "Glulxe" 722 | "HPND" 723 | "HPND-sell-variant" 724 | "HTMLTIDY" 725 | "HaskellReport" 726 | "Hippocratic-2.1" 727 | "IBM-pibs" 728 | "ICU" 729 | "IJG" 730 | "IPA" 731 | "IPL-1.0" 732 | "ISC" 733 | "ImageMagick" 734 | "Imlib2" 735 | "Info-ZIP" 736 | "Intel" 737 | "Intel-ACPI" 738 | "Interbase-1.0" 739 | "JPNIC" 740 | "JSON" 741 | "JasPer-2.0" 742 | "LAL-1.2" 743 | "LAL-1.3" 744 | "LGPL-2.0" 745 | "LGPL-2.0+" 746 | "LGPL-2.0-only" 747 | "LGPL-2.0-or-later" 748 | "LGPL-2.1" 749 | "LGPL-2.1+" 750 | "LGPL-2.1-only" 751 | "LGPL-2.1-or-later" 752 | "LGPL-3.0" 753 | "LGPL-3.0+" 754 | "LGPL-3.0-only" 755 | "LGPL-3.0-or-later" 756 | "LGPLLR" 757 | "LPL-1.0" 758 | "LPL-1.02" 759 | "LPPL-1.0" 760 | "LPPL-1.1" 761 | "LPPL-1.2" 762 | "LPPL-1.3a" 763 | "LPPL-1.3c" 764 | "Latex2e" 765 | "Leptonica" 766 | "LiLiQ-P-1.1" 767 | "LiLiQ-R-1.1" 768 | "LiLiQ-Rplus-1.1" 769 | "Libpng" 770 | "Linux-OpenIB" 771 | "MIT" 772 | "MIT-0" 773 | "MIT-CMU" 774 | "MIT-Modern-Variant" 775 | "MIT-advertising" 776 | "MIT-enna" 777 | "MIT-feh" 778 | "MIT-open-group" 779 | "MITNFA" 780 | "MPL-1.0" 781 | "MPL-1.1" 782 | "MPL-2.0" 783 | "MPL-2.0-no-copyleft-exception" 784 | "MS-PL" 785 | "MS-RL" 786 | "MTLL" 787 | "MakeIndex" 788 | "MirOS" 789 | "Motosoto" 790 | "MulanPSL-1.0" 791 | "MulanPSL-2.0" 792 | "Multics" 793 | "Mup" 794 | "NAIST-2003" 795 | "NASA-1.3" 796 | "NBPL-1.0" 797 | "NCGL-UK-2.0" 798 | "NCSA" 799 | "NGPL" 800 | "NIST-PD" 801 | "NIST-PD-fallback" 802 | "NLOD-1.0" 803 | "NLOD-2.0" 804 | "NLPL" 805 | "NOSL" 806 | "NPL-1.0" 807 | "NPL-1.1" 808 | "NPOSL-3.0" 809 | "NRL" 810 | "NTP" 811 | "NTP-0" 812 | "Naumen" 813 | "Net-SNMP" 814 | "NetCDF" 815 | "Newsletr" 816 | "Nokia" 817 | "Noweb" 818 | "Nunit" 819 | "O-UDA-1.0" 820 | "OCCT-PL" 821 | "OCLC-2.0" 822 | "ODC-By-1.0" 823 | "ODbL-1.0" 824 | "OFL-1.0" 825 | "OFL-1.0-RFN" 826 | "OFL-1.0-no-RFN" 827 | "OFL-1.1" 828 | "OFL-1.1-RFN" 829 | "OFL-1.1-no-RFN" 830 | "OGC-1.0" 831 | "OGDL-Taiwan-1.0" 832 | "OGL-Canada-2.0" 833 | "OGL-UK-1.0" 834 | "OGL-UK-2.0" 835 | "OGL-UK-3.0" 836 | "OGTSL" 837 | "OLDAP-1.1" 838 | "OLDAP-1.2" 839 | "OLDAP-1.3" 840 | "OLDAP-1.4" 841 | "OLDAP-2.0" 842 | "OLDAP-2.0.1" 843 | "OLDAP-2.1" 844 | "OLDAP-2.2" 845 | "OLDAP-2.2.1" 846 | "OLDAP-2.2.2" 847 | "OLDAP-2.3" 848 | "OLDAP-2.4" 849 | "OLDAP-2.5" 850 | "OLDAP-2.6" 851 | "OLDAP-2.7" 852 | "OLDAP-2.8" 853 | "OML" 854 | "OPL-1.0" 855 | "OPUBL-1.0" 856 | "OSET-PL-2.1" 857 | "OSL-1.0" 858 | "OSL-1.1" 859 | "OSL-2.0" 860 | "OSL-2.1" 861 | "OSL-3.0" 862 | "OpenSSL" 863 | "PDDL-1.0" 864 | "PHP-3.0" 865 | "PHP-3.01" 866 | "PSF-2.0" 867 | "Parity-6.0.0" 868 | "Parity-7.0.0" 869 | "Plexus" 870 | "PolyForm-Noncommercial-1.0.0" 871 | "PolyForm-Small-Business-1.0.0" 872 | "PostgreSQL" 873 | "Python-2.0" 874 | "QPL-1.0" 875 | "Qhull" 876 | "RHeCos-1.1" 877 | "RPL-1.1" 878 | "RPL-1.5" 879 | "RPSL-1.0" 880 | "RSA-MD" 881 | "RSCPL" 882 | "Rdisc" 883 | "Ruby" 884 | "SAX-PD" 885 | "SCEA" 886 | "SGI-B-1.0" 887 | "SGI-B-1.1" 888 | "SGI-B-2.0" 889 | "SHL-0.5" 890 | "SHL-0.51" 891 | "SISSL" 892 | "SISSL-1.2" 893 | "SMLNJ" 894 | "SMPPL" 895 | "SNIA" 896 | "SPL-1.0" 897 | "SSH-OpenSSH" 898 | "SSH-short" 899 | "SSPL-1.0" 900 | "SWL" 901 | "Saxpath" 902 | "Sendmail" 903 | "Sendmail-8.23" 904 | "SimPL-2.0" 905 | "Sleepycat" 906 | "Spencer-86" 907 | "Spencer-94" 908 | "Spencer-99" 909 | "StandardML-NJ" 910 | "SugarCRM-1.1.3" 911 | "TAPR-OHL-1.0" 912 | "TCL" 913 | "TCP-wrappers" 914 | "TMate" 915 | "TORQUE-1.1" 916 | "TOSL" 917 | "TU-Berlin-1.0" 918 | "TU-Berlin-2.0" 919 | "UCL-1.0" 920 | "UPL-1.0" 921 | "Unicode-DFS-2015" 922 | "Unicode-DFS-2016" 923 | "Unicode-TOU" 924 | "Unlicense" 925 | "VOSTROM" 926 | "VSL-1.0" 927 | "Verbatim-man-pages" 928 | "Vim" 929 | "W3C" 930 | "W3C-19980720" 931 | "W3C-20150513" 932 | "WTFPL" 933 | "Watcom-1.0" 934 | "Wsuipa" 935 | "X11" 936 | "XFree86-1.1" 937 | "XSkat" 938 | "Xerox" 939 | "Xnet" 940 | "YPL-1.0" 941 | "YPL-1.1" 942 | "ZPL-1.1" 943 | "ZPL-2.0" 944 | "ZPL-2.1" 945 | "Zed" 946 | "Zend-2.0" 947 | "Zimbra-1.3" 948 | "Zimbra-1.4" 949 | "Zlib" 950 | "blessing" 951 | "bzip2-1.0.5" 952 | "bzip2-1.0.6" 953 | "copyleft-next-0.3.0" 954 | "copyleft-next-0.3.1" 955 | "curl" 956 | "diffmark" 957 | "dvipdfm" 958 | "eCos-2.0" 959 | "eGenix" 960 | "etalab-2.0" 961 | "gSOAP-1.3b" 962 | "gnuplot" 963 | "iMatix" 964 | "libpng-2.0" 965 | "libselinux-1.0" 966 | "libtiff" 967 | "mpich2" 968 | "psfrag" 969 | "psutils" 970 | "wxWindows" 971 | "xinetd" 972 | "xpp" 973 | "zlib-acknowledgement" 974 | )) 975 | 976 | (defcustom elx-license-substitutions nil 977 | "License substitutions performed `elx-license'. 978 | 979 | A list of the form ((NAME FOUND SUBSTITUTE)...). Each element 980 | is tried in order. If NAME is nil or the PACKAGE-NAME argument 981 | is NAME, and the license that would be returned is FOUND, then 982 | `elx-license' returns SUBSTITUTE instead." 983 | :group 'elx 984 | :type '(repeat (list (choice (string :tag "Package") 985 | (const :tag "All packages" nil)) 986 | (choice (string :tag "Replace license") 987 | (const :tag "No license")) 988 | (string :tag "Substitute")))) 989 | 990 | (defcustom elx-license-use-licensee t 991 | "Whether `elx-license' used the \"licensee\" executable." 992 | :group 'elx 993 | :type 'boolean) 994 | 995 | (defun elx-license (&optional file dir package-name) 996 | "Attempt to return the license used for the file FILE. 997 | Or the license used for the file that is being visited in the 998 | current buffer if FILE is nil. 999 | 1000 | *** A value is returned in the hope that it will be useful, but 1001 | *** WITHOUT ANY WARRANTY; without even the implied warranty of 1002 | *** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1003 | 1004 | The license is determined from the permission statement, if 1005 | any. Otherwise the value of the \"License\" header keyword 1006 | is considered. If a \"LICENSE\" file or similar exists in 1007 | the proximity of FILE then that is considered also, using 1008 | `licensee' (https://github.com/licensee/licensee), provided 1009 | `elx-license-use-licensee' is non-nil. 1010 | 1011 | `elx-license-substitutions' may affect the returned value. 1012 | 1013 | An effort is made to normalize the returned value." 1014 | (lm-with-file file 1015 | (let* ((case-fold-search t) 1016 | (license 1017 | (or (and (re-search-forward elx-gnu-permission-statement-regexp nil t) 1018 | (elx--format-license nil t)) 1019 | (and (re-search-forward elx-bsd-permission-statement-regexp nil t) 1020 | (format "BSD-%s-Clause" 1021 | (cond ((match-string 4) 4) 1022 | ((match-string 3) 3) 1023 | (t 2)))) 1024 | (and (re-search-forward elx-mit-permission-statement-regexp nil t) 1025 | (if (match-string 1) "X11" "MIT")) 1026 | (and (re-search-forward elx-isc-permission-statement-regexp nil t) 1027 | "ISC") 1028 | (and (re-search-forward elx-cc-permission-statement-regexp nil t) 1029 | (let ((license (match-string 1)) 1030 | (version (match-string 2))) 1031 | (format "CC-%s-%s" 1032 | (pcase license 1033 | ("Attribution" "BY") 1034 | ("Attribution-ShareAlike" "BY-SA") 1035 | ("Attribution-NonCommercial" "BY-NC") 1036 | ("Attribution-NoDerivs" "BY-ND") 1037 | ("Attribution-NonCommercial-ShareAlike" "BY-NC-SA") 1038 | ("Attribution-NonCommercial-NoDerivs" "BY-NC-ND")) 1039 | version))) 1040 | (and (re-search-forward elx-wtf-permission-statement-regexp nil t) 1041 | "WTFPL") 1042 | (elx--header-license nil elx-spdx-license-identifiers) 1043 | (elx--header-license elx-gnu-license-keyword-regexp nil t t) 1044 | (and elx-license-use-licensee 1045 | (elx-licensee dir)) 1046 | (car (cl-find-if (pcase-lambda (`(,_ . ,re)) 1047 | (re-search-forward re nil t)) 1048 | elx-gnu-non-standard-permission-statement-alist)) 1049 | (elx--header-license elx-gnu-license-keyword-regexp nil t) 1050 | (elx--header-license elx-non-gnu-license-keyword-regexp 1051 | elx-non-gnu-license-keyword-alist) 1052 | (car (cl-find-if (pcase-lambda (`(,_ . ,re)) 1053 | (re-search-forward re nil t)) 1054 | elx-permission-statement-alist))))) 1055 | (set-text-properties 0 (length license) nil license) 1056 | (or (cl-some (pcase-lambda (`(,pkg ,src ,dst)) 1057 | (and (or (not pkg) 1058 | (equal package-name pkg)) 1059 | (equal license src) 1060 | dst)) 1061 | elx-license-substitutions) 1062 | license)))) 1063 | 1064 | (defun elx--header-license (regexp &optional list-or-alist gnu-suffix-style gnu-require-spdx) 1065 | (let ((value (lm-header "\\(?:Licen[sc]e\\|SPDX-License-Identifier\\)"))) 1066 | (and value 1067 | (or (and list-or-alist 1068 | (if (atom (car list-or-alist)) 1069 | (car (member value list-or-alist)) 1070 | (car (cl-find-if (pcase-lambda (`(,_ . ,re)) 1071 | (string-match re value)) 1072 | list-or-alist)))) 1073 | (let ((value (and regexp 1074 | (string-match regexp value) 1075 | (elx--format-license value gnu-suffix-style)))) 1076 | (and value 1077 | (or (not gnu-require-spdx) 1078 | (string-match-p 1079 | (concat "\\`\\([AL]?GPL\\|FDL\\)" 1080 | "-[0-9]+\\.[0-9]+" 1081 | "-\\(only\\|or-later\\)\\'") 1082 | value)) 1083 | value)))))) 1084 | 1085 | (defun elx--format-license (value &optional gnu-suffix-style) 1086 | (let ((abbrev (match-string 1 value)) 1087 | (version (match-string 2 value)) 1088 | (later (or (match-string 3 value) 1089 | (match-string 5 value))) 1090 | (prefix (match-string 4 value))) 1091 | (concat 1092 | (if prefix 1093 | (cond ((equal prefix "zlib") "Zlib") 1094 | (t (upcase prefix))) 1095 | (pcase (and abbrev (downcase abbrev)) 1096 | ("lesser " "LGPL") 1097 | ("library " "LGPL") 1098 | ("affero " "AGPL") 1099 | ("free " "FDL") 1100 | (`nil "GPL"))) 1101 | (and version 1102 | (if (and gnu-suffix-style 1103 | (not (string-match-p 1104 | "\\`[0-9]+\\.[0-9]+\\'" 1105 | version))) 1106 | (concat "-" version ".0") 1107 | (concat "-" version))) 1108 | (and version 1109 | (if gnu-suffix-style 1110 | (if later "-or-later" "-only") 1111 | (and later "+")))))) 1112 | 1113 | (defun elx-licensee (&optional directory-or-file) 1114 | (save-match-data 1115 | (let* ((match 1116 | (with-temp-buffer 1117 | (save-excursion 1118 | (call-process "licensee" nil '(t nil) nil "detect" "--json" 1119 | (or directory-or-file default-directory))) 1120 | (car (cl-sort 1121 | (cdr (assq 'matched_files 1122 | (let ((json-object-type 'alist) 1123 | (json-array-type 'list) 1124 | (json-key-type 'symbol) 1125 | (json-false nil) 1126 | (json-null nil)) 1127 | (condition-case nil (json-read) 1128 | (error (error "`licensee' failed: %S" 1129 | (buffer-string))))))) 1130 | #'> 1131 | :key (##or (let-alist % .matcher.confidence) 0))))) 1132 | (license (cdr (assq 'matched_license match)))) 1133 | (pcase license 1134 | ('nil nil) 1135 | ("" nil) ; haven't seen this lately 1136 | ("NONE" nil) ; unable to detect a license 1137 | ("NOASSERTION" nil) ; almost able to detect a licence 1138 | ("ISC License" "ISC") 1139 | ((guard (string-match-p "\\`\\([AL]?GPL\\|FDL\\)-[0-9]+\\.[0-9]+\\'" 1140 | license)) 1141 | (concat license "-only")) 1142 | (_ license))))) 1143 | 1144 | ;;; Extract Dates 1145 | 1146 | (defun elx-created (&optional file) 1147 | "Return the created date given in file FILE. 1148 | Or of the current buffer if FILE is equal to `buffer-file-name' 1149 | or is nil. The date is returned as YYYYMMDD or if not enough 1150 | information is available YYYYMM or YYYY. The date is taken from 1151 | the \"Created\" header keyword, or if that doesn't work from the 1152 | copyright line." 1153 | (lm-with-file file 1154 | (or (elx--date-1 (lm-creation-date)) 1155 | (elx--date-1 (elx--date-copyright))))) 1156 | 1157 | (defun elx-updated (&optional file) 1158 | "Return the updated date given in file FILE. 1159 | Or of the current buffer if FILE is equal to `buffer-file-name' 1160 | or is nil. The date is returned as YYYYMMDD or if not enough 1161 | information is available YYYYMM or YYYY. The date is taken from 1162 | the \"Updated\" or \"Last-Updated\" header keyword." 1163 | (lm-with-file file 1164 | (elx--date-1 (lm-header "\\(last-\\)?updated")))) 1165 | 1166 | ;; Yes, I know. 1167 | (defun elx--date-1 (string) 1168 | (and (stringp string) 1169 | (let ((ymd "\ 1170 | \\([0-9]\\{4,4\\}\\)\\(?:[-/.]?\ 1171 | \\([0-9]\\{1,2\\}\\)\\(?:[-/.]?\ 1172 | \\([0-9]\\{1,2\\}\\)?\\)?\\)") 1173 | (dmy "\ 1174 | \\(?3:[0-9]\\{1,2\\}\\)\\(?:[-/.]?\\)\ 1175 | \\(?2:[0-9]\\{1,2\\}\\)\\(?:[-/.]?\\)\ 1176 | \\(?1:[0-9]\\{4,4\\}\\)")) 1177 | (or (elx--date-2 string ymd t) 1178 | (elx--date-2 string dmy t) 1179 | (let ((a (elx--date-3 string)) 1180 | (b (or (elx--date-2 string ymd nil) 1181 | (elx--date-2 string dmy nil)))) 1182 | (cond ((not a) b) 1183 | ((not b) a) 1184 | ((length> a (length b)) a) 1185 | ((length> b (length a)) b) 1186 | (t a))))))) 1187 | 1188 | (defun elx--date-2 (string regexp anchored) 1189 | (and (string-match (if anchored (format "^%s$" regexp) regexp) string) 1190 | (let ((m (match-string 2 string)) 1191 | (d (match-string 3 string))) 1192 | (concat (match-string 1 string) 1193 | (and m d (concat (if (length= m 2) m (concat "0" m)) 1194 | (if (length= d 2) d (concat "0" d)))))))) 1195 | 1196 | (defun elx--date-3 (string) 1197 | (let ((time (mapcar (##or % 0) 1198 | (butlast (ignore-errors (parse-time-string string)))))) 1199 | (and time 1200 | (not (= (nth 5 time) 0)) 1201 | (format-time-string (if (and (> (nth 4 time) 0) 1202 | (> (nth 3 time) 0)) 1203 | "%Y%m%d" 1204 | ;; (format-time-string 1205 | ;; "%Y" (encode-time x x x 0 0 2012)) 1206 | ;; => "2011" 1207 | (setcar (nthcdr 3 time) 1) 1208 | (setcar (nthcdr 4 time) 1) 1209 | "%Y") 1210 | (apply 'encode-time time) 1211 | t)))) 1212 | 1213 | ;; FIXME implement range extraction in lm-crack-copyright 1214 | (defun elx--date-copyright () 1215 | (let ((lm-copyright-prefix "^\\(;+[ \t]\\)+Copyright \\((C) \\)?")) 1216 | (when (lm-copyright-mark) 1217 | (cadr (lm-crack-copyright))))) 1218 | 1219 | ;;; Extract People 1220 | 1221 | (defcustom elx-remap-names nil 1222 | "List of names that should be replaced or dropped by `elx-crack-address'. 1223 | If function `elx-crack-address' is called with a non-nil SANITIZE argument 1224 | it checks this variable to determine if names should be dropped from the 1225 | return value or replaced by another. If the cdr of an entry is nil then 1226 | the keyword is dropped; otherwise it will be replaced with the keyword in 1227 | the cadr." 1228 | :group 'elx 1229 | :type '(repeat (list string (choice (const :tag "drop" nil) 1230 | (string :tag "replacement"))))) 1231 | 1232 | ;; Yes, I know. 1233 | (defun elx-crack-address (x) 1234 | "Split up an email address X into full name and real email address. 1235 | The value is a cons of the form (FULLNAME . ADDRESS)." 1236 | (let (name mail) 1237 | (cond ((string-match (concat "\\(.+\\) " 1238 | "?[(<]\\(\\S-+@\\S-+\\)[>)]") x) 1239 | (setq name (match-string 1 x)) 1240 | (setq mail (match-string 2 x))) 1241 | ((string-match (concat "\\(.+\\) " 1242 | "[(<]\\(?:\\(\\S-+\\) " 1243 | "\\(?:\\*?\\(?:AT\\|[.*]\\)\\*?\\) " 1244 | "\\(\\S-+\\) " 1245 | "\\(?:\\*?\\(?:DOT\\|[.*]\\)\\*? \\)?" 1246 | "\\(\\S-+\\)\\)[>)]") x) 1247 | (setq name (match-string 1 x)) 1248 | (setq mail (concat (match-string 2 x) "@" 1249 | (match-string 3 x) "." 1250 | (match-string 4 x)))) 1251 | ((string-match (concat "\\(.+\\) " 1252 | "[(<]\\(?:\\(\\S-+\\) " 1253 | "\\(?:\\*?\\(?:AT\\|[.*]\\)\\*?\\) " 1254 | "\\(\\S-+\\)[>)]\\)") x) 1255 | (setq name (match-string 1 x)) 1256 | (setq mail (concat (match-string 2 x) "@" 1257 | (match-string 3 x)))) 1258 | ((string-match "\\`\\([^(]+\\) +(concat +\\([^)]+\\))\\'" x) 1259 | (setq name (match-string 1 x)) 1260 | (when-let* 1261 | ((parts (match-string 2 x)) 1262 | (parts (split-string parts " " t)) 1263 | ((seq-every-p (##string-match-p "\\`\".+\"\\'" %) parts))) 1264 | (setq mail (mapconcat (##substring % 1 -1) parts "")))) 1265 | ((string-match (concat "\\(\\S-+@\\S-+\\) " 1266 | "[(<]\\(.*\\)[>)]") x) 1267 | (setq name (match-string 2 x)) 1268 | (setq mail (match-string 1 x))) 1269 | ((string-match "\\S-+@\\S-+" x) 1270 | (setq mail x)) 1271 | (t 1272 | (setq name x))) 1273 | (setq name (and (stringp name) 1274 | (string-match "^ *\\([^:0-9<@>]+?\\) *$" name) 1275 | (match-string 1 name))) 1276 | (setq mail (and (stringp mail) 1277 | (string-match 1278 | (concat "^\\s-*\\(" 1279 | "[a-z0-9!#$%&'*+/=?^_`{|}~-]+" 1280 | "\\(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+\\)*@" 1281 | "\\(?:[a-z0-9]\\(?:[a-z0-9-]*[a-z0-9]\\)?\.\\)+" 1282 | "[a-z0-9]\\(?:[a-z0-9-]*[a-z0-9]\\)?" 1283 | "\\)\\s-*$") mail) 1284 | (downcase (match-string 1 mail)))) 1285 | (when-let ((elt (assoc name elx-remap-names))) 1286 | (setq name (cadr elt))) 1287 | (and (or name mail) 1288 | (cons name mail)))) 1289 | 1290 | (defun elx-people (header file) 1291 | (lm-with-file file 1292 | (seq-keep #'elx-crack-address 1293 | (mapcan (##split-string % ", *" t "[\s\t]") 1294 | (lm-header-multiline header))))) 1295 | 1296 | (defun elx-authors (&optional file) 1297 | "Return the author list of file FILE. 1298 | Or of the current buffer if FILE is equal to `buffer-file-name' 1299 | or is nil. Each element of the list is a cons; the car is the 1300 | full name, the cdr is an email address." 1301 | (elx-people "authors?" file)) 1302 | 1303 | (defun elx-maintainers (&optional file) 1304 | "Return the maintainer list of file FILE. 1305 | Or of the current buffer if FILE is equal to `buffer-file-name' 1306 | or is nil. Each element of the list is a cons; the car is the 1307 | full name, the cdr is an email address. If there is no 1308 | maintainer list then return the author list." 1309 | (or (elx-people "maintainers?" file) 1310 | (elx-authors file))) 1311 | 1312 | (defun elx-adapted-by (&optional file) 1313 | "Return the list of people who have adapted file FILE. 1314 | Or of the current buffer if FILE is equal to `buffer-file-name' 1315 | or is nil. Each element of the list is a cons; the car is the 1316 | full name, the cdr is an email address." 1317 | (elx-people "adapted-by" file)) 1318 | 1319 | ;;; Extract Features 1320 | 1321 | (defconst elx-provided-regexp "\ 1322 | \(\\(?:cc-\\|silentcomp-\\)?provide[\s\t\n]+'\ 1323 | \\([^(),\s\t\n]+\\)\\(?:[\s\t\n]+'\ 1324 | \(\\([^(),]+\\))\\)?)") 1325 | 1326 | (defun elx-provided () 1327 | (let (features) 1328 | (save-excursion 1329 | (goto-char (point-min)) 1330 | (while (re-search-forward elx-provided-regexp nil t) 1331 | (unless (save-match-data 1332 | (or (nth 3 (syntax-ppss)) ; in string 1333 | (nth 4 (syntax-ppss)))) ; in comment 1334 | (dolist (feature (cons (match-string 1) 1335 | (let ((f (match-string 2))) 1336 | (and f (split-string f " " t))))) 1337 | (push (intern feature) features))))) 1338 | (or features 1339 | (and (goto-char (point-min)) 1340 | (re-search-forward 1341 | "^(provide-theme[\s\t\n]+'\\([^)]+\\))" nil t) 1342 | (list (intern (concat (match-string 1) 1343 | "-theme")))) 1344 | (and (goto-char (point-min)) 1345 | (re-search-forward 1346 | "^(provide-me\\(?:[\s\t\n]+\"\\(.+\\)\"\\)?)" nil t) 1347 | (list 1348 | (intern (concat (match-string 1) 1349 | (elx--base-library-name buffer-file-name)))))))) 1350 | 1351 | (defun elx-library-feature (file) 1352 | "Return the first valid feature actually provided by FILE. 1353 | 1354 | Here valid means that requiring that feature would actually load FILE. 1355 | Normally that is the case when the feature matches the filename, e.g. 1356 | when \"foo.el\" provides `foo'. But if \"foo.el\"s parent directory's 1357 | filename is \"bar\" then `bar/foo' would also be valid. Of course this 1358 | depends on the actual value of `load-path', here we just assume that it 1359 | allows for file to be found. 1360 | 1361 | This can be used to determine if an Emacs lisp file should be considered 1362 | a library. Not every Emacs lisp file has to provide a feature / be a 1363 | library. If a file lacks an expected feature then loading it using 1364 | `require' still succeeds but causes an error." 1365 | (let* ((file (expand-file-name file)) 1366 | (sans (elx--library-sans-extensions file)) 1367 | (last (file-name-nondirectory sans))) 1368 | (cl-find-if (lambda (feature) 1369 | (setq feature (symbol-name feature)) 1370 | (or (equal feature last) 1371 | (string-suffix-p (concat "/" feature) sans))) 1372 | (save-match-data 1373 | (if (and file (not (equal file buffer-file-name))) 1374 | (with-temp-buffer 1375 | (insert-file-contents file) 1376 | (setq buffer-file-name file) 1377 | (set-buffer-modified-p nil) 1378 | (with-syntax-table emacs-lisp-mode-syntax-table 1379 | (elx-provided))) 1380 | (save-excursion 1381 | (goto-char (point-min)) 1382 | (with-syntax-table emacs-lisp-mode-syntax-table 1383 | (elx-provided)))))))) 1384 | 1385 | (defconst elx-required-regexp "\ 1386 | \(\\(?:cc-\\)?require[\s\t\n]+'\ 1387 | \\([^(),\s\t\n\"]+\\)\ 1388 | \\(?:\\(?:[\s\t\n]+\\(?:nil\\|\"[^\"]*\"\\)\\)\ 1389 | \\(?:[\s\t\n]+\\(?:nil\\|\\(t\\)\\)\\)?\\)?)") 1390 | 1391 | (defun elx-required () 1392 | (let (hard soft) 1393 | (save-excursion 1394 | (goto-char (point-min)) 1395 | (while (re-search-forward elx-required-regexp nil t) 1396 | (let ((feature (intern (match-string 1)))) 1397 | (cond ((save-match-data 1398 | (or (nth 3 (syntax-ppss)) ; in string 1399 | (nth 4 (syntax-ppss))))) ; in comment 1400 | ((match-string 2) 1401 | (push feature soft)) 1402 | (t 1403 | (push feature hard)))))) 1404 | (list hard soft))) 1405 | 1406 | ;;; List Files 1407 | 1408 | (defun elx--byte-compile-source-p (file) 1409 | (string-match-p 1410 | (concat (regexp-opt (seq-filter (lambda (s) 1411 | (and (not (equal s ".elc")) 1412 | (string-prefix-p ".el" s))) 1413 | load-suffixes)) 1414 | (regexp-opt load-file-rep-suffixes) 1415 | "\\'") 1416 | file)) 1417 | 1418 | (defun elx--library-sans-extensions (file) 1419 | (let ((file (byte-compiler-base-file-name file))) 1420 | (and (string-match (concat (regexp-opt load-suffixes) "\\'") file) 1421 | (substring file 0 (match-beginning 0))))) 1422 | 1423 | (defun elx--base-library-name (file) 1424 | (elx--library-sans-extensions (file-name-nondirectory file))) 1425 | 1426 | (defun elx--ignore-directory-p (directory) 1427 | (let ((name (file-name-nondirectory (directory-file-name directory)))) 1428 | (or (string-prefix-p "." name) 1429 | (string-prefix-p "test" name) 1430 | (string-suffix-p "-test" name) 1431 | (string-suffix-p "-tests" name) 1432 | (file-exists-p (expand-file-name ".nosearch" directory))))) 1433 | 1434 | ;;;###autoload 1435 | (defun elx-library-p (file) 1436 | "Return non-nil if FILE is an Emacs source library. 1437 | Actually return the feature provided by FILE. 1438 | 1439 | An Emacs Lisp file is considered to be a library if it provides 1440 | the correct feature; that is a feature that matches its filename 1441 | \(and possibly parts of the path leading to it)." 1442 | (and (let ((filename (file-name-nondirectory file))) 1443 | (save-match-data 1444 | (and (elx--byte-compile-source-p file) 1445 | (not (or (file-symlink-p file) 1446 | (string-equal filename dir-locals-file) 1447 | (auto-save-file-name-p filename)))))) 1448 | (elx-library-feature file))) 1449 | 1450 | (defun elx-libraries (directory &optional full nonrecursive) 1451 | "Return a list of libraries that are part of PACKAGE located in DIRECTORY. 1452 | DIRECTORY is assumed to contain the libraries belonging to a 1453 | single package. 1454 | 1455 | If optional FULL is non-nil return absolute paths otherwise paths 1456 | relative to DIRECTORY. 1457 | 1458 | If optional NONRECURSIVE only return libraries directly located 1459 | in DIRECTORY." 1460 | (mapcan (pcase-lambda (`(,library . ,feature)) 1461 | (and feature 1462 | (list (if full 1463 | library 1464 | (file-relative-name library directory))))) 1465 | (elx-libraries-1 directory nonrecursive))) 1466 | 1467 | (defun elx-libraries-1 (directory &optional nonrecursive) 1468 | "Return a list of Emacs Lisp files DIRECTORY and its subdirectories. 1469 | 1470 | The return value has the form ((LIBRARY . FEATURE)...). FEATURE 1471 | is nil if LIBRARY does not provide a feature or only features 1472 | that don't match the filename." 1473 | (let (libraries) 1474 | (dolist (f (directory-files directory t "^[^.]")) 1475 | (cond ((file-directory-p f) 1476 | (or nonrecursive 1477 | (elx--ignore-directory-p f) 1478 | (setq libraries (nconc (elx-libraries-1 f) libraries)))) 1479 | ((elx--byte-compile-source-p f) 1480 | (push (cons f (elx-library-p f)) libraries)))) 1481 | (nreverse libraries))) 1482 | 1483 | (defun elx-main-library (directory &optional package noerror nosingle) 1484 | "Return the main library from the package directory DIRECTORY. 1485 | Optional PACKAGE is the name of the package; if it is nil the 1486 | basename of DIRECTORY is used as the package name. 1487 | 1488 | Return the library whose basename matches the package name. If 1489 | that fails append \"-mode\" to the package name, respectively 1490 | remove that substring, and try again. 1491 | 1492 | The library must provide the correct feature; that is the feature 1493 | which matches the filename (and possibly parts of the path leading 1494 | to it). 1495 | 1496 | Unless optional NOSINGLE is non-nil and if there is only a single 1497 | Emacs lisp file return that even if it doesn't match the package 1498 | name. 1499 | 1500 | If the main library cannot be found raise an error or if optional 1501 | NOERROR is non-nil return nil." 1502 | (elx-main-library-1 1503 | (or package (file-name-nondirectory (directory-file-name directory))) 1504 | (elx-libraries-1 directory) 1505 | noerror nosingle)) 1506 | 1507 | (defun elx-main-library-1 (package libraries &optional noerror nosingle) 1508 | "Return the main library among LIBRARIES of the package PACKAGE. 1509 | PACKAGE is a package name, a string. LIBRARIES is a list of full 1510 | library filenames or an alist as returned by `elx-libraries-1'. 1511 | In the latter case also ensure that the main library provides the 1512 | correct feature. 1513 | 1514 | Return the library whose basename matches the package name. If 1515 | that fails append \"-mode\" to the package name, respectively 1516 | remove that substring, and try again. 1517 | 1518 | Unless optional NOSINGLE is non-nil and if there is only a single 1519 | Emacs lisp file return that even if it doesn't match the package 1520 | name. 1521 | 1522 | If no library matches raise an error or if optional NOERROR is 1523 | non-nil return nil." 1524 | (let ((match 1525 | (cond ((and (not nosingle) 1526 | (not (cdr libraries))) 1527 | (car libraries)) 1528 | ((elx-main-library-2 package libraries)) 1529 | ((elx-main-library-2 1530 | (if (string-suffix-p "-mode" package) 1531 | (substring package 0 -5) 1532 | (concat package "-mode")) 1533 | libraries))))) 1534 | (cond ((and (not match) 1535 | (not noerror)) 1536 | (error "Cannot determine main library of %s" package)) 1537 | ((atom match) 1538 | match) 1539 | ((cdr match) 1540 | (car match)) 1541 | ((not noerror) 1542 | (error "Main library %s provides no or wrong feature" 1543 | (car match)))))) 1544 | 1545 | (defun elx-main-library-2 (package libraries) 1546 | (cl-find-if (##equal (elx--base-library-name (if (consp %) (car %) %)) 1547 | package) 1548 | libraries)) 1549 | 1550 | ;;; Utilities 1551 | 1552 | (defun elx--header-multiline (header &optional extra) 1553 | "Return the contents of the header named HEADER, with continuation lines. 1554 | The returned value is a list of strings, one per line. 1555 | 1556 | If optional EXTRA is non-nil, then return (LINES BEG END INDENT), 1557 | where INDENT is either nil, if the value was specified on a 1558 | single line, or the prefix used on continuation lines." 1559 | (save-excursion 1560 | (goto-char (point-min)) 1561 | (let ((lines (lm-header header)) 1562 | (beg (line-beginning-position)) 1563 | (end (1+ (line-end-position))) 1564 | (indent nil)) 1565 | (when lines 1566 | (setq lines (list lines)) 1567 | (forward-line 1) 1568 | (while (looking-at "^;+\\(\t\\|[\t\s]\\{2,\\}\\)\\(.+\\)") 1569 | (push (match-string-no-properties 2) lines) 1570 | (unless indent 1571 | (setq indent (match-string-no-properties 1))) 1572 | (forward-line 1) 1573 | (setq end (point))) 1574 | (setq lines (nreverse lines)) 1575 | (if extra (list lines beg end indent) lines))))) 1576 | 1577 | ;;; _ 1578 | (provide 'elx) 1579 | ;; Local Variables: 1580 | ;; indent-tabs-mode: nil 1581 | ;; End: 1582 | ;;; elx.el ends here 1583 | --------------------------------------------------------------------------------