[
  {
    "path": "LICENSE.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# Plain Text Agenda\n\nThe plain text agenda format is very strongly inspired by the\ncalendar.txt idea by [Tero Karvinen](https://terokarvinen.com/2021/calendar-txt/).\nThe major difference is that there is a single event per line and a formal syntax:\n\n```\n# Header (not parsed)                                                    # Header \nYYYY-MM-DD wNN Day HH:MM-HH:MM Summary @ACTIONS... +TAGS... [REFERENCE]  # Entry\n[REFERENCE:KEY]: Content                                                 # Metadata\n```\n\nOnly the ISO date `YYYY-MM-DD` is mandatory. All other fields\nare optional (but order is strict).\n\n## Examples\n\n```markdown\n\n# Meetings\n2026-01-27 w05 Tue 11:00-12:00 Team meeting @MEET +WORK\n2026-01-27 w05 Tue 12:00-13:00 Lunch break @LUNCH +HOME\n2026-01-27 w05 Tue 15:00-16:00 Project @MEET +WORK [20260127T1500]\n2026-01-28 This is a valid entry\n\n# Medatata\n[20260127T1500:URL]: Some URL\n[20260127T1500:NOTE]: Some Notes\n```\n\nThis is both human-readable and easy to parse by any program,\nincluding Emacs and standard CLI tools. Here are some examples in\nBash:\n\n- **Today agenda:** ``` grep `date +\"%Y-%m-%d\"` agenda.txt ```\n- **Week agenda:**  ``` grep `date +\"^%Y\"` agenda.txt \\| grep `date +\"w%V\"` ```\n\nThere is also a more elaborate example [agenda.sh](./agenda.sh) that\ndisplay formatted agenda for the current week.\n\n<details>\n<summary><b>Show weekly agenda output</b></summary>\n\n```markdown\n# Monday 02 February 2026\n\n   11:00-12:00  🎓 Yousra @MEET +PHD\n   12:00-13:00  Neurosync @MEET +NEUROSYNC +EUROPE +INRIA\n   14:00-15:00  🎓 Maeva @MEET +PHD +CANCEL\n   15:00-16:00  Roshni @MEET\n\n# Tuesday 03 February 2026 (today)\n\n   10:00-11:00  Team (adm) @MEET +INRIA\n   11:00-12:00  Team (sci) @MEET +INRIA\n   15:00-16:00  🎓 Maeva @MEET +PHD\n   15:30-17:30  OSD (dictionary) @MEET +OSD\n\n# Wednesday 04 February 2026\n\n   10:00-11:00  C.Dupaix @MEET +INRIA +COSO\n   14:00-15:00  Vispy @MEET +VISPY\n\n# Thursday 05 February 2026\n\n   18:30-21:00  OSD Party @MEET +OSD\n\n# Friday 06 February 2026\n\n   13:30-14:30  Srini Chakravarthy @MEET +INDIA +ANR +UB\n   18:00-22:00  🎤 IA/Droit pénal @TALK +OSD\n```\n\n</details>\n\nIt is probably possible to have even fancier renderings using bash but\nI concentrated my efforts on Emacs.\n\n## Roadmap\n\nThe agenda is pretty usable but it is still **work in\nprogress**. Syntax should not changed much but may be nonetheless\nmodified if bugs or incompatibilities are found. There a few missing\nthings that are planned:\n\n- [x] Documentation\n- [x] Export (ical format)\n- [ ] Reorganize faces\n- [ ] Handle multiple agenda files\n- [ ] Automated git support\n- [ ] Better handling of TODO/DONE\n- [ ] A set of bash view commands\n\n## Limitations\n\nThe agenda is not meant to replace Emacs\n[org-agenda](https://orgmode.org/manual/Agenda-Views.html) which is\nmuch more powerful (by far). The proposed format probably offers\nless than 1% of org-agenda features: choice is yours.\nAmong the known limitations:\n\n- No specific syntax for repeated entries (they have to be created explicitly).\n- Limited metadata using the reference mechanisms\n- No record of creation date (but you can use git for that)\n- No active/inactive status (only the +CANCEL keyword is considered)\n- No integration with org (but also no org dependencies)\n\nAnd probably many others that I forgot to mention.\n\n# Installation\n\n# Usage\n\nThe package provides two modes:\n- A minor [edit mode](#edit-mode) to edit the source file\n- A major [view mode](#view-mode) to display the agenda.\n\n## Edit mode\n\n| Command | Key Binding | Description |\n| :--- | :--- | :--- |\n| **Adjust Date/Time (Forward)** | `S-up` | Increment the value under point<br>(year, month, day, hour or minute). |\n| **Adjust Date/Time (Backward)** | `S-down` | Decrement the value under point<br>(year, month, week, day, hour or minute). |\n| **Adjust Date/Time (Forward)** | `S-right` | Increment date under point by one day<br> or time under point by one hour. |\n| **Adjust Date/Time (Backward)** | `S-left` | Decrement date under point by one day<br> or time under point by one hour. |\n| **Go to Date** | `C-c g` | Jumps to a specific date prompted via calendar. |\n| **Insert Entry** | `C-c i` | Prompt for a date and insert a new entry at relevant place.<br> When prefixed with `C-u`, insert entry at point. |\n| **Set Entry Data** | `C-c d` | Opens a prompt to set/modify metadata.<br> When prefixed with `C-u` prompt for UID. |\n| **Repeat Entry** | `C-c r` | Prompt for a frequency and count to repeat entry at point. |\n| **Filter Agenda** | `C-c f` | Prompt for a filter to restrict view (`C-l` to clear). |\n| **Cleanup** | `C-l` | Clear caches and reparse buffer. |\n| **Cycle Outline** | `TAB` | Toggles folding of current header. |\n| **Cycle All** | `S-TAB` | Global floding cycle. |\n| **Agenda View** | `C-c a` | Switches to agenda view . |\n\nHere is a view of my current agenda:\n![Edit mode](./screenshots/agenda-edit.png)\n\n\n## View mode\n\nThe view mode allows to display the agenda organized by day, week,\nmonth, 3 months (trimester) or year. Each view has a dedicated display\nthat is supposed to ease reading (see screenshots below). All views\nshare the same key bindings but action may depends on the view. When\nan entry is displayed and there is URL metadata attachd, entry can be\nclicked.\n\n| Command | Key Binding | Description |\n| :--- | :--- | :--- |\n| **Unit Forward**   | `f` or `n` | Forward current date by one unit (d,w,m,3m or y). |\n| **Unit Backward**  | `b` or `p` | Backward current date by one unit (d,w,m,3m or y). |\n| **Month Forward**  | `S-right`  | Forward current date by one month. |\n| **Month Backward** | `S-left`   | Backward current date by one month. |\n| **3 Months Forward** | `S-down` | Forward current date by 3 months (year view). |\n| **3 Months Backward** | `S-up`  | Backward current date by 3 months (year view). |\n| **Goto entry**     | `TAB` or `RET` | Go to entry at point. | \n| **Capture**        | `c`        | Capture a new entry using date at point (if any). | \n| **Refresh**        | `r`        | Refresh view (reparse). | \n| **Day mode**       | `d`        | Switch to day mode. | \n| **Week mode**      | `w`        | Switch to week mode. | \n| **Month mode**     | `m`        | Switch to month mode. | \n| **3 Months mode**  | `t`        | Switch to 3 months (trimester) mode. | \n| **Year mode**      | `y`        | Switch to year mode. | \n| **Goto date**      | `g`        | Prompt for date and goto to selected date. |\n| **Goto today**     | `.`        | Go to today. | \n\n### Day mode\n\nA summary message of the day is displayed at the bottom when moving to\na new date.\n\n![View mode (day)](./screenshots/agenda-day-view.png)\n\n### Week mode\n![View mode (day)](./screenshots/agenda-week-view.png)\n\n### Month mode\n\nIn month mode, the current week is displayed using default faces, other\nweeks are displayed using shadow face.\n\n![View mode (day)](./screenshots/agenda-month-1-view.png)\n\n### 3 months mode\n\nIn month mode, the current week is displayed using default faces, other\nweeks are displayed using shadow face.\n\n![View mode (day)](./screenshots/agenda-month-3-view.png)\n\n### Year mode\n\nIn month mode, the selected month is displayed using default faces,\nother months are displayed using shadow face. A summary message of the\nday is displayed at the bottom when moving to a new date.\n\n![View mode (day)](./screenshots/agenda-year-view.png)\n\n\n## Export\n\nIt is possible to export the whole agenda to ical format in two files:\na private file where entries have all the details and a public file\nwhere title / tags / actions are simply replaced by \"(busy)\" or\n\"(away)\" when there is \"MAP\" data attached. The public file can be used to indicate people when you're available without giving details. Synchronization is made using [vdirsyncer](https://github.com/pimutils/vdirsyncer) that you need to have configured.\n\n## Capture\n\nCapture is very simple since an entry is exactly one line and can be\ndirectly prompted in the minibuffer. Date and time can be prefilled\nusing a provided date or prompted using calendar. When prefixed with\n`C-u`, data can be set for the new entry.\n\nThe new entry is inserted at the nearest date inside the agenda file\n(starting from end).\n\n\n"
  },
  {
    "path": "agenda-capture.el",
    "content": ";;; agenda-capture.el --- Capture framework -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(defvar agenda-quick-capture-map\n  (let ((map (make-sparse-keymap)))\n    (set-keymap-parent map minibuffer-local-map)\n    (define-key map (kbd \"S-<up>\")    #'agenda-shift-up)\n    (define-key map (kbd \"S-<down>\")  #'agenda-shift-down)\n    (define-key map (kbd \"S-<left>\")  #'agenda-shift-left)\n    (define-key map (kbd \"S-<right>\") #'agenda-shift-right)\n    map)\n\"Keymap for capture in minibuffer.\")\n\n;;;###autoload\n(defun agenda-capture-with-calendar (&optional with-data)\n  \"Open a calendar to choose a date then pre-fill an entry with selected date.\nIf WITH-DATA is non-nil (C-u), also prompt for additional data.\n\nUse arrow keys to shift year/month/day/hour/minute based on \ncursor position in the minibuffer.\"\n  (interactive \"P\")\n  (agenda-with-calendar-select date\n    (agenda-capture date with-data)))\n\n;;;###autoload\n(defun agenda-capture (&optional date with-data)\n  \"Prompt for an entry pre-filled with DATE (month day year) or current\ndate and current time. If WITH-DATA is non-nil (C-u), also prompt for\nadditional data.\n\nUse arrow keys to shift year/month/day/hour/minute based on \ncursor position in the minibuffer.\"\n  (interactive \"P\")\n  (let* ((timestamp (if date\n                        (encode-time (list 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))\n                      (current-time)))\n         (hour (string-to-number (format-time-string \"%H\")))\n         (initial (concat (format-time-string \"%Y-%m-%d w%V %a\" timestamp)\n                          \"  \" (format \"%02d:00\" hour)\n                          \"-\"  (format \"%02d:00  \" (min (1+ hour) 24))))\n         (minibuffer-prompt-properties '(cursor-intangible t read-only t))\n         (prompt (concat\n                  (propertize \"Agenda capture\"\n                              'face '(:inherit (link bold)))\n                  (propertize \"\\n\" 'face 'default\n                                   'display (format \"\\n%s \" (agenda-mark 'capture)))))\n         \n         (entry (read-from-minibuffer prompt initial agenda-quick-capture-map)))\n    (unless (and agenda-file (file-exists-p agenda-file))\n      (error \"Agenda file not found: %s. \" agenda-file))\n    (if (string-match agenda-entry-re entry)\n        (let* ((year  (string-to-number (car (agenda-match 'date-y entry))))\n               (month (string-to-number (car (agenda-match 'date-m entry))))\n               (day   (string-to-number (car (agenda-match 'date-d entry))))\n               (source-buffer (find-file-noselect agenda-file)))\n          (with-current-buffer source-buffer\n            (agenda--goto-date (list month day year))\n            (end-of-line)\n            (unless (= (line-beginning-position) (line-end-position))\n              (insert \"\\n\"))\n              (insert entry)\n              (when with-data\n                (let ((current-prefix-arg nil))\n                  (call-interactively #'agenda-entry-set-data)))\n              (message (concat (propertize \"Entry captured \" 'face 'bold)\n                               (format \"(%s)\" entry)))\n              (agenda-highlight (line-beginning-position)\n                                (line-end-position))))\n      (message \"Entry format not recognized!\"))))\n\n(provide 'agenda-capture)\n;;; agenda-capture.el ends here\n"
  },
  {
    "path": "agenda-edit.el",
    "content": ";;; agenda-edit.el --- Agenda edit mode -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'agenda-parse)\n(require 'agenda-faces)\n\n(defun agenda-highlight (beg end)\n  \"Move the highlight overlay to cover BEG to END.\"\n  (unless agenda--highlight-overlay\n    (setq agenda--highlight-overlay (make-overlay (point) (point)))\n    (overlay-put agenda--highlight-overlay 'face 'agenda-edit-highlight))\n  (move-overlay agenda--highlight-overlay beg end)\n  (add-hook 'pre-command-hook #'agenda-highlight-clear nil t))\n\n(defun agenda-highlight-clear ()\n  \"Clear highlight only if the last event was a keyboard event.\"\n  (let ((event last-command-event))\n    (unless (or (listp event)\n                (memq event '(wheel-up wheel-down\n                              mouse-wheel-up-event \n                              mouse-wheel-down-event)))\n      (when agenda--highlight-overlay\n        (move-overlay agenda--highlight-overlay (point) (point)))\n      (remove-hook 'pre-command-hook #'agenda-highlight-clear t))))\n\n(defun agenda-mark (what)\n  \"Return mark associated with WHAT\"\n  (cdr (assoc what agenda-marks)))\n\n(defun agenda--set-mark (char &optional face)\n  \"Add CHAR in the left margin using FACE.\"\n  (remove-overlays (line-beginning-position) (line-end-position))\n  (let* ((start (line-beginning-position))\n         (overlay (make-overlay start start nil nil t)))\n    (overlay-put overlay 'agenda-mark t)\n    (overlay-put overlay 'before-string \n                 (propertize \" \" 'display \n                             `((margin left-margin) \n                               ,(propertize (concat \" \" char)\n                                            'face (or face 'default)))))))\n\n(defun agenda-mark-entry-at-point ()\n  \"Set margin mark for entry at point.\"\n  (save-excursion\n    (save-match-data\n      (beginning-of-line)\n      (when-let ((entry (agenda-entry-at-point)))\n        (cond ((agenda-entry-cancel-p entry)\n               (agenda--set-mark (agenda-mark 'cancel) 'agenda-edit-cancel))\n              ((agenda-entry-birthday-p entry)\n               (agenda--set-mark (agenda-mark 'birthday)))\n              ((agenda-entry-today-p entry)\n               (agenda--set-mark (agenda-mark 'today)))\n              ((agenda-entry-active-deadline-p entry)\n               (agenda--set-mark (agenda-mark 'deadline) 'agenda-edit-deadline))\n              ((agenda-entry-inweek-p entry)\n               (agenda--set-mark (agenda-mark 'inweek)))\n              (t\n               (remove-overlays (line-beginning-position)\n                                (line-end-position)\n                                'agenda-mark t)))))))\n\n(defun agenda--set-link (beg end marker &optional face)\n  \"Mark BEG to END with a clickable button that moves point to MARKER.\nButton face can be specified with FACE.\"\n\n  (let ((map (make-sparse-keymap))\n        (callback (lambda (&rest _)\n                     (interactive)\n                     (push-mark) \n                     (goto-char (marker-position marker))\n                     (recenter))))\n    (define-key map [mouse-1] callback)\n    (define-key map [mouse-2] callback)\n    (define-key map (kbd \"RET\") callback)\n    (with-silent-modifications\n      (add-text-properties beg end\n                           `(mouse-face highlight\n                             face link\n                             font-lock-face link\n                             follow-link t\n                             keymap ,map)))))\n\n(defun agenda-link-data-at-point ()\n  \"Add link to date ref for entry at point.\"\n  (save-excursion\n    (save-match-data\n      (when-let* ((ref (agenda-match 'ref))                 \n                  (ref-beg (1+ (cadr ref)))\n                  (ref-end (1- (cddr ref)))\n                  (ref (substring (car ref) +1 -1))\n                  (ref-marker (save-excursion\n                                (goto-char ref-beg)\n                                (point-marker))))\n        (goto-char (point-min))\n        (when (search-forward-regexp (format \"^\\\\[\\\\(%s\\\\):.*\\\\]:.*$\" ref))\n          (let* ((data-beg (match-beginning 1))\n                (data-end (match-end 1))\n                (data-marker (save-excursion\n                               (goto-char data-beg)\n                               (point-marker))))\n            (agenda--set-link ref-beg ref-end data-marker)\n            (agenda--set-link data-beg data-end ref-marker)))))))\n\n(defun agenda-parse-buffer ()\n  \"Parse buffer.\"\n  (interactive)\n  (save-excursion\n    (remove-overlays (point-min) (point-max))\n    (font-lock-flush)\n    (font-lock-ensure)\n\n    ;; Process entries\n    (goto-char (point-min))\n    (while (re-search-forward agenda-entry-re nil t)\n      (let ((entry (agenda-entry-at-point)))\n        ;; Mark entry\n        (save-excursion\n          (goto-char (cadr (agenda-match 'date)))\n          (agenda-mark-entry-at-point))\n        ;; Create button on data\n        (save-excursion\n          (goto-char (cadr (agenda-match 'date)))\n          (agenda-link-data-at-point))))\n  \n    ;; Process headers\n    (with-silent-modifications\n      (goto-char (point-min))\n      (while (re-search-forward agenda-header-re nil t)\n        (let* ((start (match-beginning 0))\n               (full-prefix (match-string 1))\n               (prefix (format \"%2s\" (string-trim full-prefix))))\n          (put-text-property start (+ start (length full-prefix))\n                             'display `((margin left-margin)\n                                        ,(propertize prefix\n                                                     'face 'agenda-edit-header-prefix))))))))\n\n(defun agenda-date-change-at-point (delta)\n  \"Change date at point by DELTA '(year month day).\n  This methods highlights the modified date and update the margin marker.\"\n  (save-excursion\n    (when-let* ((entry (agenda-entry-at-point))\n                (date-group (agenda-match 'date))\n                (date-value (cdr (assoc 'date entry)))\n                (date-beg (cadr date-group))\n                (date-end (cddr date-group))\n                (timestamp (encode-time 0 0 0 \n                                          (+ (nth 2 date-value) (nth 2 delta))\n                                          (+ (nth 1 date-value) (nth 1 delta))\n                                          (+ (nth 0 date-value) (nth 0 delta))))\n                  (date (format-time-string \"%Y-%m-%d w%V %a\" timestamp)))\n        (goto-char (cadr date-group))\n        (delete-region date-beg date-end)\n        (insert date)\n        (agenda-mark-entry-at-point)\n        (agenda-highlight date-beg date-end))))\n\n(defun agenda-time-change-at-point (delta)\n  \"Change time or time-range at point by DELTA '(hour minute).\n  This methods highlights the modified date and update the margin marker.\"\n  (save-excursion\n    (when-let* ((point (point))\n                (entry (agenda-entry-at-point))\n                (time-group (agenda-match 'time))\n                (time-start (cdr (assoc 'time-start entry)))\n                (time-start-group (agenda-match 'time-start)))\n      (let* ((time-end (cdr (assoc 'time-end entry)))\n             (time-end-group (agenda-match 'time-end))\n             (point-on-time-start (and time-start-group\n                                       (>= point (cadr time-start-group))\n                                       (<  point (cddr time-start-group))))\n             (point-on-time-end (and time-end-group\n                                     (>= point (cadr time-end-group))\n                                     (<  point (cddr time-end-group))))\n             (time-start-ts (encode-time 0 \n                                         (+ (nth 1 time-start)\n                                            (if point-on-time-start (nth 1 delta) 0))\n                                         (+ (nth 0 time-start)\n                                            (if point-on-time-start (nth 0 delta) 0))\n                                         1 1 1970))\n             (time-end-ts (encode-time 0\n                                       (+ (nth 1 (or time-end time-start))\n                                          (if (or point-on-time-start point-on-time-end)\n                                              (nth 1 delta) 0))\n                                       (+ (nth 0 (or time-end time-start))\n                                          (if (or point-on-time-start point-on-time-end)\n                                              (nth 0 delta) 0))\n                                       1 1 1970))\n             (time-str (cond (point-on-time-end\n                              (format-time-string \"%H:%M\" time-end-ts))\n                             ((and point-on-time-start time-end)\n                              (format \"%s-%s\" \n                                      (format-time-string \"%H:%M\" time-start-ts)\n                                      (format-time-string \"%H:%M\" time-end-ts)))\n                             (point-on-time-start\n                              (format-time-string \"%H:%M\" time-start-ts))))\n             (time-region (cond (point-on-time-end\n                                 (cdr time-end-group))\n                                ((and point-on-time-start time-end)\n                                 (cdr time-group))\n                                (point-on-time-start\n                                 (cdr time-start-group)))))          \n        (when (and time-str time-region)\n          (delete-region (car time-region) (cdr time-region))\n          (goto-char (car time-region))\n          (insert time-str)\n          (agenda-mark-entry-at-point)\n          (agenda-highlight (car time-region) (cdr time-region)))))))\n\n(defmacro agenda--with-undoable-edit (&rest body)\n  \"Execute BODY as a buffer-modifying operation with undo and point safety.\n\n  This macro ensures:\n\n  1. The cursor (point) is preserved after BODY runs.\n  2. All changes are recorded in an undo change group.\n  3. If the user repeatedly invokes the same command, \n  all edits are merged into a single undo step.\n\n  Intended for use with commands that repeatedly modify\n  dates, times, or other buffer content in-place.\"\n  `(let ((orig-point (point))\n         (handle (if (eq last-command this-command)\n                     agenda--last-handle\n                   (prepare-change-group))))\n     (setq agenda--last-handle handle)\n     (unwind-protect\n         (progn\n           (activate-change-group handle)\n           ,@body)\n       (goto-char orig-point)\n       (when (eq last-command this-command)\n         (undo-amalgamate-change-group handle)))))\n\n(defun agenda--shift-up ()\n  \"Increment date or time at point, based on the cursor position.\"\n  (let ((groups (agenda-groups-at-point)))\n    (cond\n     ((memq 'date-y groups) (agenda-date-change-at-point '(+1 0 0)))\n     ((memq 'date-m groups) (agenda-date-change-at-point '(0 +1 0)))\n     ((memq 'date-d groups) (agenda-date-change-at-point '(0 0 +7)))     \n     ((memq 'time-start-h groups) (agenda-time-change-at-point '(+1 0)))\n     ((memq 'time-start-m groups) (agenda-time-change-at-point '(0 +5)))\n     ((memq 'time-end-h   groups) (agenda-time-change-at-point '(+1 0)))\n     ((memq 'time-end-m   groups) (agenda-time-change-at-point '(0 +5))))))\n\n(defun agenda--shift-down ()\n  \"Decrement date or time at point, based on the cursor position.\"\n  (let ((groups (agenda-groups-at-point)))\n    (cond\n     ((memq 'date-y groups) (agenda-date-change-at-point '(-1 0 0)))\n     ((memq 'date-m groups) (agenda-date-change-at-point '(0 -1 0)))\n     ((memq 'date-d groups) (agenda-date-change-at-point '(0 0 -7)))     \n     ((memq 'time-start-h groups) (agenda-time-change-at-point '(-1 0)))\n     ((memq 'time-start-m groups) (agenda-time-change-at-point '(0 -5)))\n     ((memq 'time-end-h   groups) (agenda-time-change-at-point '(-1 0)))\n     ((memq 'time-end-m   groups) (agenda-time-change-at-point '(0 -5))))))\n\n(defun agenda--shift-right ()\n  \"Increment date or time at point by 1 day or 1 hour.\"\n  (let ((groups (agenda-groups-at-point)))\n    (cond\n     ((memq 'date groups) (agenda-date-change-at-point '(0 0 +1)))\n     ((memq 'time groups) (agenda-time-change-at-point '(+1 0))))))\n\n(defun agenda-shift--left ()\n  \"Decrement date or time at point by 1 day or 1 hour.\"\n  (let ((groups (agenda-groups-at-point)))\n    (cond\n     ((memq 'date groups) (agenda-date-change-at-point '(0 0 -1)))\n     ((memq 'time groups) (agenda-time-change-at-point '(-1 0))))))\n\n(defun agenda-shift-down ()\n  \"Decrement date or time at point, based on the cursor position.\"\n  (interactive)\n  (agenda--with-undoable-edit (agenda--shift-down)))\n\n(defun agenda-shift-up ()\n  \"Increment date or time at point, based on the cursor position.\"\n  (interactive)\n  (agenda--with-undoable-edit (agenda--shift-up)))\n\n(defun agenda-shift-right ()\n  \"Increment date or time at point by 1 day or 1 hour.\"\n  (interactive)\n  (agenda--with-undoable-edit (agenda--shift-right)))\n\n(defun agenda-shift-left ()\n  \"Decrement date or time at point by 1 day or 1 hour.\"\n  (interactive)\n  (agenda--with-undoable-edit (agenda-shift--left)))\n\n(defun agenda-filter (regexp &optional strip-comment)\n  \"Hide lines not matching REGEXP. Supports keywords like 'future'.\n  With optional STRIP-COMMENT (prefix arg), comment lines are hidden.\"\n    (interactive\n     (let* ((keywords '(\"today\" \"this week\" \"this month\" \n                        \"tomorrow\" \"next week\" \"next month\" \n                        \"future\" \"marked\"))\n            (all (append keywords agenda-filter-history))\n            (input (completing-read \"Filter: \" \n                                    all nil nil nil 'agenda-filter-history)))\n       (list input current-prefix-arg)))\n\n  (save-excursion\n    (outline-show-all)\n    (let* ((now (current-time))\n           (keywords\n            `((\"today\"      . ,(format-time-string \"%Y-%m-%d\" now))\n              (\"tomorrow\"   . ,(format-time-string \"%Y-%m-%d\" (time-add now (days-to-time 1))))\n              (\"this week\"  . ,(format-time-string \"w%V\" now))\n              (\"this month\" . ,(format-time-string \"%Y-%m\" now))\n              (\"next week\"  . ,(format-time-string \"w%V\" (time-add now (days-to-time 7))))\n              (\"future\"     . \"__agenda_future__\")\n              (\"marked\"     . \"__agenda_mark__\")))\n           (actual-regexp (or (cdr (assoc (downcase (or regexp \"\")) keywords)) regexp)))\n\n      (with-silent-modifications\n        (remove-text-properties (point-min) (point-max) '(invisible nil))\n        (if (string-blank-p actual-regexp)\n            (progn\n              (setq buffer-read-only nil)\n              (outline-minor-mode 1))\n          (progn\n            (goto-char (point-min))\n            (while (not (eobp))\n              (let* ((is-comment (looking-at-p \"#\"))\n                     (matches\n                      (cond \n                       ((string= actual-regexp \"__agenda_mark__\")\n                        (agenda-line-marked-p))\n                       ((string= actual-regexp \"__agenda_future__\")\n                        (agenda-line-future-p))\n                       (t\n                        (agenda-line-match-p actual-regexp)))))\n                (unless (or matches (and (not strip-comment) is-comment))\n                  (put-text-property (line-beginning-position)\n                                     (line-beginning-position 2)\n                                     'invisible t))\n                (forward-line 1)))            \n            (setq buffer-read-only t)\n            (outline-minor-mode -1)))))))\n\n(defun agenda-cleanup ()\n  \"Reparse buffer and recenter.\"\n  (interactive)\n  (set-window-margins nil 3)\n  (setq buffer-read-only nil)\n  (with-silent-modifications\n    (remove-text-properties (point-min) (point-max) '(invisible nil)))\n  (agenda-parse-buffer)\n  (let ((agenda-edit-mode nil))\n    (call-interactively\n     (key-binding (this-command-keys)))))\n\n(defun agenda-outline-cycle ()\n  \"Toggle visibility and show hidden count by hijacking the last character.\"\n  (interactive)\n  (when outline-minor-mode\n    (condition-case nil\n        (save-excursion\n          (outline-back-to-heading)\n          (let* ((line-end (line-end-position))\n                 (subtree-end (save-excursion (outline-end-of-subtree) (point)))\n                 (count 0))\n            (remove-overlays (line-beginning-position) (1+ line-end) 'agenda-count t)\n            (if (outline-invisible-p line-end)\n                (progn \n                  (outline-show-entry)\n                  (outline-show-children))\n              (save-excursion\n                (goto-char line-end)\n                (while (re-search-forward agenda-entry-re subtree-end t)\n                  (setq count (1+ count))))\n              (outline-hide-subtree)\n              (when (> count 0)\n                (let* ((char-pos (1- line-end))\n                       (char-at-pos (char-to-string (char-after char-pos)))\n                       (ov (make-overlay char-pos line-end)))\n                  (overlay-put ov 'display \n                               (concat char-at-pos \n                                       (propertize (format \" (%d entries) \" count) \n                                                   'face 'agenda-edit-header-summary)))\n                  (overlay-put ov 'agenda-count t)\n                  (overlay-put ov 'priority 1000))))))\n      (error (indent-for-tab-command)))))\n\n(defun agenda-outline-cycle-all ()\n  \"Toggle visibility for the whole buffer. \n  If any heading is hidden, show all. Otherwise, collapse to Level 1 and show counts.\"\n  (interactive)\n  (when outline-minor-mode\n    (let ((any-folded nil))\n      (save-excursion\n        (goto-char (point-min))\n        (while (and (not any-folded) \n                    (re-search-forward outline-regexp nil t))\n          (when (outline-invisible-p (line-end-position))\n            (setq any-folded t))))\n      (if any-folded\n          (progn\n            (remove-overlays (point-min) (point-max) 'agenda-count t)\n            (outline-show-all))\n        (outline-hide-sublevels 1)\n        (save-excursion\n          (goto-char (point-min))\n          (while (re-search-forward \"^# +.*$\" nil t)\n            (let* ((line-end (point))\n                   (subtree-end (save-excursion (outline-end-of-subtree) (point)))\n                   (count 0))\n              (remove-overlays (line-beginning-position) (1+ line-end) 'agenda-count t)\n              (save-excursion\n                (while (re-search-forward agenda-entry-re subtree-end t)\n                  (setq count (1+ count))))\n              (when (> count 0)\n                (let* ((char-pos (1- line-end))\n                       (char-at-pos (char-to-string (char-after char-pos)))\n                       (ov (make-overlay char-pos line-end)))\n                  (overlay-put ov 'display \n                               (concat char-at-pos \n                                       (propertize (format \" (%d entries) \" count) \n                                                   'face 'agenda-edit-header-summary)))\n                  (overlay-put ov 'agenda-count t)\n                  (overlay-put ov 'priority 1000))))))))))\n\n(defun agenda--goto-date (target &optional exact)\n  \"Go to the TARGET date (month day year). If EXACT is non-nil, only stops on a perfect match.\n Otherwise, stops on the closest date equal to or older than selected date.\"\n  (let* ((target-time (encode-time 0 0 0 (nth 1 target) (nth 0 target) (nth 2 target)))\n         (target-days (time-to-days target-time))\n         (best-pos nil))\n    (save-excursion\n      (goto-char (point-max))\n      (catch 'found\n        (while (re-search-backward agenda-entry-re nil t)\n          (let* ((entry-date-str (car (agenda-match 'date-iso)))\n                 (entry-time-str (or (car (agenda-match 'time-start)) \"00:00\"))\n                 (entry-days (time-to-days\n                              (date-to-time (concat entry-date-str \" \" entry-time-str)))))\n            (if exact\n                (cond\n                 ((= entry-days target-days)\n                  (setq best-pos (match-beginning 0))\n                  (throw 'found t))\n                 \n                 ((< entry-days target-days)\n                  (setq best-pos nil)\n                  (throw 'found nil)))\n              (setq best-pos (match-beginning 0))\n              (when (<= entry-days target-days)\n                (throw 'found t)))))))\n    (if best-pos\n        (progn\n          (goto-char best-pos)\n          (beginning-of-line)))))\n\n(defun agenda-goto-date (&optional exact)\n  \"Open the calendar and go to the selected date when RET is pressed.\nIf EXACT is non-nil, only stops on a perfect match.  Otherwise, stops on\nthe closest date equal to or older than selected date.\"\n  (interactive (list current-prefix-arg))\n   (agenda-with-calendar-select date\n     (agenda--goto-date date)))\n\n(defun agenda-insert-entry (&optional here)\n  \"Open the calendar and insert a new entry for the selected date.\nIf HERE is t,  insert entry at point, else, search for closest date.\"\n  (interactive (list current-prefix-arg))\n  (agenda-with-calendar-select date\n    (unless here\n      (agenda--goto-date date))\n    (end-of-line)\n    (unless (= (line-beginning-position) (line-end-position))\n      (insert \"\\n\"))\n    (let* ((timestamp (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))\n           (hour (string-to-number (format-time-string \"%H\"))))\n      (insert (concat (format-time-string \"%Y-%m-%d w%V %a\" timestamp)\n                      \"  \" (format \"%02d:00\" hour) \"-\"\n                      (format \"%02d:00  \" (min (1+ hour) 24)))))))\n\n(defun agenda-repeat-entry (frequency count)\n  \"Read current entry and create COUNT copies incremented by FREQUENCY.\n  FREQUENCY is a string like '+1w', '+3d', '+1m', or '+1y'.\"\n  (interactive \"sFrequency (e.g., +1w): \\nnCount: \")\n  (save-excursion\n    (beginning-of-line)\n    (if (not (looking-at agenda-entry-re))\n        (user-error \"Not on a valid agenda entry\")\n      (let* ((year  (string-to-number (car (agenda-match 'date-y))))\n             (month (string-to-number (car (agenda-match 'date-m))))\n             (day   (string-to-number (car (agenda-match 'date-d))))\n             (rest  (buffer-substring (cddr (agenda-match 'date))\n                                      (line-end-position)))\n             (val   (string-to-number (substring frequency 1 -1)))\n             (unit  (substring frequency -1))\n             (delta (pcase unit\n                      (\"d\" (list val 0 0))\n                      (\"w\" (list (* val 7) 0 0))\n                      (\"m\" (list 0 val 0))\n                      (\"y\" (list 0 0 val))\n                      (_ (user-error \"Unknown unit: %s\" unit)))))        \n        (end-of-line)\n        (dotimes (i count)\n          (let* ((multiplier (1+ i))\n                 (new-time (encode-time 0 0 0 \n                                        (+ day   (* multiplier (nth 0 delta)))\n                                        (+ month (* multiplier (nth 1 delta)))\n                                        (+ year  (* multiplier (nth 2 delta))))))\n            (insert (format-time-string \"\\n%Y-%m-%d w%V %a\" new-time)\n                    rest)))))))\n\n(defun agenda-collect-uids ()\n  \"Scan agenda buffer for all UIDs (entry & data lines).\"\n  (let (uids)\n    (save-excursion\n      ;; Entry lines\n      (goto-char (point-min))\n      (while (re-search-forward agenda-entry-re nil t)\n        (when-let ((uid-str (agenda-match 'uid)))\n          (push (substring (car uid-str) 1 -1) uids)))\n      ;; Data lines\n      (goto-char (point-min))\n      (while (re-search-forward agenda-data-re nil t)\n        (when-let ((uid-str (agenda-match 'data-uid)))\n          (push (car uid-str) uids))))\n    (delete-dups uids)))\n\n(defun agenda-entry-generate-uid (entry)\n  \"Generate a unique id for ENTRY.\nChecks YYYYMMDDTHHMM, then YYYYMMDDT0001, T0002, etc.\"\n  (let* ((uid-data (cdr (assoc 'uid (assoc 'data entry))))\n         (used (delete uid-data (agenda-collect-uids)))\n         (date (cdr (assoc 'date entry)))\n         (time (or (cdr (assoc 'time-start entry)) '(0 1)))\n         (uid-prefix (format \"%04d%02d%02dT\" (nth 0 date) (nth 1 date) (nth 2 date)))\n         (uid-suffix (format \"%02d%02d\" (nth 0 time) (nth 1 time)))              \n         (uid-auto (or uid-data (concat uid-prefix uid-suffix)))\n         (uid-uniq (if (not (member uid-auto used))\n                       uid-auto\n                     (let ((count 1) (res nil))\n                       (while (not res)\n                         (let ((uid-temp (format \"%s%04d\" uid-prefix count)))\n                           (if (not (member uid-temp used))\n                               (setq res uid-temp)\n                             (setq count (1+ count)))))\n                       res)))\n         (uid-user (read-string \"UID: \" uid-uniq)))    \n    (while (member uid-user used)\n      (setq uid-user (read-string (format \"UID '%s' already used! New UID: \" uid-user) \n                                  uid-uniq)))\n    uid-user))\n\n(defun agenda-entry-set-data (uid key value)\n  \"Update or create metadata for entry at point.\n  If C-u is provided, prompts to confirm/modify the UID.\n  Metadata is stored at the END of the buffer.\n\n  [NOTE]: Co-written with Gemini.\"\n  (interactive\n   (let* ((entry (or (agenda-entry-at-point) (user-error \"No entry at point\")))\n          (data-alist (cdr (assoc 'data entry)))\n          ;; 1. Handle UID: Prompt ONLY if prefix argument (C-u) is active\n          (final-uid (if current-prefix-arg\n                         (agenda-entry-generate-uid entry)\n                       (or (cdr (assoc 'uid data-alist))\n                           ;; Silent generation if no UID exists\n                           (let ((uid-data (cdr (assoc 'uid data-alist)))\n                                 (used (agenda-collect-uids))\n                                 (date (cdr (assoc 'date entry)))\n                                 (time (or (cdr (assoc 'time-start entry)) '(0 1))))\n                             (let* ((prefix (format \"%04d%02d%02dT\" (nth 0 date) (nth 1 date) (nth 2 date)))\n                                    (suffix (format \"%02d%02d\" (nth 0 time) (nth 1 time)))\n                                    (base (concat prefix suffix)))\n                               (if (not (member base used)) base\n                                 (let ((c 1) (res nil))\n                                   (while (not res)\n                                     (let ((cand (format \"%s%04d\" prefix c)))\n                                       (if (not (member cand used)) (setq res cand)\n                                         (setq c (1+ c)))))\n                                   res)))))))\n          ;; 2. Select Key\n          (selected-key (completing-read \"Key: \" '(\"URL\" \"MAP\" \"NOTE\") nil t))\n\n          ;; 3. Extract existing value from data alist\n          (key-sym (intern (downcase selected-key)))\n          (current-val (or (cdr (assoc key-sym data-alist)) \"\")))\n     (list final-uid \n           selected-key \n           (read-string (format \"Value (%s): \" selected-key) current-val))))\n\n  (let ((entry-pos (copy-marker (line-beginning-position))))\n    ;; 1. Sync the UID on the entry line\n    (save-excursion\n      (goto-char entry-pos)\n      (let ((existing-uid (cdr (assoc 'uid (assoc 'data (agenda-entry-at-point))))))\n        (unless (string= uid existing-uid)\n          (when (re-search-forward \" +\\\\[[^]]+\\\\]\" (line-end-position) t)\n            (replace-match \"\"))\n          (goto-char (line-end-position))\n          (insert (format \" [%s]\" uid)))))\n\n    ;; 2. Update or delete the data line at the end of the buffer\n    (save-excursion\n      (goto-char (point-max))\n      (unless (bolp) (insert \"\\n\"))\n      (let ((search-re (format \"^\\\\[%s:%s\\\\]:\" (regexp-quote uid) (regexp-quote key)))\n            (found-pos nil))\n        (save-excursion\n          (when (re-search-backward search-re nil t)\n            (setq found-pos (line-beginning-position))))\n        (cond\n         ((and found-pos (string-empty-p value))\n          (goto-char found-pos)\n          (delete-region (line-beginning-position) (progn (forward-line 1) (point))))\n         ((and found-pos (not (string-empty-p value)))\n          (goto-char found-pos)\n          (delete-region (line-beginning-position) (line-end-position))\n          (insert (format \"[%s:%s]: %s\" uid key value)))\n         ((not (string-empty-p value))\n          (goto-char (point-max))\n          (unless (bolp) (insert \"\\n\"))\n          (insert (format \"[%s:%s]: %s\\n\" uid key value))))))\n\n    ;; 3. Cleanup Header\n    (save-excursion\n      (goto-char (point-min))\n      (unless (re-search-forward (format \"^\\\\[%s:[[:alpha:]]+\\\\]:\" (regexp-quote uid)) nil t)\n        (goto-char entry-pos)\n        (when (re-search-forward (format \" +\\\\[%s\\\\]\" (regexp-quote uid)) (line-end-position) t)\n          (replace-match \"\"))))    \n    (set-marker entry-pos nil)))\n\n(defun agenda-insert-holidays (year &optional no-header)\n  \"Generate and insert holidays for YEAR.\nWith a prefix argument (C-u), skip the '# Holidays' header.\"\n  (interactive \n   (list (read-number \"Year: \" (nth 5 (decode-time (current-time))))\n         current-prefix-arg))\n  (let ((results nil))\n    (save-window-excursion\n      (list-holidays year year))\n    (with-current-buffer \"*Holidays*\"\n      (save-excursion\n        (goto-char (point-min))\n        (while (re-search-forward \"^\\\\([^:\\n]+\\\\): +\\\\(.*\\\\)$\" nil t)\n          (let* ((date-raw (match-string 1))\n                 (event-name (match-string 2))\n                 (parsed (parse-time-string date-raw))\n                 (day (nth 3 parsed))\n                 (month (nth 4 parsed))\n                 (item-year (or (nth 5 parsed) year)))\n            (when (and day month)\n              (let* ((time-val (encode-time 0 0 0 day month item-year))\n                     (full-date (format-time-string \"%Y-%m-%d w%V %a\" time-val)))\n                (push (format \"%s  %s +HOLIDAYS\\n\" full-date event-name) results)))))))\n    (when results\n      (unless no-header\n        (insert (format \"## Holidays %d\\n\\n\" year)))\n      (dolist (line (reverse results))\n        (insert line))\n      (unless no-header (insert \"\\n\")))))\n\n(defvar agenda-edit-mode-map\n  (let ((map (make-sparse-keymap)))\n    (define-key map (kbd \"S-<right>\") #'agenda-shift-right)\n    (define-key map (kbd \"S-<left>\")  #'agenda-shift-left)\n    (define-key map (kbd \"S-<down>\")  #'agenda-shift-down)\n    (define-key map (kbd \"S-<up>\")    #'agenda-shift-up)\n    (define-key map (kbd \"C-c e\")     #'agenda-export)\n    (define-key map (kbd \"C-c g\")     #'agenda-goto-date)\n    (define-key map (kbd \"C-c i\")     #'agenda-insert-entry)\n    (define-key map (kbd \"C-c r\")     #'agenda-repeat-entry)\n    (define-key map (kbd \"C-c d\")     #'agenda-entry-set-data)\n    (define-key map (kbd \"C-c f\")     #'agenda-filter)\n    (define-key map (kbd \"C-l\")       #'agenda-cleanup)\n    (define-key map (kbd \"TAB\")       #'agenda-outline-cycle)\n    (define-key map (kbd \"<backtab>\") #'agenda-outline-cycle-all)\n    (define-key map (kbd \"C-c a\")     #'agenda-view)\n    map)\n  \"Keymap for 'agenda-edit-mode'.\")\n\n(defconst agenda-font-lock-keywords\n  `((,agenda-data-re\n     (0 'agenda-edit-data)\n     (,(agenda-group 'data-ref) '(agenda-edit-data-ref) prepend t))\n\n    (,agenda-header-re\n     (0  'agenda-edit-header))\n    \n    (,agenda-comment-re\n     (0 'agenda-edit-comment))\n\n    (,agenda-entry-re\n     (0 (let* ((date (car (agenda-match 'date)))\n               (time (car (agenda-match 'time)))\n               (tags (car (agenda-match 'tags))))\n          (setq-local is-today     (agenda-date-today-p date))\n          (setq-local is-now       (agenda-date-time-now-p date time))\n          (setq-local is-inweek    (agenda-date-inweek-p (match-string 1)))\n          (setq-local is-cancel    (agenda-tags-cancel-p tags))\n          (setq-local is-deadline  (and (agenda-tags-deadline-p tags)\n                                        (not (agenda-tags-done-p tags))))\n          (cond (is-cancel 'agenda-edit-cancel)\n                ((and (not is-inweek) (not is-today)) 'agenda-edit-outweek)\n                (t nil))))\n     (,(agenda-group 'date)\n      (cond (is-cancel                  'agenda-edit-cancel)\n            (is-deadline                'agenda-edit-deadline)\n            ((and is-today is-deadline) 'agenda-edit-deadline)\n            (is-today                   'agenda-edit-today)\n            (is-inweek                  'agenda-edit-inweek)\n            (t                          'agenda-edit-outweek)) prepend)\n     \n     (,(agenda-group 'time) (cond (is-cancel 'agenda-edit-cancel)\n                                  (is-today  'agenda-edit-today)\n                                  (is-inweek 'agenda-edit-inweek)\n                                  (t         'agenda-edit-outweek)) prepend t)\n     \n     (,(agenda-group 'title) (cond (is-cancel 'agenda-edit-cancel)\n                                   (is-today  'agenda-edit-today)\n                                   (is-inweek 'agenda-edit-inweek)\n                                   (t         'agenda-edit-outweek)) prepend)\n     \n     (,(agenda-group 'actions) (cond (is-cancel 'agenda-edit-cancel)\n                                     (is-today  '(agenda-edit-action\n                                                  agenda-edit-today))\n                                     (is-inweek 'agenda-edit-action)\n                                     (t         'agenda-edit-outweek)) prepend t)\n      \n     (,(agenda-group 'tags) (cond (is-cancel 'agenda-edit-cancel)\n                                  (is-today  '(agenda-edit-tag\n                                               agenda-edit-today))\n                                  (is-inweek 'agenda-edit-tag)\n                                  (t         'agenda-edit-outweek)) prepend t)\n     \n     (,(agenda-group 'uid) (cond (is-cancel  'agenda-edit-cancel)\n                                 (is-today   '(agenda-edit-reference\n                                               agenda-edit-today))\n                                 (is-inweek  'agenda-edit-reference)\n                                 (t          'agenda-edit-outweek)) prepend t)))\n  \"Agenda font lock for edit mode.\")\n\n;;;###autoload\n(define-minor-mode agenda-edit-mode\n  \"Minor mode for editing agenda files.\"\n  :lighter \"Agenda[E]\"\n  :keymap agenda-edit-mode-map\n  (if agenda-edit-mode\n      (progn\n        (font-lock-add-keywords nil agenda-font-lock-keywords 'append)\n        (font-lock-flush)\n        (font-lock-ensure)\n        (set-window-margins nil 3)\n        (setq-local left-margin-width 3)\n        (setq-local outline-regexp \"^\\\\(#+\\\\) \"\n                    outline-level (lambda () (length (match-string 1)))\n                    outline-heading-end-regexp \"\\n\"\n                    outline-end-of-heading-function nil)\n        (outline-minor-mode 1)\n        (agenda-parse-buffer))\n    (progn\n      (font-lock-remove-keywords nil agenda-font-lock-keywords)\n      (set-window-margins nil 0)\n      (setq-local left-margin-width 0)\n      (agenda-highlight-clear)\n      (with-silent-modifications\n        (remove-text-properties (point-min) (point-max) '(invisible nil))\n        (remove-text-properties (point-min) (point-max) '(display nil))\n        (remove-overlays (point-min) (point-max)))\n      (font-lock-flush)\n      (font-lock-ensure))))\n\n(provide 'agenda-edit)\n;;; agenda-edit.el ends here\n"
  },
  {
    "path": "agenda-export.el",
    "content": ";;; agenda-export.el --- Export functions -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'agenda-parse)\n\n(defun agenda-export--ical-sanitize (string)\n  \"Sanitize STRING by escaping commas, semicolons, and newlines with a\nbackslash and removing unicode nerd icons.\"\n  (when (stringp string)\n    (setq string (replace-regexp-in-string (regexp-quote \"\\\\\") \"\\\\\\\\\" string t t))\n    (setq string (replace-regexp-in-string (regexp-quote \",\")  \"\\\\,\" string t t))\n    (setq string (replace-regexp-in-string (regexp-quote \";\")  \"\\\\;\" string t t))\n    (setq string (replace-regexp-in-string (regexp-quote \"\\n\") \"\\\\n\" string t t))\n    (setq string (replace-regexp-in-string \"[\\uE000-\\uF8FF] \" \"\" string))\n    string))\n\n(defun agenda-export--ical-uid (date time public)\n  \"Generate UID from DATE, TIME and PUBLIC.\nPublic UIDs are suffixed with '-PUBLIC', else with '-PRIVATE'.\"\n  (format \"%04d%02d%02dT%02d%02d%s\"\n          (nth 0 date) (nth 1 date) (nth 2 date)\n          (if time (nth 0 time) 0)\n          (if time (nth 1 time) 0)\n          (if public \"-PUBLIC\" \"-PRIVATE\")))\n\n(defun agenda-export--ical-timestamp (date time &optional public)\n  (if time\n      (format \"%04d%02d%02dT%02d%02d00\" \n              (nth 0 date) (nth 1 date) (nth 2 date)\n              (nth 0 time) (nth 1 time))\n    (format \"%04d%02d%02d\"\n            (nth 0 date) (nth 1 date) (nth 2 date))))\n\n(defun agenda-export--ical-entry (entry &optional public)  \n  \"Return regular ENTRY as a VEVENT ical string.\n Generated UID and informations depends on whether PUBLIC is t.\"\n  (let* ((date (cdr (assoc 'date entry)))\n         (time-start (cdr (assoc 'time-start entry)))\n         (time-end (cdr (assoc 'time-end entry)))\n         (title (cdr (assoc 'title entry)))\n         (actions (cdr (assoc 'actions entry))) \n         (tags (cdr (assoc 'tags entry)))\n         (is-deadline (member \"DEADLINE\" tags))\n         (is-birthday (member \"BIRTHDAY\" tags))\n         (data (cdr (assoc 'data entry)))\n         (url (cdr (assoc 'url data)))\n         (note (cdr (assoc 'note data)))\n         (map (cdr (assoc 'map data))))\n    (concat\n     \"BEGIN:VEVENT\\n\"\n     ;; UID\n     (format \"UID:%s\\n\" (agenda-export--ical-uid date time-start public))\n\n     ;; DSTAMP\n     (format \"DTSTAMP:%s\\n\" (format-time-string \"%Y%m%dT%H%M%SZ\" nil t))\n\n    ;; DTSTART or DUE\n     (if is-deadline\n         (concat (format \"DUE:%s\\n\" (agenda-export--ical-timestamp date time-start))\n                 \"STATUS:NEEDS-ACTION\\n\")\n       (format \"DTSTART:%s\\n\" (agenda-export--ical-timestamp date time-start)))\n\n     ;; DTEND\n     (when (and time-end (not is-deadline) (not is-birthday))\n       (format \"DTEND:%s\\n\" (agenda-export--ical-timestamp date time-end)))\n\n     ;; BIRTHDAY\n     (when is-birthday\n       (concat \"RRULE:FREQ=YEARLY\\n\"\n               \"TRANSP:TRANSPARENT\\n\"\n               \"X-APPLE-SPECIAL-DAY:BIRTHDAY\\n\"))\n\n     ;; PUBLIC part\n     (if public\n         ;; SUMMARY\n         (if map\n             (format \"SUMMARY:(away)\\n\")\n           (format \"SUMMARY:(busy)\\n\"))\n       \n       ;; PRIVATE part\n       (concat\n        ;; SUMMARY\n        (format \"SUMMARY:%s (%s)\\n\"\n                (agenda-export--ical-sanitize title)\n                (mapconcat #'string-trim actions \",\"))\n        ;; CATEGORIES\n        (when tags (format \"CATEGORIES:%s\\n\" (mapconcat #'string-trim tags \",\")))\n        ;; URL\n        (when url (format \"URL:%s\\n\" url))\n        ;; LOCATION\n        (when map (format \"LOCATION:%s\\n\" map))\n        ;; DESCRIPTION\n        (when note (format \"DESCRIPTION: %s\\n\" (agenda-export--ical-sanitize note)))))\n     \"END:VEVENT\\n\")))\n\n(defun agenda-export-ical (filename &optional public)\n  (let ((entries (agenda-collect-entries t)))\n    (with-temp-buffer\n      (insert \"BEGIN:VCALENDAR\\n\"\n              \"VERSION:2.0\\n\"\n              \"CALSCALE:GREGORIAN\\n\"\n              (format \"X-WR-CALNAME:%s/%s\\n\"\n                      (upcase user-login-name)\n                      (upcase (if public \"public\" \"private\")))\n              (format-time-string \"X-WR-TIMEZONE:%Z\\n\")\n              \"\\n\")\n      (dolist (entry entries)\n        (insert (agenda-export--ical-entry entry public) \"\\n\"))\n      (insert \"\\n\"\n              \"END:VCALENDAR\\n\")\n      (write-region (point-min) (point-max) filename))))\n\n(defun agenda-export-sync ()\n  \"Run 'vdirsyncer sync' and report status / time.\"\n  (interactive)\n  (let* ((buf-name \"*Vdirsyncer Output*\")\n         (buf (get-buffer-create buf-name))\n         (proc (get-buffer-process buf))\n         (start-time (float-time (current-time))))    \n    (if (process-live-p proc)\n        (message \"vdirsyncer is already running.\")      \n      (progn\n        (with-current-buffer buf\n          (let ((inhibit-read-only t))\n            (erase-buffer)))        \n        (message \"vdirsyncer: sync started...\")        \n        (let ((new-proc (start-process-shell-command \"vdir-sync\" buf \"vdirsyncer sync\")))\n          (set-process-sentinel new-proc\n              (lambda (p event)\n                (let* ((elapsed (- (float-time (current-time)) start-time))\n                       (p-buf (process-buffer p)))\n                  (cond \n                   ((string-match-p \"finished\" event)\n                    (message \"vdirsyncer: sync complete (%.2fs).\" elapsed))\n                   ((string-match-p \"exited abnormally\" event)\n                    (message \"vdirsyncer: sync failed (%.2fs).\" elapsed)\n                    (pop-to-buffer p-buf)))))))))))\n\n(defun agenda-export (&optional no-sync)\n  \"Export agenda in public and private ical files and synchronize them\nusing vdirsyncer unless NO-SYNC is t.\"\n  (interactive)\n  (if (and agenda-file-ical-public\n           (file-exists-p agenda-file-ical-public))\n      (agenda-export-ical agenda-file-ical-public t)\n    (error \"Public ical file (%s) does not exist.\" agenda-file-ical-public))\n  (if (and agenda-file-ical-private\n           (file-exists-p agenda-file-ical-private))\n      (agenda-export-ical agenda-file-ical-private nil)\n    (error \"Private ical file (%s) does not exist.\" agenda-file-ical-private))\n  (unless no-sync\n    (agenda-export-sync)))\n\n(provide 'agenda-export)\n;;; agenda-export.el ends here\n"
  },
  {
    "path": "agenda-faces.el",
    "content": ";;; agenda-faces.el --- Visual styles and customization -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n\n(defgroup agenda nil\n  \"Agenda\"\n  :group 'applications)\n\n(defgroup agenda-edit-faces nil\n  \"Agenda faces for edit mode.\"\n  :group 'agenda)\n\n(defgroup agenda-view-faces nil\n  \"Agenda faces for view mode.\"\n  :group 'agenda)\n\n(defface agenda-edit-highlight\n  '((t :inherit (widget-field bold default)\n       :inverse-video nil))\n  \"Face for transient highlighting (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-inweek\n  '((t :inherit (default)))\n  \"Face for entries in current week (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-outweek\n  '((t :inherit (shadow)))\n  \"Face for entries oustide current week (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-today\n  '((t :inherit (bold)))\n  \"Face for today entries (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-tag\n  '((t :inherit (warning)))\n  \"Face for tags (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-action\n  '((t :inherit (link)))\n  \"Face for actions (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-reference\n  '((t :inherit shadow))\n  \"Face for references (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-data\n  '((t :inherit shadow))\n  \"Face for data line (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-data-ref\n  '((t :inherit (shadow bold)))\n  \"Face for key on data line (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-cancel\n  '((t :strike-through t :inherit shadow))\n  \"Face for cancelled entries (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-deadline\n  '((t :inherit (error bold)))\n  \"Face for deadline entries (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-header\n  '((t :inherit (bold)))\n  \"Face for headers (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-header-prefix\n  '((t :inherit (shadow default)))\n  \"Face for headers prefix (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-header-summary\n  '((t :inherit (warning)))\n  \"Face for headers entries summary (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-data\n  '((t :inherit (shadow)))\n  \"Face for date line (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-ref\n  '((t :inherit (bold)))\n  \"Face for date line reference (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-edit-comment\n  '((t :inherit (shadow)))\n  \"Face for comments (edit mode).\"\n  :group 'agenda-edit-faces)\n\n(defface agenda-view-title\n  '((t :inherit (bold)))\n  \"Face for title (week, view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-subtitle\n  '((t :inherit (shadow)))\n    \"Face for subtitle (week extent, view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-date\n  '((t :inherit (bold)))\n  \"Face for date (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-tag\n  '((t :inherit (agenda-edit-tag)))\n  \"Face for tags (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-action\n  '((t :inherit (agenda-edit-action)))\n  \"Face for actions (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-cancel\n  '((t :inherit agenda-edit-cancel))\n  \"Face for cancelled entries (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-button\n  '((t :inherit (link bold)))\n  \"Face for buttons (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-time\n  '((t :inherit (bold)))\n  \"Face for time (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-deadline-header\n  '((t :inherit (bold error)))\n  \"Face for deadline header (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-date-today\n  '((t :inherit (bold error)))\n  \"Face for today text in view mode.\"\n  :group 'agenda-faces)\n\n(defface agenda-view-time-today\n  '((t :inherit (bold)))\n  \"Face for today time (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-view-time-now\n  '((t :inverse-video t :inherit bold))\n  \"Face for now time (view mode).\"\n  :group 'agenda-view-faces)\n\n(defface agenda-deadline-0\n  '((t :inverse-video t :inherit (bold)))\n  \"Face for deadline with priority 0.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-deadline-1\n  '((t :inverse-video t :inherit (bold error)))\n  \"Face for deadline with priority 1.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-deadline-2\n  '((t :inherit (bold error)))\n  \"Face for deadline with priority 2.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-deadline-3\n  '((t :inherit (bold)))\n  \"Face for deadline with priority 3.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-slot-free\n  '((t :inherit region))\n  \"Face for free slot.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-slot-busy\n  '((t :inverse-video t :inherit (bold shadow)))\n  \"Face for busy slot.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-slot-busy-inweek\n  '((t :inverse-video t :inherit (bold)))\n  \"Face for busy slot for the current week.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-slot-deadline\n  '((t :inverse-video t :inherit (error bold)))\n  \"Face for busy & deadline slot.\"\n  :group 'agenda-view-faces)\n\n(defface agenda-slot-personal\n  '((t :inverse-video t :inherit (link bold)))\n  \"Face for busy & personal slot.\"\n  :group 'agenda-view-faces)\n\n(provide 'agenda-faces)\n;;; agenda-faces.el ends here\n"
  },
  {
    "path": "agenda-parse.el",
    "content": ";;; agenda-parse.el --- Parsing, test and collect functions -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;; Commentary:\n\n;; This module provides all parsing and test functions for processing\n;; agenda source file.\n;;\n;; It handles:\n;;   - Identification of entries via regular expressions.\n;;   - Various tests on string or entries\n;;   - Convertion of raw text lines into entry\n;;   - Conversion of entries field into string\n;;   - Collect entries based on a filter function\n;;   - Compute 30mn slots for a given date\n;;\n;; All collect functions use a cache whose invalidation is based on\n;; buffer modified tick. Cache can be bypassed with the force\n;; parameter in relevant functions.\n\n;;; Code:\n(require 'rx)\n\n(defconst agenda-entry-re\n  (rx line-start\n      ;; --- DATE BLOCK ---\n      (submatch-n 1 ;; date (e.g., \"2026-01-17 W02 Sat\")\n        (submatch-n 2 ;; date-iso (e.g., \"2026-01-17\")\n          (submatch-n 3 (repeat 4 digit)) \"-\" ;; date-y\n          (submatch-n 4 (repeat 2 digit)) \"-\" ;; date-m\n          (submatch-n 5 (repeat 2 digit)))    ;; date-d\n        (optional (one-or-more space) (any \"Ww\") (one-or-more digit))\n        (optional (one-or-more space) (one-or-more letter)))\n      (one-or-more space)\n      ;; --- TIME BLOCK ---\n      (optional\n       (submatch-n 6 ;; time (e.g., \"08:30-10:00\")\n         (submatch-n 7 ;; time-start (e.g., \"08:30\")\n           (submatch-n 8 (repeat 2 digit)) \":\" ;; time-start-h\n           (submatch-n 9 (repeat 2 digit)))    ;; time-start-m\n         (optional \"-\" \n                   (submatch-n 10 ;; time-end (e.g., \"10:00\")\n                     (submatch-n 11 (repeat 2 digit)) \":\" ;; time-end-h\n                     (submatch-n 12 (repeat 2 digit))))))  ;; time-end-m\n\n      (optional (one-or-more space) (one-or-more \"-\")) ;;  Aesthetic dashes\n      (one-or-more space)\n      \n      ;; --- CONTENT BLOCK ---\n      ;;      (submatch-n 13 (minimal-match (zero-or-more (not (any \"@+#\")))) \n      ;;                  (not (any \"@+# \"))) ;; non-empty title\n      (submatch-n 13 (zero-or-more (not (any \"@+#\\n\")))) ;; title\n      \n      (optional (one-or-more space)\n                (submatch-n 14 (one-or-more (seq \"@\" (one-or-more (not (any space \"+@#\"))) \n                                                (zero-or-more space))))) ;; actions\n      (optional (one-or-more space)\n                (submatch-n 15 (one-or-more (seq \"+\" (one-or-more (not (any space \"+@#\"))) \n                                                 (zero-or-more space))))) ;; tags\n      ;; --- UID BLOCK ---\n      (optional (one-or-more space)\n                (submatch-n 16 \"[\" (one-or-more (any alnum \"-\")) \"]\")) ;; [UID]\n      line-end)\n  \"Matches an entry line with several groups that can be accessed using the\n'agenda-match' function.\")\n\n(defconst agenda-data-re\n  (rx line-start\n      \"[\"\n      (submatch-n 1 ;; Full data ref (UID:KEY)\n        (submatch-n 2 (one-or-more (any alnum \"-\"))) ;; UID\n        \":\"\n        (submatch-n 3 (one-or-more alpha))) ;; KEY\n      \"]:\"\n      (zero-or-more space)\n      (submatch-n 4 (zero-or-more not-newline)) ;; Content (value)\n      line-end)\n  \"Matches a data line with several groups that can be accessed using\nthe 'agenda-match' function.\")\n\n(defconst agenda-header-re\n  (rx line-start\n      (submatch-n 1 (one-or-more \"#\")\n                    (one-or-more space))\n      (group (one-or-more (not (any \":\" \"\\n\")))) ;; No colons allowed\n      line-end)\n  \"Matches a header line.\")\n\n(defconst agenda-comment-re\n  (rx line-start\n      \"#\" (one-or-more space)\n      (group (zero-or-more not-newline))\n      line-end)\n  \"Matches a comment line.\")\n\n(defconst agenda-group-map\n  '(;; All\n    (all . 0)\n    ;; Entry line (1-16) \n    (date         . 1) (date-iso     . 2)\n    (date-y       . 3)  (date-m       . 4) (date-d       . 5)\n    (time         . 6)\n    (time-start   . 7)  (time-start-h . 8) (time-start-m . 9)\n    (time-end     . 10) (time-end-h  . 11) (time-end-m  . 12)\n    (title        . 13) (actions     . 14) (tags        . 15)\n    (uid          . 16) (ref         . 16) \n    ;; Data line (1-4)\n    (data . 0)\n    (data-ref . 1)  (data-uid . 2) (data-key . 3) \n    (data-value . 4))\n  \"Fixed mapping of semantic names to group indices for both\n'agenda-entry-re' and 'agenda-data-re'\")\n\n(defun agenda-group (type)\n  \"Get the group number for TYPE (from the 'agenda-group map').\"\n  (or (cdr (assoc type agenda-group-map))\n      (error \"Unknown agenda group: %s\" type)))\n\n(defun agenda-match (type &optional string)\n  \"Return (MATCH-STRING . (BEG . END)) for group TYPE and optional STRING\nby the previous search or regexp operation.\"\n  (let ((group (agenda-group type)))\n    (when (match-beginning group)\n      (cons (match-string-no-properties group string)\n            (cons (match-beginning group) \n                  (match-end group))))))\n\n(defun agenda-groups-at-point ()\n  \"Return list of groups at point, sorted by descending specificity.\"\n  (save-excursion\n    (let ((point (point)))\n      (beginning-of-line)\n      (when-let* ((line-type (cond ((looking-at agenda-entry-re) :entry)\n                                   ((looking-at agenda-data-re)  :data)\n                                   (t nil))))\n        (let (matches)\n          (dolist (entry agenda-group-map)\n            (let* ((sym (car entry))\n                   (group (cdr entry))\n                   (is-data (string-prefix-p \"data-\" (symbol-name sym))))\n              (when (eq (if is-data :data :entry) line-type)\n                (let ((beg (match-beginning group))\n                      (end (match-end group)))\n                  (when (and beg end (>= point beg) (<= point end))\n                    (push (cons sym (- end beg)) matches))))))\n          (mapcar #'car (sort matches (lambda (a b) (> (cdr a) (cdr b))))))))))\n\n(defun agenda-lookup-data (uid)\n  \"Scan buffer backwards for data lines matching UID and return an alist\nof (key . value).\"\n  (save-match-data\n    (save-excursion\n      (goto-char (point-max))\n      (let ((results `((uid . ,uid))))\n        (while (re-search-backward agenda-data-re nil t)\n          (when (string= (car (agenda-match 'data-uid)) uid)\n            (push (cons (intern (downcase (car (agenda-match 'data-key))))\n                        (car (agenda-match 'data-value)))\n                  results)))\n        results))))\n\n(defun agenda-entry-from-match ()\n  \"Return an entry from previous search or regexp operation.\"\n  (let* ((date (list (string-to-number (car (agenda-match 'date-y)))\n                     (string-to-number (car (agenda-match 'date-m)))\n                     (string-to-number (car (agenda-match 'date-d)))))\n         (time-start (when-let ((h (car (agenda-match 'time-start-h)))\n                                (m (car (agenda-match 'time-start-m))))\n                       (list (string-to-number h) (string-to-number m))))\n         (time-end   (when-let ((h (car (agenda-match 'time-end-h)))\n                                (m (car (agenda-match 'time-end-m))))\n                       (list (string-to-number h) (string-to-number m))))\n         (title   (when-let ((title (car (agenda-match 'title))))\n                    (string-trim title)))\n         (actions (when-let ((actions (car (agenda-match 'actions))))\n                    (save-match-data\n                      (split-string (string-trim actions) \"@\" t))))\n         (tags    (when-let ((tags (car (agenda-match 'tags))))\n                    (save-match-data\n                      (split-string (string-trim tags) \"+\" t))))\n         (marker (save-excursion\n                   (goto-char (match-beginning 0))\n                   (point-marker)))\n         (uid (when-let ((uid (car (agenda-match 'uid))))\n                (substring uid +1 -1))) ;; Remove [ and ]\n         (data (when uid (agenda-lookup-data uid))))\n    `((date       . ,date)\n      (marker     . ,marker)\n      (time-start . ,time-start)\n      (time-end   . ,time-end)\n      (title      . ,title)\n      (actions    . ,actions)\n      (tags       . ,tags)\n      (data       . ,data))))\n\n(defun agenda-entry-at-point ()\n  \"Get entry at point (if any).\"\n  (save-excursion\n    (beginning-of-line)\n    (when (looking-at agenda-entry-re)\n      (agenda-entry-from-match))))\n\n(defun agenda-data-at-point ()\n  \"Get data at point (if any).\"\n  (save-excursion\n    (beginning-of-line)\n    (when (looking-at agenda-data-re)\n      (let ((uid (car (agenda-match 'data-uid)))\n            (key (intern (downcase (car (agenda-match 'data-key)))))\n            (val (car (agenda-match 'data-value))))\n        (cons uid (cons key val))))))\n\n(defun agenda-entry-date-string (entry &optional format)\n  \"Return ENTRY date as a formatted string using FORMAT.\nDefault format is YYYY-MM-DD wXX Day.\"\n  (let* ((format (or format \"%Y-%m-%d w%V %a\"))\n         (date (cdr (assoc 'date entry)))\n         (year (nth 0 date))\n         (month (nth 1 date))\n         (day (nth 2 date))\n         (timestamp (encode-time (list 0 0 0 day month year))))\n    (format-time-string format timestamp)))\n\n(defun agenda-entry-date-iso-string (entry)\n  \"Return ENTRY date as an ISO date format YYYY-MM-DD.\"\n  (agenda-entry-date-string entry \"%Y-%m-%d\"))\n\n(defun agenda-entry-time-start-string (entry)\n  \"Return ENTRY time start as a formatted string HH:MM or nil.\"\n  (when-let* ((time (cdr (assoc 'time-start entry)))\n              (time-h (nth 0 time))\n              (time-m (nth 1 time)))\n    (format \"%02d:%02d\" time-h time-m)))\n\n(defun agenda-entry-time-end-string (entry)\n  \"Return ENTRY time end ad a formatted string HH:MM or nil.\"\n  (when-let* ((time (cdr (assoc 'time-end entry)))\n              (time-h (nth 0 time))\n              (time-m (nth 1 time)))\n    (format \"%02d:%02d\" time-h time-m)))\n\n(defun agenda-entry-time-string (entry)\n  \"Convert ENTRY time as a formatted string [HH:MM[-HH:MM]].\"\n  (let* ((time-start (agenda-entry-time-start-string entry))\n         (time-end   (agenda-entry-time-end-string entry)))\n    (cond ((and time-start time-end) (format \"%s-%s\" time-start time-end))\n          (time-start                time-start))))\n\n(defun agenda-entry-tags-string (entry)\n  \"Return ENTRY tags formatted for display.\"\n  (when-let* ((tags (cdr (assoc 'tags entry))))\n    (mapconcat (lambda (tag) (concat \"+\" tag)) tags \"\")))\n\n(defun agenda-entry-actions-string (entry)\n  \"Return ENTRY actions formatted for display.\"\n  (when-let* ((actions (cdr (assoc 'actions entry))))\n    (mapconcat (lambda (action) (concat \"@\" action)) actions \"\")))\n\n(defun agenda-entry-title-string (entry)\n  \"Return ENTRY title formatted for display.\"\n  (cdr (assoc 'title entry)))\n\n(defun agenda-entry-less-p (entry-1 entry-2)\n  \"Return non-nil if ENTRY1 is before ENTRY2 (lexicographic order\nbased on entries date+time).\"\n  (let ((entry-1-str (concat (agenda-entry-date-iso-string entry-1) \" \"\n                            (agenda-entry-time-string entry-1)))\n        (entry-2-str (concat (agenda-entry-date-iso-string entry-2) \" \"\n                            (agenda-entry-time-string entry-2))))\n    (string< entry-1-str entry-2-str)))\n\n(defun agenda-line-marked-p ()\n  \"Return non-nil if current line has a margin-mark overlay.\"\n  (seq-find (lambda (ov) (overlay-get ov 'agenda-mark)) \n            (overlays-in (line-beginning-position) (line-end-position))))\n\n(defun agenda-line-future-p ()\n  \"Return non-nil if line starts with a date >= today.\"\n  (let ((today (format-time-string \"%Y-%m-%d\"))\n        (date (buffer-substring (line-beginning-position) \n                                (+ (line-beginning-position) (length today)))))\n    (or (string= date today)\n        (string> date today))))\n\n(defun agenda-line-match-p (regex)\n  \"Return non-nil if REGEX matches the current line.\"\n  (let ((line (buffer-substring-no-properties (line-beginning-position) \n                                              (line-end-position)))\n        (case-fold-search t))\n    (string-match-p regex line)))\n\n(defun agenda-date-today-p (date-str)\n  \"Return t if DATE-STR (formatted as 'YYYY-MM-DD') is today.\"\n  (when (stringp date-str)\n    (string-prefix-p (format-time-string \"%Y-%m-%d\") date-str)))\n\n(defun agenda-date-time-now-p (date-str time-str)\n  \"Return t if DATE-STR (formatted as 'YYYY-MM-DD') is today and\ncurrent time is within TIME-STR range (formatted as 'HH:MM-HH:MM')\"\n  (when (and (stringp date-str) (stringp time-str)\n             (agenda-date-today-p date-str))\n    (save-match-data\n      (when-let* ((now (current-time))\n                  (times (string-split time-str \"-\"))\n                  (start-str (nth 0 times))\n                  (end-str (or (nth 1 times) start-str)) \n                  (time-start (date-to-time (concat date-str \" \" start-str)))\n                  (time-end (date-to-time (concat date-str \" \" end-str))))\n        (and (not (time-less-p now time-start))\n             (time-less-p now time-end))))))\n\n(defun agenda-date-inweek-p (date-str)\n  \"Return t if DATE-STR (formatted as 'YYYY-MM-DD wXX Day') is in current week.\"\n  (when (stringp date-str)\n    (save-match-data\n      (string-match-p (format-time-string \"[wW]%V\") date-str))))\n\n(defun agenda-tags-cancel-p (tags-str)\n  \"Check if +CANCEL is present in TAGS-STR.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (string-match-p \"+CANCEL\" tags-str))))\n\n(defun agenda-tags-deadline-p (tags-str)\n  \"Check if +DEADLINE is present in TAGS-STR.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (string-match-p \"+DEADLINE\" tags-str))))\n\n(defun agenda-tags-active-deadline-p (tags-str)\n  \"Check if +DEADLINE is present in TAGS-STR but not +DONE.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (and (string-match-p \"+DEADLINE\" tags-str)\n           (not (string-match-p \"+DONE\" tags-str))))))\n\n(defun agenda-tags-done-p (tags-str)\n  \"Check if +DONE is present in TAGS-STR.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (string-match-p \"+DONE\" tags-str))))\n\n(defun agenda-tags-personal-p (tags-str)\n  \"Check if +PERSONAL is present in TAGS-STR.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (string-match-p \"+PERSONAL\" tags-str))))\n\n(defun agenda-tags-birthday-p (tags-str)\n  \"Check if +BIRTHDAY is present in TAGS-STR.\"\n  (when (stringp tags-str)\n    (save-match-data\n      (string-match-p \"+BIRTHDAY\" tags-str))))\n\n(defun agenda-entry-inweek-p (entry &optional week year)\n  \"Return t if entry is in WEEK (str) of YEAR (str).\"\n  (let* ((date (agenda-entry-date-string entry))\n         (week (or week (string-to-number (format-time-string \"%V\"))))\n         (week (format \"[wW]%02d\" week))\n         (year (or year (string-to-number (format-time-string \"%Y\"))))\n         (year (format \"%04d\" year)))\n    (and (string-prefix-p year date)\n         (string-match-p week date))))\n\n(defun agenda-entry-between-p (entry &optional beg end)\n  \"Return t if entry is between BEG and END (YYYY-MM-DD format).\n  If BEG is nil, there is no lower bound. If END is nil, there is no upper bound.\"\n  (let ((date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (and date\n         (or (null beg) (not (string< date beg)))\n         (or (null end) (not (string< end date))))))\n\n(defun agenda-entry-strictly-between-p (entry &optional beg end)\n  \"Return t if entry is strictly between BEG and END (strings in YYYY-MM-DD format).\n  If BEG is nil, there is no lower bound. If END is nil, there is no upper bound.\"\n  (let ((date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (and date\n         (or (null beg) (string< beg date))\n         (or (null end) (string< date end)))))\n\n(defun agenda-entry-after-p (entry &optional date)\n  \"Return t if entry is on or after DATE (YYYY-MM-DD).\n  If DATE is nil, defaults to today.\"\n  (let ((after-date (or date (format-time-string \"%Y-%m-%d\")))\n        (entry-date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (not (string< entry-date after-date))))\n\n(defun agenda-entry-strictly-after-p (entry &optional date)\n  \"Return t if entry is strictly after DATE (YYYY-MM-DD).\n  If DATE is nil, defaults to today.\"\n  (let ((after-date (or date (format-time-string \"%Y-%m-%d\")))\n        (entry-date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (string< after-date entry-date)))\n\n(defun agenda-entry-before-p (entry &optional date)\n  \"Return t if entry is on or before DATE (YYYY-MM-DD).\n  If DATE is nil, defaults to today.\"\n  (let ((before-date (or date (format-time-string \"%Y-%m-%d\")))\n        (entry-date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (not (string< before-date entry-date))))\n\n(defun agenda-entry-strictly-before-p (entry &optional date)\n  \"Return t if entry is strictly before DATE (YYYY-MM-DD).\n  If DATE is nil, defaults to today.\"\n  (let ((before-date (or date (format-time-string \"%Y-%m-%d\")))\n        (entry-date (agenda-entry-date-string entry \"%Y-%m-%d\")))\n    (string< entry-date before-date)))\n\n(defun agenda-entry-date-p (entry &optional date)\n  \"Return t if entry falls on DATE (YYYY-MM-DD).\n  If DATE is nil, defaults to today.\"\n    (string= (or date (format-time-string \"%Y-%m-%d\"))\n             (agenda-entry-date-iso-string entry)))\n\n(defun agenda-entry-today-p (entry)\n  \"Return t if entry is today.\"\n  (agenda-entry-date-p entry))\n\n(defun agenda-entry-now-p (entry)\n  \"Return t if entry is now.\"\n  (let ((time-start-hm (agenda-entry-time-start-string entry))\n        (time-end-hm (agenda-entry-time-end-string entry))\n        (now-hm (format-time-string \"%H:%M\"))\n        (is-today (agenda-entry-today-p entry)))\n    (and is-today time-start-hm\n         (not (string< now-hm time-start-hm))\n         (or (not time-end-hm)\n             (string< now-hm time-end-hm)))))\n\n(defun agenda-entry-cancel-p (entry)\n  \"Return t if entry has CANCEL in tags\"\n  (when-let ((tags (cdr (assoc 'tags entry))))\n    (member \"CANCEL\" tags)))\n\n(defun agenda-entry-deadline-p (entry)\n  \"Return t if entry has DEADLINE in tags\"\n  (when-let ((tags (cdr (assoc 'tags entry))))\n    (member \"DEADLINE\" tags)))\n\n(defun agenda-entry-active-deadline-p (entry)\n  \"Return t if entry has DEADLINE in tags\"\n  (when-let ((tags (cdr (assoc 'tags entry))))\n    (and (member \"DEADLINE\" tags)\n         (not (member \"DONE\" tags)))))\n\n(defun agenda-entry-todo-p (entry)\n  \"Return t if entry has TODO in actions\"\n  (when-let ((actions (cdr (assoc 'actions entry))))\n    (member \"DONE\" actions)))\n\n(defun agenda-entry-done-p (entry)\n  \"Return t if entry has DONE in tags\"\n  (when-let ((tags (cdr (assoc 'tags entry))))\n    (member \"DONE\" tags)))\n\n(defun agenda-entry-birthday-p (entry &optional week day)\n  \"Return t if entry has BIRTHDAY in tags and week is WEEK and DAY.\"\n  (when-let* ((date (agenda-entry-date-string entry))\n              (entry-date (cdr (assoc 'date entry)))\n              (tags (cdr (assoc 'tags entry)))\n              (week (or week (string-to-number (format-time-string \"%V\"))))\n              (week (format \"[wW]%02d\" week)))\n    (and (member \"BIRTHDAY\" tags)\n         (or (not day)\n             (eq day (nth 2 entry-date)))\n         (string-match-p week date))))\n\n(defvar-local agenda-source-buffer nil\n  \"Agenda source buffer\")\n\n(defun agenda-source-buffer ()\n  \"Return the agenda source buffer.\"\n  (unless (and agenda-source-buffer (buffer-live-p agenda-source-buffer))\n    (unless (and agenda-file (file-exists-p agenda-file))\n      (error \"Agenda file not found: %s. \" agenda-file))\n    (setq agenda-source-buffer (find-file-noselect agenda-file)))\n  agenda-source-buffer)\n\n(defvar-local agenda--entries-cache nil\n  \"Cache storage for entries as (TICK . ENTRIES).\")\n\n(defun agenda-collect-entries (&optional force)\n  \"Retrieve all entries from the source buffer.\nIf FORCE is non-nil, ignore the cache and re-scan.\"\n  (with-current-buffer (agenda-source-buffer)\n    (let ((current-tick (buffer-chars-modified-tick (agenda-source-buffer))))\n      (if (and (not force)\n               agenda--entries-cache\n               (eq (car agenda--entries-cache) current-tick))\n          (cdr agenda--entries-cache)\n        (let ((entries nil))\n          (save-excursion\n            (goto-char (point-min))\n            (while (re-search-forward agenda-entry-re nil t)\n              (push (agenda-entry-from-match) entries)))\n          (setq agenda--entries-cache (cons current-tick entries))\n          entries)))))\n\n(defun agenda-filter-entries (filter-fn &rest args)\n  \"Collect and return a sorted list of entries that satisfy FILTER-FN.\nFILTER-FN is called on each entry with supplementary ARGS.\"\n  (let* ((filtered nil))\n    (dolist (entry (agenda-collect-entries))\n      (when (apply filter-fn entry args)\n        (push entry filtered)))\n    (sort filtered #'agenda-entry-less-p)))\n\n(defvar-local agenda--uids-cache nil\n  \"Cache storage for UIDs as (TICK . UIDS).\")\n\n(defun agenda-collect-uids (&optional force)\n  \"Scan agenda buffer for all UIDs (entry or data lines).\nIf FORCE is non-nil, ignore the cache and re-scan.\"\n  (let ((current-tick (buffer-chars-modified-tick (agenda-source-buffer))))\n    (if (and (not force)\n             agenda--uids-cache \n             (eq (car agenda--uids-cache) current-tick))\n        (cdr agenda--uids-cache)\n      (let (uids)\n        (save-excursion\n          ;; Entry lines\n          (goto-char (point-min))\n          (while (re-search-forward agenda-entry-re nil t)\n            (when-let ((uid-str (agenda-match 'uid)))\n              (push (substring (car uid-str) 1 -1) uids)))\n          ;; Data lines\n          (goto-char (point-min))\n          (while (re-search-forward agenda-data-re nil t)\n            (when-let ((uid-str (agenda-match 'data-uid)))\n              (push (car uid-str) uids))))\n        (let ((result (delete-dups uids)))\n          (setq agenda--uids-cache (cons current-tick result))\n          result)))))\n\n(defvar-local agenda--slots-cache nil\n  \"Cache storage for slots as (TICK . ((DATE . SLOTS) ...)).\")\n\n(defun agenda-collect-slots (date &optional force)\n  \"Compute 30-minute slots for a given calendar DATE (month day year).\nIf FORCE is non-nil, ignore the cache and re-scan.\"\n  (let ((current-tick (buffer-chars-modified-tick (agenda-source-buffer))))\n    (unless (and (not force)\n                 agenda--slots-cache \n                 (eq (car agenda--slots-cache) current-tick))\n      (setq agenda--slots-cache (cons current-tick nil)))\n    (let* ((date-cache (cdr agenda--slots-cache))\n           (cached-entry (assoc date date-cache)))\n      (if cached-entry\n          (cdr cached-entry)\n        (let* ((date-iso (format \"%04d-%02d-%02d\" (nth 2 date) (nth 0 date) (nth 1 date)))\n               (entries (agenda-filter-entries\n                         (lambda (entry date)\n                           (and (not (agenda-entry-cancel-p entry))\n                                (agenda-entry-date-p entry date)))\n                         date-iso))\n               (slots (make-list 48 nil)))\n          (dolist (entry entries)\n            (let* ((start (cdr (assoc 'time-start entry)))\n                   (start-h (nth 0 start))\n                   (start-m (nth 1 start))\n                   (end (cdr (assoc 'time-end entry)))\n                   (end-h (cond (end   (nth 0 end))\n                                (start start-h)))\n                   (end-m (cond (end   (nth 1 end))\n                                (start (+ start-m 30)))))\n              (when (and start-h start-m end-h end-m)\n                (let* ((slot-start (/ (+ (* start-h 60) start-m) 30))\n                       (slot-end   (/ (+ (* end-h 60) end-m) 30)))\n                  (dotimes (i 48)\n                    (when (and (>= i slot-start) (< i slot-end))\n                      (push entry (nth i slots))))))))\n          (setcdr agenda--slots-cache \n                  (cons (cons date slots) date-cache))\n          slots)))))\n\n(provide 'agenda-parse)\n;;; agenda-parse.el ends here\n"
  },
  {
    "path": "agenda-utils.el",
    "content": ";;; agenda-utils.el --- Utility functions -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;; Commentary:\n\n;; This module provides various utility functions.\n\n;;; Code:\n\n(defvar agenda--last-selected-date nil\n  \"Stores the last selected date (month day year).\")\n\n(defmacro agenda-with-calendar-select (var &rest body)\n  \"Open calendar and bind the selected date to VAR, then execute BODY.\nWhen a date is selected, it is saved for next call.\"\n  (declare (indent 1))\n  (let ((callback-sym (make-symbol \"callback\")))\n    `(let ((,callback-sym (lambda (,var) ,@body)))\n       (calendar)\n       (when agenda--last-selected-date\n         (calendar-goto-date agenda--last-selected-date))\n       (let ((map (make-sparse-keymap)))\n         (set-keymap-parent map calendar-mode-map)\n         (define-key map (kbd \"RET\")\n           `(lambda ()\n              (interactive)\n              (let ((selected-date (calendar-cursor-to-date)))\n                (setq agenda--last-selected-date selected-date)\n                (calendar-exit)\n                (funcall ,,callback-sym selected-date))))         \n         (define-key map (kbd \"C-g\")\n           (lambda ()\n             (interactive)\n             (calendar-exit)))\n         (use-local-map map)))))\n\n(defun agenda-date-forward (date &optional n unit)\n  \"Forward calendar DATE (month day year) by N UNIT. \nSupports negative N for moving backward.\"\n  (let* ((n (or n 1))\n         (unit (or unit 'day))\n         (month (nth 0 date))\n         (day (nth 1 date))\n         (year (nth 2 date)))\n    (pcase unit\n      ((or 'day 'week)\n       (let ((delta (if (eq unit 'week) (* n 7) n)))\n         (calendar-gregorian-from-absolute\n          (+ (calendar-absolute-from-gregorian date) delta))))\n      ((or 'month 'month-3)\n       (let* ((total-months (+ month -1 (if (eq unit 'month-3) (* n 3) n)))\n              (new-month (+ (mod total-months 12) 1))\n              (new-year (+ year (floor total-months 12)))\n              (last-day (calendar-last-day-of-month new-month new-year))\n              (new-day (min day last-day)))\n         (list new-month new-day new-year)))\n      ('year\n       (let* ((new-year (+ year n))\n              (last-day (calendar-last-day-of-month month new-year))\n              (new-day (min day last-day)))\n         (list month new-day new-year)))      \n      (_ (error \"Invalid unit: %s\" unit)))))\n\n(defun agenda-url-button-string (text url)\n  \"Return TEXT as a clickable string that opens URL.\"\n  (let ((map (make-sparse-keymap))\n        (callback (lambda (&optional _ignore) \n                    (interactive) \n                    (browse-url url))))\n    (define-key map [mouse-1] callback)\n    (define-key map [mouse-2] callback)\n    (define-key map (kbd \"RET\") callback)\n    (propertize text\n                'face 'agenda-view-button\n                'font-lock-face 'agenda-view-button\n                'mouse-face 'highlight\n                'help-echo (concat \"Go to \"\n                                   (propertize url 'face 'agenda-view-button))\n                'follow-link t\n                'keymap map)))\n\n(provide 'agenda-utils)\n;;; agenda-utils.el ends here\n"
  },
  {
    "path": "agenda-view-day.el",
    "content": ";;; agenda-view-day.el --- Daily view  -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'cal-iso)\n(require 'agenda-parse)\n(require 'agenda-faces)\n\n\n(defun agenda-view-day--display-title (date)\n  \"Return DATE string.\"\n  (let* ((ts (encode-time (list 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))))\n    (propertize (format-time-string \"%A, %d %B %Y\" ts)\n                'face 'agenda-view-title)))\n\n(defun agenda-view-day--display-date (date)\n  \"Return DATE string for day header.\"\n  (let* ((today-iso (format-time-string \"%Y-%m-%d\"))\n         (date-ts (encode-time (list 0 0 0 (nth 2 date) (nth 1 date) (nth 0 date))))\n         (date-iso (format-time-string \"%Y-%m-%d\" date-ts))\n         (date-str (format-time-string \"%A %d %B %Y\" date-ts)))\n    (concat (propertize date-str 'face 'agenda-view-date)\n            (if (string= date-iso today-iso) \n                (propertize \" (today)\\n\\n\" 'face 'agenda-view-date-today)\n              \"\\n\\n\"))))\n\n(defun agenda-view-day--display-entry (entry &optional time-str)\n  \"Return ENTRY string, optionally with time replaced by TIME-STR.\"\n  (let* ((today-iso (format-time-string \"%Y-%m-%d\"))\n         (date-iso (agenda-entry-date-string entry \"%Y-%m-%d\"))\n         (time-start-hm (agenda-entry-time-start-string entry))\n         (time-end-hm (agenda-entry-time-end-string entry))\n         (data (cdr (assoc 'data entry)))\n         (url (cdr (assoc 'url data)))\n         (title (cdr (assoc 'title entry)))\n         (title (if url\n                    (agenda-url-button-string title url)\n                  title))\n        (actions (agenda-entry-actions-string entry))\n        (tags (agenda-entry-tags-string entry))                       \n        (marker (cdr (assoc 'marker entry)))\n        (line-face (if (agenda-entry-cancel-p entry)\n                       'agenda-view-cancel\n                     nil))\n        (time-face (cond ((agenda-entry-now-p entry)\n                          'agenda-view-time-now)\n                         ((agenda-entry-today-p entry)\n                          'agenda-view-time-today)\n                         (t 'default)))\n        (time-str (if time-str\n                      (format \" %11s \" time-str)\n                    (propertize\n                     (cond ((and time-start-hm time-end-hm)\n                            (format \" %s-%s \" time-start-hm time-end-hm))\n                           (time-start-hm\n                            (format \" %s       \" time-start-hm))\n                           (t\n                            \" ----------- \"))\n                     'face (or time-face line-face)))))\n    (propertize\n     (concat  \" \" time-str\n              \" \" title\n              (when actions\n                (concat \" \" (propertize actions 'face (or line-face 'agenda-edit-action))))\n              (when tags\n                (concat \" \" (propertize tags 'face (or line-face 'agenda-edit-tag))))\n              \"\")\n     'agenda-entry-marker marker)))\n\n(defun agenda-view-day-display (&optional date force)\n  \"Display the agenda for DATE. When FORCE is t, force update.\"\n  (let* ((date (or date agenda-view-date))\n         (year (or (nth 2 date)\n                   (string-to-number (format-time-string \"%Y\"))))\n         (month (or (nth 0 date)\n                     (string-to-number (format-time-string \"%m\"))))\n         (day (or (nth 1 date)\n                  (string-to-number (format-time-string \"%d\"))))\n         (date (list month day year))\n         (date-str (format \"%4d-%02d-%02d\" year month day))\n         (ts (encode-time (list 0 0 0 day month year)))\n         (week (string-to-number (format-time-string \"%V\" ts)))\n         (today (format-time-string \"%Y-%m-%d\"))\n         (now (format-time-string \"%H:%M\"))\n         \n         ;; Entries (filtered by week/year)\n         (entries (agenda-filter-entries \n                   (lambda (entry date)\n                     (and (not (agenda-entry-cancel-p entry))\n                          (agenda-entry-date-p entry date)))\n                   date-str))\n    \n         ;; Birthdays (filtered by week and post-processed)\n         (birthdays (agenda-filter-entries \n                     (lambda (entry week year)\n                       (and (not (agenda-entry-cancel-p entry))\n                            (agenda-entry-birthday-p entry week (nth 1 date))))\n                     week year))\n         (birthdays (agenda-view--process-birthdays birthdays year))\n\n         ;; Deadlines (future only)\n         (deadlines (agenda-filter-entries \n                     (lambda (entry week year)\n                       (and (not (agenda-entry-cancel-p entry))\n                            (not (agenda-entry-done-p entry))\n                            (agenda-entry-deadline-p entry)))\n                     week year))\n\n         (entries (sort (append entries birthdays) #'agenda-entry-less-p)))\n    \n        ;; Calendar\n        (save-excursion\n          (insert (agenda-view-calendar date t)))\n        (agenda-view--next-line 1 24)\n        (insert \"  \" (agenda-view-day--display-title date))\n        (agenda-view--next-line 2 24)\n        \n        ;; Entries and birthdays\n        (if entries\n            (dolist (entry entries)\n              (let ((date (cdr (assoc 'date entry))))\n                (insert (agenda-view-day--display-entry entry))\n                (agenda-view--next-line 1 24)))\n          (progn\n            (insert (propertize \"  No event found.\" 'face 'shadow))\n            (agenda-view--next-line 1 24)))\n\n        ;; Future deadlines\n        (when (> (length deadlines) 0)\n          (agenda-view--next-line 1 24)\n          (insert (propertize \"  Upcoming deadlines\" 'face 'agenda-view-date))\n          (agenda-view--next-line 2 24)\n          (dolist (entry deadlines)\n            (let* ((date (cdr (assoc 'date entry)))\n                   (time (encode-time (list 0 0 0 (nth 2 date) (nth 1 date) (nth 0 date))))\n                   (days (- (time-to-days time)\n                            (time-to-days (current-time))))\n                   (face (agenda-view--deadline-face days))\n                   (time-str (propertize (format \"In %2d days \" days)\n                                         'face face)))\n              (when (<= days 21)\n                (insert (agenda-view-day--display-entry entry time-str))\n                (agenda-view--next-line 1 24)))))\n        \n        ;; Move point to relevant place on mini-calendar\n        (goto-char (point-min))\n        (when-let ((prop (text-property-search-forward 'agenda-date-marker date #'equal)))\n          (goto-char (prop-match-beginning prop)))))\n  \n(provide 'agenda-view-day)\n;;; agenda-view-day.el ends here\n"
  },
  {
    "path": "agenda-view-month.el",
    "content": ";;; agenda-view-month.el --- Monthly view -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'calendar)\n(require 'agenda-parse)\n(require 'agenda-faces)\n\n\n(defun agenda-view-month--display-week (date &optional no-newline show-week)\n  \"Return DATE literal string, prefixed by a newline for Mondays, unless\nNO-NEWLINE is t. Week number is shown for Mondays or when SHOW-WEEK it t.\"\n  (let* ((ts (encode-time (list 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))\n         (weekday (nth 6 (decode-time ts)))\n         (is-monday (eq weekday 1))\n         (is-weekend (memq weekday '(0 6)))\n         (line-prefix (if (and is-monday (not no-newline)) \"\\n\" \"\"))\n         (week-prefix (format-time-string \"Week %V, %a, %d %b %Y  \" ts))\n         (date-prefix (format-time-string \"         %a, %d %b %Y  \" ts))\n         (week-prefix (format-time-string \"%a %d \" ts))\n         (date-prefix (format-time-string \"%a %d \" ts))\n         (face (cond (is-weekend 'shadow)\n                     (is-monday  'bold)\n                     (t          'shadow))))\n    (propertize\n     (concat line-prefix\n             (if (or is-monday show-week)\n                 week-prefix\n               date-prefix))\n     'font-lock-face face 'face face)))\n\n(defun agenda-view-month--display-entry (entry)\n  \"Return a display string for ENTRY.\"\n  (let ((time (agenda-entry-time-string entry))\n        (title (agenda-entry-title-string entry))\n        (actions (agenda-entry-actions-string entry))\n        (tags (agenda-entry-tags-string entry)))\n    (concat (when time\n              (concat (propertize time 'face 'bold) \" \"))\n            title \" \" actions \" \" tags)))\n\n(defun agenda-view-month--slot-face (entries)\n  \"Return face for entries (=slot).\"\n  (let* ((entry (car entries))\n         (inweek (when entry (agenda-entry-inweek-p entry)))\n         (face (cond (inweek  'agenda-slot-busy-inweek)\n                     (entries 'agenda-slot-busy)\n                     (t       'agenda-slot-free))))\n    (catch 'found\n      (dolist (slot agenda-slot-faces)\n        (let* ((slot-key (car slot))\n               (slot-face (cdr slot)))\n          (dolist (entry entries)\n            (let ((tags (agenda-entry-tags-string entry)))\n              (when (and (stringp tags) (string-match-p slot-key tags))\n                (setq face slot-face)\n                (throw 'found face)))))))\n    face))\n\n(defun agenda-view-month--display-slot (entries &optional date)\n  \"Return a one char string for SLOT.\"\n  (let* ((first (car entries))\n         (count (length entries))\n         (is-deadline (seq-some #'agenda-entry-deadline-p entries))\n         (marker (when first (cdr (assoc 'marker first))))\n         (help (when entries\n                 (mapconcat #'agenda-view-month--display-entry entries \"\\n\")))\n         (face (agenda-view-month--slot-face entries))\n         (char (cond (is-deadline (agenda-mark 'deadline))\n                     ((> count 1) (agenda-mark 'conflict))\n                     (t           \" \"))))\n    (propertize char\n                'face face\n                'agenda-date-marker date\n                'agenda-entry-marker marker\n                'help-echo help)))\n\n(defun agenda-view-month--display-summary (slots)\n  \"Given a list of slots, return a single line summary of entries.\"\n\n  (let ((summaries)\n        (entries (nreverse (seq-uniq (seq-mapcat #'identity slots)))))\n    (dolist (entry entries)\n      (let* ((time (cdr (assoc 'time-start entry)))\n             (title (cdr (assoc 'title entry)))\n             (inweek (agenda-entry-inweek-p entry))\n             (now (agenda-entry-now-p entry))\n             (title-face (if inweek 'default 'shadow))\n             (time-face  (cond (now    '(:inverse-video t :inherit bold))\n                               (inweek 'bold)                               \n                               (t '(bold shadow))))\n             (data (cdr (assoc 'data entry)))\n             (url (cdr (assoc 'url data)))\n             (title (if (and inweek url)\n                        (agenda-url-button-string title url)\n                      (propertize title 'face title-face)))\n             (marker (cdr (assoc 'marker entry)))\n             (summary (if time\n                          (concat\n                           (propertize (format (if now \" %02d:%02d \" \"%02d:%02d\")\n                                               (nth 0 time) (nth 1 time))\n                                       'face time-face)\n                           \" \"\n                           title)\n                        (format \"%s\" title)))\n             (summary (propertize summary 'agenda-entry-marker marker)))\n        (push summary summaries)))\n    (mapconcat #'identity summaries (propertize \" \" 'face 'shadow))))\n\n(defun agenda-view-month--display-slots (date &optional hour-start hour-end with-summary)\n  \"Return slots string for calendar DATE (month day year) between\nHOUR-START and HOUR-END. When WITH-SUMMRAY is t, append a summary with all entries.\"\n  (let* ((slots (agenda-collect-slots date))\n         (slots-str \"\")\n         (hour-start (or hour-start 8))\n         (hour-start (min (max hour-start 0) 23))\n         (hour-end (or hour-end 18))\n         (hour-end (min (max (1+ hour-start) hour-end) 24))\n         (index-start (* hour-start 2))\n         (index-max (* hour-end 2))\n         (index index-start))\n    (while (<= index index-max)\n      (setq slots-str (concat slots-str\n                             (agenda-view-month--display-slot (nth index slots) date)\n                             (agenda-view-month--display-slot (nth (1+ index) slots) date)))\n      (setq index (+ index 2)))\n    (concat slots-str\n            (when with-summary\n              (concat \"  \" (agenda-view-month--display-summary slots))))))\n\n(defun agenda-view-month--display-clock (&optional hour-start hour-end)\n  \"Return time string for calendar DATE (month day year) between\nHOUR-START and HOUR-END.\"\n  (let* ((time \"\")\n         (hour-start (or hour-start 8))\n         (hour-end (or hour-end 18))\n         (hour-start (min (max hour-start 0) 23))\n         (hour-end (min (max (1+ hour-start) hour-end) 24))\n         (index-start (* hour-start 2))\n         (index-max (* hour-end 2))\n         (index index-start))\n    (while (<= index index-max)\n      (setq time (concat time\n                         (if (eq (% (- index index-start) 4) 0)\n                             (propertize (concat (format \"%02d\" (/ index 2)))\n                                         'face 'shadow)\n                           \"  \")))\n      (setq index (+ index 2)))\n    time))\n\n(defun agenda-view-month--display (month year column &optional hour-start hour-end with-summary)\n  \"\"\n  (let* ((year (or year (string-to-number (format-time-string \"%Y\"))))\n         (month (or month (string-to-number (format-time-string \"%m\"))))\n         (today (calendar-current-date))\n         (day (list month 1 year))\n         (day (calendar-absolute-from-gregorian day))\n         (day-last (list month (calendar-last-day-of-month month year) year))\n         (day-last (calendar-absolute-from-gregorian day-last))\n         (dates (let ((dates))\n                  (while (<= day day-last)\n                    (push (calendar-gregorian-from-absolute day) dates)\n                    (setq day (1+ day)))\n                  (nreverse dates))))\n    (dolist (date dates)\n      (let* ((ts (encode-time (list 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))\n             (weekday (nth 6 (decode-time ts)))\n             (is-today (equal date today))\n             (is-inweek (string= (format-time-string \"%G-%V\" ts)\n                                 (format-time-string \"%G-%V\")))              \n             (is-monday (eq weekday 1))\n             (is-weekend (memq weekday '(0 6)))\n             (is-first (eq date (car dates))))\n\n        ;; Month header\n        (when is-first\n          (agenda-view--next-line 1 column)\n          (insert \"        \"\n                  (propertize (format \" %s \" (format-time-string \"%B %Y\" ts))\n                              'agena-hl-range t\n                              'face 'bold)\n                  \"  \")\n          (agenda-view--next-line 1 column))\n\n        ;; Time header\n        (when (or is-monday is-first)\n          (agenda-view--next-line 1 column)\n          (insert (propertize (format-time-string \"Week %V \" ts)\n                              'agenda-hl-range t\n                              'face (cond (is-inweek 'bold)\n                                          (t         '(bold shadow))))\n                  \" \"\n                  (propertize (agenda-view-month--display-clock hour-start hour-end)\n                              ;; 'agenda-hl-range t\n                              'face (cond (is-inweek 'default)\n                                          (t         'shadow)))\n                  \"  \")\n          (agenda-view--next-line 1 column))\n\n        ;; Day slots\n        (insert (propertize (format-time-string \" %a %d \" ts)\n                            'agenda-hl-range t\n                            'agenda-date-marker date\n                            'face (cond (is-today   '(:inverse-video t :inherit bold))\n                                        (is-inweek  'default)\n                                        ;; (is-monday  'shadow)\n                                        ;; (is-weekend 'shadow)\n                                        (t          'shadow)))\n                \" \"\n                (agenda-view-month--display-slots date hour-start hour-end with-summary)\n                \"  \")\n        (agenda-view--next-line 1 column)))))\n\n(defun agenda-view-month-1-display (&optional date force)\n  \"Display month agenda for DATE with summary next to each day.\nWhen FORCE is t, force update.\"\n  (interactive)\n  (let* ((date (or date agenda-view-date))\n         (month (nth 0 date))\n         (year (nth 2 date))\n         (hour-start 8)\n         (hour-end  18)\n         (month-col-size\n          (+ 7                                ;; Date prefix\n             (* (- hour-end hour-start -1) 2) ;; Slots\n             5))                              ;; Spacing between months\n         (month (or month\n                   (car agenda-view-month-date)\n                   (string-to-number (format-time-string \"%m\"))))\n         (year (or year\n                   (cdr agenda-view-month-date)\n                   (string-to-number (format-time-string \"%Y\"))))\n         (buffer (get-buffer-create agenda-view-buffer)))\n\n    (save-excursion\n      (agenda-view-month--display month year\n                                  (* 0 month-col-size)\n                                  hour-start hour-end t))\n    (goto-char (point-min))\n    (when-let ((prop (text-property-search-forward 'agenda-date-marker date #'equal)))\n      (goto-char (prop-match-beginning prop)))))\n\n(defun agenda-view-month-3-display (&optional date force)\n  \"Display 3 months agenda for DATE.\nWhen FORCE is t, force update.\"\n  (interactive)\n  (let* ((date (or date agenda-view-date))\n         (month (nth 0 date))\n         (year (nth 2 date))\n         (hour-start 8)\n         (hour-end  18)\n         (month-col-size\n          (+ 7                                ;; Date prefix\n             (* (- hour-end hour-start -1) 2) ;; Slots\n             5)))                             ;; Spacing between months\n    (dolist (index '(0 1 2))\n      (save-excursion\n        (agenda-view-month--display month year\n                                    (* index month-col-size)\n                                    hour-start hour-end)\n        (calendar-increment-month month year 1)))\n    (goto-char (point-min))\n    (when-let ((prop (text-property-search-forward 'agenda-date-marker date #'equal)))\n      (goto-char (prop-match-beginning prop)))))\n\n                         \n(provide 'agenda-view-month)\n;;; agenda-view-month.el ends here\n"
  },
  {
    "path": "agenda-view-week.el",
    "content": ";;; agenda-view-week.el --- Weekly view  -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'cal-iso)\n(require 'agenda-parse)\n(require 'agenda-faces)\n\n(defun agenda-view-week-extent (&optional week year)\n  \"Return timestamp for first & last days of WEEK YEAR.\"\n  (let* ((year (or year (string-to-number (format-time-string \"%Y\"))))\n         (year (or year (string-to-number (format-time-string \"%V\"))))\n         (abs-mon (calendar-iso-to-absolute (list week 1 year)))\n         (mon-greg (calendar-gregorian-from-absolute abs-mon))\n         (sun-greg (calendar-gregorian-from-absolute (+ abs-mon 6))))\n    (cons \n     (encode-time 0 0 0 (nth 1 mon-greg) (nth 0 mon-greg) (nth 2 mon-greg))\n     (encode-time 0 0 0 (nth 1 sun-greg) (nth 0 sun-greg) (nth 2 sun-greg)))))\n\n(defun agenda-view-week--display-title (week year)\n  \"Return WEEK / YEAR string.\"\n  (let* ((week-extent (agenda-view-week-extent week year))\n         (week-start (format-time-string \"%d %B %Y\" (car week-extent)))\n         (week-end (format-time-string \"%d %B %Y\" (cdr week-extent))))\n     (propertize (format \"Year %s, week %02d\\n\" year week) 'face 'agenda-view-title)))\n\n(defun agenda-view-week--display-subtitle (week year)\n  \"Return WEEK / YEAR extend string.\"\n  (let* ((week-extent (agenda-view-week-extent week year))\n         (week-start (format-time-string \"%d %B %Y\" (car week-extent)))\n         (week-end (format-time-string \"%d %B %Y\" (cdr week-extent))))\n    (propertize (format \"%s - %s\\n\" week-start week-end) 'face 'agenda-view-subtitle)))\n\n(defun agenda-view-week--display-date (date)\n  \"Return DATE string for day header.\"\n  (let* ((today-iso (format-time-string \"%Y-%m-%d\"))\n         (date-ts (encode-time (list 0 0 0 (nth 2 date) (nth 1 date) (nth 0 date))))\n         (date-iso (format-time-string \"%Y-%m-%d\" date-ts))\n         (date-str (format-time-string \"%A %d %B %Y\" date-ts)))\n    (concat (propertize date-str\n                        'agenda-hl-range t\n                        'face 'agenda-view-date\n                        )\n            (if (string= date-iso today-iso) \n                (propertize \" (today)\\n\\n\" 'face 'agenda-view-date-today)\n              \"\\n\\n\"))))\n\n(defun agenda-view-week--display-entry (entry &optional time-str)\n  \"Return ENTRY string, optionally with time replaced by TIME-STR.\"\n  (let* ((today-iso (format-time-string \"%Y-%m-%d\"))\n         (date-iso (agenda-entry-date-string entry \"%Y-%m-%d\"))\n         (time-start-hm (agenda-entry-time-start-string entry))\n         (time-end-hm (agenda-entry-time-end-string entry))\n         (data (cdr (assoc 'data entry)))\n         (url (cdr (assoc 'url data)))\n         (title (cdr (assoc 'title entry)))\n         (title (if url\n                    (agenda-url-button-string title url)\n                  title))\n        (actions (agenda-entry-actions-string entry))\n        (tags (agenda-entry-tags-string entry))                       \n        (marker (cdr (assoc 'marker entry)))\n        (line-face (if (agenda-entry-cancel-p entry)\n                       'agenda-view-cancel\n                     nil))\n        (time-face (cond ((agenda-entry-now-p entry)\n                          'agenda-view-time-now)\n                         ((agenda-entry-today-p entry)\n                          'agenda-view-time-today)))\n        (time-str (if time-str\n                      (format \" %11s \" time-str)\n                    (propertize\n                     (cond ((and time-start-hm time-end-hm)\n                            (format \" %s-%s \" time-start-hm time-end-hm))\n                           (time-start-hm\n                            (format \" %s       \" time-start-hm))\n                           (t\n                            \" ----------- \"))\n                     'agenda-hl-range t\n                     'face (or time-face line-face)))))\n    (propertize\n     (concat  \"  \" time-str\n              \" \"  title\n              (when actions\n                (concat \" \" (propertize actions 'face (or line-face 'agenda-edit-action))))\n              (when tags\n                (concat \" \" (propertize tags 'face (or line-face 'agenda-edit-tag))))\n              \"\\n\")\n     'agenda-entry-marker marker)))\n\n(defun agenda-view-week-display (&optional date force)\n  \"Display the agenda for DATE.\nWhen FORCE is t, force update\"\n  (interactive)\n  (let* ((date (or date agenda-view-date))\n         (month (nth 0 date))\n         (day (nth 1 date))\n         (year (nth 2 date))\n         (week (car (calendar-iso-from-absolute\n                     (calendar-absolute-from-gregorian date))))\n         (today (format-time-string \"%Y-%m-%d\"))\n         (now (format-time-string \"%H:%M\"))\n         (point-first nil)\n         (point-date nil)\n         (buffer (get-buffer-create agenda-view-buffer))\n         \n         ;; Entries (filtered by week/year)\n         (entries (agenda-filter-entries \n                   (lambda (entry week year)\n                     (and (not (agenda-entry-cancel-p entry))\n                          (agenda-entry-inweek-p entry week year)))\n                   week year))\n    \n         ;; Birthdays (filtered by week and post-processed)\n         (birthdays (agenda-filter-entries \n                     (lambda (entry week year)\n                       (and (not (agenda-entry-cancel-p entry))\n                            (agenda-entry-birthday-p entry week)))\n                     week year))\n         (birthdays (agenda-view--process-birthdays birthdays year))\n\n         ;; Deadlines (future only)\n         (deadlines (agenda-filter-entries \n                     (lambda (entry week year)\n                       (and (not (agenda-entry-cancel-p entry))\n                            (not (agenda-entry-done-p entry))\n                            (agenda-entry-deadline-p entry)))\n                     week year))\n         (entries (sort (append entries birthdays) #'agenda-entry-less-p)))\n    \n    (insert (agenda-view-week--display-title week year)\n            (agenda-view-week--display-subtitle week year))\n\n    ;; Entries and birthdays\n    (let ((current-date nil))\n      (dolist (entry entries)\n        (let* ((entry-date (cdr (assoc 'date entry)))\n               (cal-date (list (nth 1 entry-date) (nth 2 entry-date) (nth 0 entry-date))))\n          (unless (equal entry-date current-date)\n            (insert \"\\n\" (agenda-view-week--display-date entry-date))\n            (setq current-date entry-date))\n          (when (and (not point-date) (equal cal-date date))\n            (setq point-date (line-beginning-position)))\n          (unless point-first\n            (setq point-first (line-beginning-position)))\n          (insert (propertize (agenda-view-week--display-entry entry)\n                              'agenda-date-marker cal-date)))))\n\n    ;; Future deadlines\n    (when (> (length deadlines) 0)\n      (insert (propertize \"\\nUpcoming deadlines\\n\\n\" 'face 'agenda-view-date))\n      (dolist (entry deadlines)\n        (let* ((date (cdr (assoc 'date entry)))\n               (time (encode-time (list 0 0 0 (nth 2 date) (nth 1 date) (nth 0 date))))\n               (days (- (time-to-days time)\n                        (time-to-days (current-time))))\n               (face (agenda-view--deadline-face days))\n               (time-str (propertize (format \" In %2d days \" days)\n                                     'agenda-hl-range t\n                                     'face face)))\n          (when (<= days 30)\n            (insert (propertize (agenda-view-week--display-entry entry time-str)\n                                'agenda-date-marker date))))))\n    (goto-char (or point-date point-first (point-min)))))\n\n(provide 'agenda-view-week)\n;;; agenda-view-week.el ends here\n"
  },
  {
    "path": "agenda-view-year.el",
    "content": ";;; agenda-view-year.el --- Yearly view  -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'cal-iso)\n(require 'agenda-parse)\n(require 'agenda-faces)\n\n(defvar agenda-view-year--layout '(3 . 4)\n  \"Year view calendar layout as (ROWS . COLS).\")\n\n(defun agenda-view-year-display (&optional date force layout)\n  \"Display a grid of months for YEAR based on LAYOUT (rows . cols).\nDefault LAYOUT is (3 . 4). Each month is 24 columns wide and 10 rows high.\"\n  (let* ((date (or date agenda-view-date))\n         (year (nth 2 date))\n         (month (nth 0 date))\n         (day  (nth 1 date))\n         (layout (or layout '(3 . 4)))\n         (rows (car layout))\n         (cols (cdr layout)))\n    (setq agenda-view-year--layout layout)\n    (dotimes (row rows)\n      (let ((months nil))\n        (dotimes (col cols)\n          (let* ((month-index  (+ 1 (* row cols) col))\n                 (month-string (agenda-view-calendar (list month-index day year) \n                                                    (eq month-index month) \n                                                    force)))\n            (push (split-string month-string \"\\n\" t) months)))\n        (setq months (nreverse months))\n        (dotimes (line 10)\n          (dolist (month-lines months)\n            (insert (nth line month-lines) \" \"))\n          (insert \"\\n\"))))\n    (goto-char (point-min))\n    (when-let ((prop (text-property-search-forward 'agenda-date-marker date #'equal)))\n      (goto-char (prop-match-beginning prop)))))\n\n(defun agenda-view-year-display-auto (&optional date force)\n  \"Calculate the best (rows . cols) layout based on window width.\"\n  (let* ((width (window-width))\n         ;; Each month is 24 chars + 1 char space = 25\n         (max-cols (max 1 (/ width 25)))\n         (cols (cond ((>= max-cols 12) 12)\n                     ((>= max-cols 6)  6)\n                     ((>= max-cols 4)  4)\n                     ((>= max-cols 3)  3)\n                     ((>= max-cols 2)  2)\n                     (t 1)))\n         (rows (/ 12 cols))\n         (layout (cons rows cols)))\n    (agenda-view-year-display date force layout)))\n\n(provide 'agenda-view-year)\n;;; agenda-view-year.el ends here\n"
  },
  {
    "path": "agenda-view.el",
    "content": ";;; agenda-view.el --- Agenda view -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Code:\n(require 'agenda-parse)\n(require 'agenda-faces)\n(require 'agenda-utils)\n(require 'agenda-view-day)\n(require 'agenda-view-week)\n(require 'agenda-view-month)\n(require 'agenda-view-year)\n\n(defvar agenda-view-date nil\n  \"Date currently displayed.\")\n\n(defvar agenda-view-unit 'day\n  \"Unit view (day, week, month, month-3 or year.\")\n\n(defun agenda-view--process-birthdays (entries year &optional month)\n  \"Return a new list of ENTRIES with updated date and title related tp YEAR\nand MONTH.\"\n  (mapcar (lambda (entry)\n            (let* ((birth-date (cdr (assoc 'date entry)))\n                   (birth-year (car birth-date))\n                   (age (- year birth-year))\n                   (new-date (list year (nth 1 birth-date) (nth 2 birth-date)))\n                   (old-title (cdr (assoc 'title entry)))\n                   (new-title (concat (agenda-mark 'birthday)\n                                      \" \"\n                                      (format old-title age)))\n                   (new-entry (assq-delete-all 'date\n                                  (assq-delete-all 'title\n                                      (copy-sequence entry)))))\n              (cons (cons 'date new-date)\n                    (cons (cons 'title new-title)\n                          new-entry)))) \n          entries))\n\n(defun agenda-view--deadline-face (days)\n  \"Return face for deadline (=slot).\"\n    (let ((face 'default))\n      (catch 'found\n        (dolist (deadline agenda-deadline-faces)\n          (let* ((deadline-days (car deadline))\n                 (deadline-face (cdr deadline)))\n            (unless (< deadline-days days)\n              (setq face deadline-face)\n              (throw 'found face)))))\n    face))\n\n(defun agenda-view--next-line (&optional n column)\n  \"Move point forward ? line at specified column.\"\n  (dotimes (i (or n 1))\n    (if (eobp) (newline) (forward-line 1)))\n  (move-to-column (or column 24) t))\n\n(defun agenda-view--display-summary (slots)\n  \"Given a list of slots, return a single line summary of entries.\"\n\n  (let ((summaries)\n        (entries (nreverse (seq-uniq (seq-mapcat #'identity slots)))))\n    (dolist (entry entries)\n      (let* ((time (cdr (assoc 'time-start entry)))\n             (title (cdr (assoc 'title entry)))\n             (data (cdr (assoc 'data entry)))\n             (summary (if time\n                          (concat\n                           (propertize (format \"%02d:%02d\" (nth 0 time) (nth 1 time))\n                                       'face 'bold)\n                           \" \"\n                           title)\n                        title)))\n        (push summary summaries)))\n    (mapconcat #'identity summaries \" \")))\n\n(defvar agenda-view--calendar-cache (make-hash-table :test 'equal)\n  \"Cache for agenda calendar strings. Key is (month year active).\")\n\n(defun agenda-view-calendar (date &optional active force)\n  \"Generate a calendar representation for DATE (month day year).\nUses a cache based on month, year, and ACTIVE status unless FORCE is non-nil.\"\n  (let* ((month (nth 0 date))\n         (day (nth 1 date))\n         (year (nth 2 date))\n         (cache-key (list month year active))\n         (cache-val (gethash cache-key agenda-view--calendar-cache)))\n    \n    (if (and (not force) cache-val)\n        cache-val\n      (let* ((first (list month 1 year))\n             (first-day (calendar-absolute-from-gregorian first))\n             (first-mon (- first-day (mod (+ (calendar-day-of-week first) 6) 7)))\n             (header (format \"%s %d\" (calendar-month-name month) year))\n             (spaces (- 20 (length header)))\n             (face (if (not active) 'shadow nil))\n             (calendar nil))\n        (push (concat (propertize\n                       (concat (make-string (/ spaces 2) ?\\s)\n                               header\n                               (make-string (- spaces (/ spaces 2)) ?\\s))\n                       'face `(:inverse-video t :inherit (,face bold)))\n                      \" \") calendar)\n        (push (concat (propertize \"Mo Tu We Th Fr \" 'face `(bold ,face))\n                      (propertize \"Sa Su \"'face face)) calendar)\n        (dotimes (i 6)\n          (let ((line \"\"))\n            (dotimes (j 7)\n              (let* ((index (+ (* i 7) j))\n                     (day-date (calendar-gregorian-from-absolute (+ first-mon index)))                     \n                     (is-today (and (eq (nth 1 day-date) day)\n                                    (eq (nth 0 day-date) month)))\n                     (is-month (eq (nth 0 day-date) month))\n                     (is-weekend (memq (calendar-day-of-week day-date) '(0 6)))\n                     (slots (agenda-collect-slots day-date))\n                     (entries (seq-find #'identity slots))\n                     (has-deadline (seq-some\n                                    (lambda (entry)\n                                      (member \"DEADLINE\" (cdr (assoc 'tags entry))))\n                                    entries))\n                     ;; FIXME: Does that work a slot has several entries?\n                     (first-entry (car entries))\n                     (marker (cdr (assoc 'marker first-entry)))\n                     (help (agenda-view--display-summary slots))\n                     (total (/ (seq-count #'identity slots) 2))\n                     (palette agenda-calendar-palette)\n                     (total (min total (length palette)))\n                     (face (cond\n;;                            ((and is-month has-deadline)\n  ;;                           '(:background \"#FFFF00\" :foreground \"#000000\"))\n                            ((and is-month (> total 0))\n                             `( :inherit ,(if has-deadline 'bold 'default)\n                                :foreground ,(car (nth total palette))\n                                :background ,(cdr (nth total palette))))\n                            ((and is-month is-weekend)\n                             '(:inherit shadow))))\n                     (day (if is-month\n                              (if has-deadline\n                                  (format \"%2d%s\" (nth 1 day-date) (agenda-mark 'deadline))\n                                (format \"%2d \" (nth 1 day-date)))                            \n                            \"   \")))\n                (setq line (concat line\n                                   (propertize day\n                                               'agenda-entry-marker marker\n                                               'agenda-date-marker (when is-month day-date)\n                                               'help-echo help\n                                               'face face)))))\n            (push line calendar)))\n        (let ((result (concat\n                       (propertize  \"┌──────────────────────┐\\n\" 'face face)\n                       (mapconcat (lambda (line)\n                                    (concat (propertize \"│ \" 'face face)\n                                            line\n                                            (propertize \"│\" 'face face)))\n                                  (reverse calendar) \"\\n\")\n                       (propertize \"\\n└──────────────────────┘\\n\" 'face face))))\n          (puthash cache-key result agenda-view--calendar-cache)\n          result)))))\n\n(defun agenda-view-refresh ()\n  \"Refresh the current view with forced update.\"\n  (interactive)\n  (agenda-view nil nil t))\n\n(defun agenda-view-goto-today ()\n  \"Jump to the current week.\"\n  (interactive)\n  (agenda-view (calendar-current-date)))\n\n(defun agenda-view-goto-date ()\n  \"Select a date via calendar and open the view for that week.\"\n  (interactive)\n  (agenda-with-calendar-select date\n    (agenda-view date)))\n\n(defun agenda-view-goto-next ()\n  \"Go to the next week.\"\n  (interactive)\n  (let ((date (agenda-date-forward agenda-view-date +1 agenda-view-unit)))\n    (agenda-view date)))\n\n(defun agenda-view-goto-prev ()\n  \"Go to the next week.\"\n  (interactive)\n  (let ((date (agenda-date-forward agenda-view-date -1 agenda-view-unit)))\n    (agenda-view date)))\n\n(defun agenda-view-goto-date-at-point ()\n  \"Select a date via calendar and open the view for that week.\"\n  (interactive)\n  (when-let* ((date (get-text-property (point) 'agenda-date-marker)))\n    (agenda-view date)))\n\n(defun agenda-view-goto-up ()\n  (interactive)\n  (if-let* ((date (get-text-property (point) 'agenda-date-marker)))\n      (cond ((memq agenda-view-unit '(day year))\n             (agenda-view (agenda-date-forward date -7 'day)))\n            ((memq agenda-view-unit '(month month-3))\n             (when-let* ((date-prev (agenda-date-forward date -1 'day))\n                         (prop (save-excursion\n                                 (goto-char (point-min))\n                                 (text-property-search-forward 'agenda-date-marker\n                                                               date-prev t))))\n               (goto-char (prop-match-beginning prop))))\n            ((memq agenda-view-unit '(week))\n             (when-let* ((prop (save-excursion\n                                 (text-property-search-backward 'agenda-date-marker))))\n               (goto-char (prop-match-beginning prop))))             \n            (t (call-interactively #'previous-line)))\n    (call-interactively #'previous-line)))\n\n(defun agenda-view-goto-down ()\n  (interactive)\n  (if-let* ((date (get-text-property (point) 'agenda-date-marker)))\n      (cond ((memq agenda-view-unit '(day year))\n             (agenda-view (agenda-date-forward date +7 'day)))\n            ((memq agenda-view-unit '(month month-3))\n             (when-let* ((date-prev (agenda-date-forward date +1 'day))\n                         (prop (save-excursion\n                                 (goto-char (point-min))\n                                 (text-property-search-forward 'agenda-date-marker\n                                                               date-prev t))))\n               (goto-char (prop-match-beginning prop))))\n            ((memq agenda-view-unit '(week))\n             (when-let* ((prop (save-excursion\n                                 (text-property-search-forward 'agenda-date-marker nil nil t))))\n               (goto-char (prop-match-beginning prop))))\n            (t (call-interactively #'next-line)))\n    (call-interactively #'next-line)))\n\n(defun agenda-view-goto-left ()\n  (interactive)\n  (if-let* ((date (get-text-property (point) 'agenda-date-marker)))\n      (cond ((memq agenda-view-unit '(day year))\n             (agenda-view (agenda-date-forward date -1 'day)))\n            ((memq agenda-view-unit '(month month-3))\n             (if-let* ((date-prev (agenda-date-forward date -1 'month))\n                       (prop (save-excursion\n                               (goto-char (point-min))\n                               (text-property-search-forward 'agenda-date-marker\n                                                             date-prev t))))\n                 (goto-char (prop-match-beginning prop))\n               (call-interactively #'left-char)))\n            (t   (call-interactively #'left-char)))\n    (call-interactively #'left-char)))\n\n(defun agenda-view-goto-right ()\n  (interactive)\n  (if-let* ((date (get-text-property (point) 'agenda-date-marker)))\n      (cond ((memq agenda-view-unit '(day year))\n             (agenda-view (agenda-date-forward date +1 'day)))\n            ((memq agenda-view-unit '(month month-3))\n             (if-let* ((date-prev (agenda-date-forward date +1 'month))\n                         (prop (save-excursion\n                                 (goto-char (point-min))\n                                 (text-property-search-forward 'agenda-date-marker\n                                                               date-prev t))))\n                 (goto-char (prop-match-beginning prop))\n               (call-interactively #'right-char)))\n            (t (call-interactively #'right-char)))\n    (call-interactively #'right-char)))\n\n(defun agenda-view-goto-shift-left ()\n  (interactive)\n  (if-let* ((date (and (memq agenda-view-unit '(day year month))\n                       agenda-view-date)))\n      (agenda-view (agenda-date-forward date -1 'month))\n    (call-interactively #'left-char)))\n\n(defun agenda-view-goto-shift-right ()\n  (interactive)\n  (if-let* ((date (and (memq agenda-view-unit '(day year month))\n                       agenda-view-date)))\n      (agenda-view (agenda-date-forward date +1 'month))\n    (call-interactively #'right-char)))\n\n(defun agenda-view-goto-shift-up ()\n  (interactive)\n  (if-let* ((date (and (memq agenda-view-unit '(year))\n                       agenda-view-date)))\n      (agenda-view (agenda-date-forward date (- (cdr agenda-view-year--layout)) 'month))\n    (call-interactively #'previous-line)))\n\n(defun agenda-view-goto-shift-down ()\n  (interactive)\n  (if-let* ((date (and (memq agenda-view-unit '(year))\n                       agenda-view-date)))\n      (agenda-view (agenda-date-forward date (cdr agenda-view-year--layout) 'month))\n    (call-interactively #'next-line)))\n\n(defun agenda-view-goto-entry ()\n  \"Jump to the source line of the entry at point or to the closest date if\nno entry at point. When in year mode, switch to week mode instead.\"\n  (interactive)  \n  (let* ((marker (get-text-property (point) 'agenda-entry-marker))\n         (date (get-text-property (point) 'agenda-date-marker)))\n    (cond ((eq agenda-view-unit 'year)\n           (agenda-view-week))\n\n          (marker\n           (pop-to-buffer (marker-buffer marker))\n           (agenda-filter \"\")\n           (goto-char (marker-position marker))\n           (agenda-highlight (line-beginning-position)\n                             (line-end-position))\n           (recenter))\n          \n          (date\n           (pop-to-buffer (agenda-source-buffer))\n           (agenda-filter \"\")\n           (remove-text-properties (point-min) (point-max) '(invisible nil))\n           (agenda--goto-date date)\n           (agenda-highlight (line-beginning-position)\n                             (line-end-position))\n           (recenter)))))\n\n(defun agenda-view-day (&optional date force)\n  \"Display the agenda for DATE in day mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (agenda-view date 'day force))\n\n(defun agenda-view-week (&optional date force)\n  \"Display the agenda for DATE in week mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (agenda-view date 'week force))\n\n(defun agenda-view-month-1 (&optional date force)\n  \"Display the agenda for DATE in month mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (agenda-view date 'month force))\n\n(defun agenda-view-month-3 (&optional date force)\n  \"Display the agenda for DATE in 3 months mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (agenda-view date 'month-3 force))\n\n(defun agenda-view-year (&optional date force)\n  \"Display the agenda for DATE in year mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (agenda-view date 'year force))\n\n(defun agenda-view-capture (&optional with-data)\n  \"Capture a new entry using date at point (if any).\"\n  (interactive \"P\")\n  (when-let ((date (or (get-text-property (point) 'agenda-date-marker)\n                       (agenda-view-date)\n                       (calendar-current-date))))\n    (agenda-capture date with-data)))\n\n(defun agenda-view (&optional date unit force)\n  \"Display the agenda for DATE in UNIT mode.\nWhen FORCE is t, force update from source.\"\n  (interactive)\n  (let* ((buffer (get-buffer-create agenda-view-buffer))\n         (date (or date\n                   agenda-view-date\n                   (calendar-current-date)))\n         (unit (or unit agenda-view-unit 'day)))\n    (setq agenda-view-date date)\n    (setq agenda-view-unit unit)\n    (if (memq agenda-view-unit '(week month month-3))\n        (hl-line-mode 1)\n      (hl-line-mode -1))      \n    (setq-local hl-line-range-function #'agenda-view--hl-line-range)\n    (with-current-buffer buffer\n      (let ((inhibit-read-only t))\n        (erase-buffer)\n        (cond ((eq unit 'day)     (agenda-view-day-display nil force))\n              ((eq unit 'week)    (agenda-view-week-display nil force))\n              ((eq unit 'month)   (agenda-view-month-1-display nil force))\n              ((eq unit 'month-3) (agenda-view-month-3-display nil force))\n              ((eq unit 'year)    (agenda-view-year-display-auto nil force))\n              (t (error (format \"Unknown view mode (%s)\" unit))))\n        (set-buffer-modified-p nil)\n        (unless (derived-mode-p 'agenda-view-mode)\n          (agenda-view-mode))\n        (setq mode-name (concat \"Agenda View: \"\n                                (cond ((eq agenda-view-unit 'day)     \"Day\")\n                                      ((eq agenda-view-unit 'week)    \"Week\")\n                                      ((eq agenda-view-unit 'month)   \"Month\")\n                                      ((eq agenda-view-unit 'month-3) \"3 Months\")\n                                      ((eq agenda-view-unit 'year)    \"Year\"))))\n        (pop-to-buffer buffer)))))\n\n(defvar agenda-view-mode-map\n  (let ((map (make-sparse-keymap)))\n    (define-key map (kbd \"RET\")       #'agenda-view-goto-entry)\n    (define-key map (kbd \"TAB\")       #'agenda-view-goto-entry)\n    (define-key map (kbd \"<mouse-1>\") #'agenda-view-goto-date-at-point)\n    (define-key map (kbd \"c\")         #'agenda-view-capture)\n    (define-key map (kbd \"r\")         #'agenda-view-refresh)\n    (define-key map (kbd \"C-l\")       #'agenda-view-refresh)\n    (define-key map (kbd \"e\")         #'agenda-export)\n    (define-key map (kbd \"d\")         #'agenda-view-day)\n    (define-key map (kbd \"w\")         #'agenda-view-week)\n    (define-key map (kbd \"m\")         #'agenda-view-month-1)\n    (define-key map (kbd \"t\")         #'agenda-view-month-3)\n    (define-key map (kbd \"y\")         #'agenda-view-year)    \n    (define-key map (kbd \"g\")         #'agenda-view-goto-date)\n    (define-key map (kbd \".\")         #'agenda-view-goto-today)\n\n    (define-key map (kbd \"<left>\")    #'agenda-view-goto-left)\n    (define-key map (kbd \"<right>\")   #'agenda-view-goto-right)\n    (define-key map (kbd \"<up>\")      #'agenda-view-goto-up)\n    (define-key map (kbd \"<down>\")    #'agenda-view-goto-down)\n    (define-key map (kbd \"S-<left>\")  #'agenda-view-goto-shift-left)\n    (define-key map (kbd \"S-<right>\") #'agenda-view-goto-shift-right)\n    (define-key map (kbd \"S-<up>\")    #'agenda-view-goto-shift-up)\n    (define-key map (kbd \"S-<down>\")  #'agenda-view-goto-shift-down)\n\n    (define-key map (kbd \"f\")         #'agenda-view-goto-next)\n    (define-key map (kbd \"n\")         #'agenda-view-goto-next)\n    (define-key map (kbd \"b\")         #'agenda-view-goto-prev)\n    (define-key map (kbd \"p\")         #'agenda-view-goto-prev)\n    map)\n  \"Keymap for `agenda-view-mode'.\")\n\n(defun agenda-view--hl-line-range ()\n  \"Restrict line highlight to some parts of the line.\n Each view mode defines relevant range as 'agenda-hl-range'.\"\n  (save-excursion\n    (save-restriction\n      (save-match-data\n        (let* ((prop 'agenda-hl-range)\n               (val t)\n               (lbp (line-beginning-position))\n               (lep (line-end-position))\n               beg end)\n          ;; Restrict all buffer operations to just this line\n          (narrow-to-region lbp lep)\n          (cond\n           ;; 1. Check if point is already ON the property\n           ((eq (get-text-property (point) prop) val)\n            (setq beg (previous-single-property-change\n                       (min (1+ (point)) (point-max)) prop nil lbp)\n                end (next-single-property-change (point) prop nil lep)))         \n           ;; 2. BACKWARD search: Only if NOT at the very start of the line\n           ((and (> (point) lbp)\n                 (let ((match (text-property-search-backward prop val t)))\n                   (when (and match (>= (prop-match-beginning match) lbp))\n                     (setq beg (prop-match-beginning match)\n                           end (prop-match-end match))\n                     t)))) ; Return t to break the cond\n           ;; 3. FORWARD search: Look ahead within the same line\n           (t\n            (let ((match-fwd (text-property-search-forward prop val t)))\n              (when (and match-fwd (< (prop-match-beginning match-fwd) lep))\n                (setq beg (prop-match-beginning match-fwd)\n                      end (prop-match-end match-fwd))))))\n      (cons (or beg lbp) (or end lep)))))))\n\n(define-derived-mode agenda-view-mode special-mode \"Agenda view\"\n  \"Major mode for displaying the agenda dashboard.\"\n  (setq truncate-lines t)\n  (hl-line-mode 1)\n  (setq-local hl-line-range-function #'agenda-view--hl-line-range)\n  (face-remap-add-relative 'hl-line 'nano-salient-h)\n  (add-hook 'post-command-hook (lambda ()\n                                 (let ((message-log-max nil))\n                                   (display-local-help t)) nil t)))\n\n(provide 'agenda-view)\n;;; agenda-view.el ends here\n"
  },
  {
    "path": "agenda.el",
    "content": ";;; agenda.el --- A fast & simple text-based agenda -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2026 Nicolas P. Rougier\n\n;; Author: Nicolas P. Rougier <nicolas.rougier@inria.fr>\n;; URL: https://github.com/rougier/agenda\n;; Version: 0.1.0\n;; Package-Requires: ((emacs \"27.1\"))\n;; Keywords: calendar, agenda, convenience\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; For a full copy of the GNU General Public License\n;; see <https://www.gnu.org/licenses/>.\n\n;;; Commentary:\n\n;; This package provides a fast, lightweight agenda system based on a\n;; simple text file format. It provides an edit mode, to ease entering\n;; information and a view mode to render the agenda for day, week,\n;; month, 3 months or year.\n;;\n;; The project is structured into several sub-modules:\n;;   - agenda-faces.el          : Faces definition\n;;   - agenda-parse.el          : Parsing and test functions\n;;   - agenda-utils.el          : Various utility functions\n;;   - agenda-edit.el           : Minor edit mode\n;;   - agenda-view.el           : Major view mode\n;;     - agenda-view-day.el     : Day view\n;;     - agenda-view-week.el    : Week view\n;;     - agenda-view-month.el   : Single month and 3 months view\n;;     - agenda-view-year.el    : Year view\n;;   - agenda-export.el         ; Export functions (ical)\n;;   - agenda-capture.el        : Capture functions\n\n;; Note on date formats:\n;;  - Calendar format is (month day year)\n;;  - Agenda entry format is (year month day)\n;;  - Timestamp format is (second minute hour day month year)\n;;  - ISO commercial format is (week weekday year)\n\n;; It is important to distinguish between two modes:\n;; - agenda-edit-mode: For the editing the source file \n;; - agenda-view-mode: For the viewing the agenda\n\n;;; Code:\n(require 'cal-iso)\n(require 'calendar)\n(require 'agenda-faces)\n(require 'agenda-parse)\n(require 'agenda-utils)\n(require 'agenda-view)\n(require 'agenda-edit)\n(require 'agenda-export)\n(require 'agenda-capture)\n\n(defcustom agenda-file (expand-file-name \"agenda.txt\" user-emacs-directory)\n  \"Agenda file\"\n  :group 'agenda\n  :type 'file)\n\n(defcustom agenda-file-ical-public \"~/.calendars/Public.ics\"\n  \"Agenda export filename for public agenda (personal information stripped).\"\n  :group 'agenda\n  :type 'file)\n\n(defcustom agenda-file-ical-private \"~/.calendars/Private.ics\"\n  \"Agenda export filename for public agenda (personal information visible).\"\n  :group 'agenda\n  :type 'file)\n\n(defconst agenda-view-buffer \"*agenda*\"\n  \"Name of the agenda view buffer\")\n\n(defvar agenda--highlight-overlay nil\n  \"Overlay used for transient highlighting.\")\n\n(defcustom agenda-marks '((inweek   . \"○\")\n                          (today    . \"●\")\n                          (cancel   . \"\")\n                          (capture  . \" \") \n                          (birthday . \"󰃫\")\n                          (conflict . \"*\")\n                          (deadline . \"!\"))\n  \"List of margin marks.\"\n  :group 'agenda\n  :type '(alist :key-type (symbol :tag \"State\")\n                :value-type (string :tag \"Mark\")))\n\n(defcustom agenda-slot-faces\n  '((\"DEADLINE\"       . agenda-slot-deadline)\n    (\"PERSONAL\\\\|HOME\" . agenda-slot-personal))\n  \"Mapping of tag to faces.\"\n  :type '(alist :key-type (string :tag \"Tags filter\")\n                :value-type (face :tag \"Face\"))\n  :group 'agenda)\n\n(defcustom agenda-deadline-faces\n  '(( 0 . agenda-deadline-0)\n    ( 7 . agenda-deadline-1)    \n    (15 . agenda-deadline-2)\n    (30 . agenda-deadline-3))\n  \"Mapping of days to deadlines faces (view week mode).\"\n  :type '(alist :key-type (integer :tag \"Number of days\")\n                :value-type (face :tag \"Face\"))\n  :group 'agenda)\n\n(defcustom agenda-calendar-palette\n  (let* ((black (face-foreground 'default nil 'default))\n         (white (face-background 'default nil 'default)))\n    (list (cons black white)       ;; Base entry\n          ;; Material deep orange shades\n          (cons black \"#FBE9E7\")   ;; 50\n          (cons black \"#FFCCBC\")   ;; 100\n          (cons black \"#FFAB91\")   ;; 200\n          (cons black \"#FF8A65\")   ;; 300\n          (cons black \"#FF7043\")   ;; 400\n          (cons white \"#FF5722\")   ;; 500\n          (cons white \"#F4511E\")   ;; 600\n          (cons white \"#E64A19\")   ;; 700\n          (cons white \"#D84315\")   ;; 800\n          (cons white \"#BF360C\"))) ;; 900  \n  \"List of (FG . BG) color pairs for calendar highlighting.\nThe first entry is a base (foreground . background) pair using the default Emacs\ncolors. Subsequent entries correspond to the standard Deep Orange shades (50–900),\nwith foreground chosen for readability (black on light backgrounds, white on dark).\"\n  :type '(repeat (cons color color))\n  :group 'nano-agenda)\n\n;; Installing agenda-mode for the agenda-file\n(add-to-list 'auto-mode-alist (cons agenda-file 'agenda-edit-mode))\n\n;;;###autoload\n(defun agenda (&optional empty-cache)\n  \"Invalidate all caches if EMPTY-CACHE is t and popup the agenda.\"  \n  (interactive)\n  (unless (and agenda-file (file-exists-p agenda-file))\n    (error \"Agenda file not found: %s. \" agenda-file))\n  (setq agenda-source-buffer (find-file-noselect agenda-file))\n  (with-current-buffer agenda-source-buffer\n    (when empty-cache\n      (setq agenda--entries-cache nil\n            agenda--uids-cache nil\n            agenda--slots-cache nil)\n      (when agenda-view--calendar-cache\n        (clrhash agenda-view--calendar-cache)))\n    (agenda-edit-mode)\n    (agenda-parse-buffer)\n    (agenda-view)))\n\n(bind-key (kbd \"M-a\") #'agenda)\n(bind-key (kbd \"M-c\") #'agenda-capture-with-calendar)\n\n(provide 'agenda)\n;;; agenda.el ends here\n"
  },
  {
    "path": "agenda.sh",
    "content": "#!/bin/bash\n\n# Configuration: Define your agenda source file here\nAGENDA_FILE=\"/Users/rougier/.nano.d/agenda.txt\"\n\n# Clear the terminal screen for a clean workspace\nclear\n\n# Get current year and ISO week number for filtering\nYEAR=$(date +%Y)\nWEEK=$(date +w%V)\nTODAY=$(date +%Y-%m-%d)\n\n# Regex Breakdown\nre=\"^([0-9]{4}-[0-9]{2}-[0-9]{2}( [wW][0-9]+)?( [[:alpha:]]+)?)\"\nre+=\"[[:space:]]+([0-9]{2}:[0-9]{2}(-[0-9]{2}:[0-9]{2})?)?\"\nre+=\"([[:space:]]+-+)*[[:space:]]+\"\nre+=\"([^@+\\[]+[^@+\\[[:space:]])\"\nre+=\"[[:space:]]*((@[^[:space:]+\\[]+[[:space:]]*)*)\"\nre+=\"[[:space:]]*(([+][^[:space:]\\[]+[[:space:]]*)*)\"\nre+=\"[[:space:]]*(\\[([[:alnum:]]+)\\])?$\"\n\n# UI Styling Constants\nBOLD=\"\\033[1m\"\nSTRIKE=\"\\033[9m\"              # ANSI Strikethrough\nBRIGHT_RED=\"\\033[91m\"         # For @ACTIONS\nLIGHT_GRAY=\"\\033[38;5;250m\"   # For +TAGS\nRESET=\"\\033[0m\"\n\ncurrent_date_header=\"\"\n\nif [[ -f \"$AGENDA_FILE\" ]]; then\n    # Filter for week, then SORT alphabetically (chronological by date/time)\n    grep \"^${YEAR}.*${WEEK}\" \"$AGENDA_FILE\" | sort | while read -r line; do\n        \n        if [[ $line =~ $re ]]; then\n            iso_date=\"${BASH_REMATCH[1]:0:10}\"\n            time_str=\"${BASH_REMATCH[4]:-           }\"\n            title=\"${BASH_REMATCH[7]}\"\n            \n            actions=\"${BASH_REMATCH[8]}\"\n            actions=\"${actions#\"${actions%%[![:space:]]*}\"}\" \n            actions=\"${actions%\"${actions##*[![:space:]]}\"}\" \n            \n            tags=\"${BASH_REMATCH[10]}\"\n            tags=\"${tags#\"${tags%%[![:space:]]*}\"}\"\n            tags=\"${tags%\"${tags##*[![:space:]]}\"}\"\n\n            # --- STRIKETHROUGH LOGIC ---\n            # Check if +CANCEL exists in the tags string\n            line_style=\"\"\n            if [[ \"$tags\" == *\"+CANCEL\"* ]]; then\n                line_style=\"$STRIKE\"\n            fi\n\n            # Date Header Logic\n            if [[ \"$iso_date\" != \"$current_date_header\" ]]; then\n                [[ -n \"$current_date_header\" ]] && printf \"\\n\"\n                \n                pretty_date=$(date -j -f \"%Y-%m-%d\" \"$iso_date\" +\"%A %d %B %Y\" 2>/dev/null || \\\n                              date -d \"$iso_date\" +\"%A %d %B %Y\" 2>/dev/null)\n                \n                if [[ \"$iso_date\" == \"$TODAY\" ]]; then\n                    printf \"${BOLD}%s${RESET} (today)\\n\\n\" \"${pretty_date:-$iso_date}\"\n                else\n                    printf \"${BOLD}%s${RESET}\\n\\n\" \"${pretty_date:-$iso_date}\"\n                fi\n                current_date_header=\"$iso_date\"\n            fi\n\n            # Print the line using the line_style (Empty or Strikethrough)\n            printf \"    ${line_style}%s  %s${RESET}\" \"$time_str\" \"$title\"\n\n            if [[ -n \"$actions\" ]]; then\n                printf \" ${BRIGHT_RED}%s${RESET}\" \"$actions\"\n            fi\n\n            if [[ -n \"$tags\" ]]; then\n                printf \" ${LIGHT_GRAY}%s${RESET}\" \"$tags\"\n            fi\n\n            printf \"\\n\"\n        fi\n    done\nelse\n    echo -e \"${BRIGHT_RED}Error: File '$AGENDA_FILE' not found.${RESET}\"\nfi\n\nprintf \"\\n\"\n\n"
  }
]