[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-edna 901a84a 72/72: Add 'packages/org-edna/' from com
From: |
Ian Dunn |
Subject: |
[elpa] scratch/org-edna 901a84a 72/72: Add 'packages/org-edna/' from commit 'ce425a365cc305142a6ec7ec95ebe5fd636100e3' |
Date: |
Sun, 21 May 2017 21:11:30 -0400 (EDT) |
branch: scratch/org-edna
commit 901a84ad17e7369bba2ddfed5fc844c531695ce7
Merge: 07e5ab2 ce425a3
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Add 'packages/org-edna/' from commit
'ce425a365cc305142a6ec7ec95ebe5fd636100e3'
git-subtree-dir: packages/org-edna
git-subtree-mainline: 07e5ab2a06f86a779cba517735cdb9c06c6f287b
git-subtree-split: ce425a365cc305142a6ec7ec95ebe5fd636100e3
---
packages/org-edna/.bzrignore | 6 +
packages/org-edna/COPYING | 674 +++++++++++++++++++++++++++
packages/org-edna/Makefile | 68 +++
packages/org-edna/defaults.mk | 26 ++
packages/org-edna/org-edna-tests.el | 556 ++++++++++++++++++++++
packages/org-edna/org-edna-tests.org | 82 ++++
packages/org-edna/org-edna.el | 773 +++++++++++++++++++++++++++++++
packages/org-edna/org-edna.org | 876 +++++++++++++++++++++++++++++++++++
8 files changed, 3061 insertions(+)
diff --git a/packages/org-edna/.bzrignore b/packages/org-edna/.bzrignore
new file mode 100644
index 0000000..ec97837
--- /dev/null
+++ b/packages/org-edna/.bzrignore
@@ -0,0 +1,6 @@
+*.elc
+local.mk
+org-edna-autoloads.el
+org-edna.info
+org-edna.texi
+org-edna.html
\ No newline at end of file
diff --git a/packages/org-edna/COPYING b/packages/org-edna/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/packages/org-edna/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/packages/org-edna/Makefile b/packages/org-edna/Makefile
new file mode 100644
index 0000000..765fe32
--- /dev/null
+++ b/packages/org-edna/Makefile
@@ -0,0 +1,68 @@
+# This is part of org-edna
+#
+# Copyright (C) 2017 Ian Dunn.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Load defaults
+include defaults.mk
+
+# Load local definitions
+include local.mk
+
+EMACS=$(emacs) --batch -L $(org_path)
+ALLSRC=org-edna.el
+SOURCE=$(ALLSRC)
+TARGET=$(patsubst %.el,%.elc,$(SOURCE))
+
+.PHONY: clean check local.mk help
+
+all: $(TARGET)
+
+compile: $(TARGET)
+
+%.elc: %.el
+ @$(EMACS) \
+ -L "." \
+ -f batch-byte-compile $<
+
+autoloads: org-edna-autoloads.el
+
+org-edna-autoloads.el:
+ @$(EMACS) \
+ --eval "(require 'package)" \
+ --eval "(setq inhibit-message t)" \
+ --eval "(package-generate-autoloads \"org-edna\" \"$$(pwd)\")"
+
+clean:
+ -rm -f *.elc
+
+check: compile
+ @$(EMACS) \
+ -L "." \
+ --load "ert" \
+ --load "org-edna-tests.el" \
+ -f ert-run-tests-batch-and-exit
+
+local.mk:
+ @cp -n defaults.mk local.mk
+
+help:
+ $(info )
+ $(info make all - Default)
+ $(info make compile - Compile Emacs Lisp Files)
+ $(info make autoloads - Generate Autoloads)
+ $(info make clean - Remove generated .elc files)
+ $(info make check - Run Tests)
+ @echo ""
diff --git a/packages/org-edna/defaults.mk b/packages/org-edna/defaults.mk
new file mode 100644
index 0000000..aed4ab3
--- /dev/null
+++ b/packages/org-edna/defaults.mk
@@ -0,0 +1,26 @@
+# This is part of org-edna
+#
+# Copyright (C) 2017 Ian Dunn.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+emacs = emacs
+
+prefix = /usr/share
+
+org_path = $(prefix)/emacs/site-lisp/org
+
+info_dir = $(prefix)/info
+
+lisp_dir = $(prefix)/emacs/site-lisp/
diff --git a/packages/org-edna/org-edna-tests.el
b/packages/org-edna/org-edna-tests.el
new file mode 100644
index 0000000..3ba5c28
--- /dev/null
+++ b/packages/org-edna/org-edna-tests.el
@@ -0,0 +1,556 @@
+;;; org-edna-tests.el --- Tests for org-edna
+
+;; Copyright (C) 2017 Ian Dunn
+
+;; Author: Ian Dunn <address@hidden>
+;; Keywords: convenience, text, org
+;; Version: 1.0
+;; Package-Requires: ((emacs "25.1") (seq "2.19") (org "8.0"))
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify it
under
+;; the terms of the GNU General Public License as published by the Free
Software
+;; Foundation; either version 3, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+;; details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'org-edna)
+(require 'ert)
+(require 'org-id)
+
+(defconst org-edna-test-dir
+ (expand-file-name (file-name-directory (or load-file-name
buffer-file-name))))
+
+(defconst org-edna-test-file
+ (expand-file-name "org-edna-tests.org" org-edna-test-dir))
+
+(defconst org-edna-tests-el
+ (expand-file-name "org-edna-tests.el" org-edna-test-dir))
+
+;; Jan 15, 2000; chosen at random
+(defconst org-edna-test-time
+ (encode-time 0 0 0 15 1 2000))
+
+(defconst org-edna-test-sibling-one-id
"82a4ac3d-9565-4f94-bc84-2bbfd8d7d96c")
+(defconst org-edna-test-sibling-two-id
"72534efa-e932-460b-ae2d-f044a0074815")
+(defconst org-edna-test-sibling-three-id
"06aca55e-ce09-46df-80d7-5b52e55d6505")
+(defconst org-edna-test-parent-id
"21b8f1f5-14e8-4677-873d-69e0389fdc9e")
+(defconst org-edna-test-id-heading-one
"0d491588-7da3-43c5-b51a-87fbd34f79f7")
+(defconst org-edna-test-id-heading-two
"b010cbad-60dc-46ef-a164-eb155e62cbb2")
+(defconst org-edna-test-id-heading-three
"97e6b0f0-40c4-464f-b760-6e5ca9744eb5")
+(defconst org-edna-test-id-heading-four
"7d4d564b-18b2-445c-a0c8-b1b3fb9ad29e")
+(defconst org-edna-test-archive-heading
"d7668277-f959-43ba-8e85-8a3c76996862")
+
+(defun org-edna-find-test-heading (id)
+ "Find the test heading with id ID."
+ (org-id-find-id-in-file id org-edna-test-file t))
+
+(ert-deftest org-edna-parse-form-no-arguments ()
+ (let* ((input-string "test-string")
+ (parsed (org-edna-parse-form input-string)))
+ (should parsed)
+ (should (= (length parsed) 4))
+ (pcase-let* ((`(,token ,args ,modifier ,pos) parsed))
+ (should (eq token 'test-string))
+ (should (not args))
+ (should (not modifier))
+ (should (= pos 11)))))
+
+(ert-deftest org-edna-parse-form-no-arguments-modifier ()
+ (let* ((input-string "!test-string")
+ (parsed (org-edna-parse-form input-string)))
+ (should parsed)
+ (should (= (length parsed) 4))
+ (pcase-let* ((`(,token ,args ,modifier ,pos) parsed))
+ (should (eq token 'test-string))
+ (should (not args))
+ (should (eq modifier '!))
+ (should (= pos 12)))))
+
+(ert-deftest org-edna-parse-form-single-argument ()
+ (let* ((input-string "test-string(abc)")
+ (parsed (org-edna-parse-form input-string)))
+ (should parsed)
+ (should (= (length parsed) 4))
+ (pcase-let* ((`(,token ,args ,modifier ,pos) parsed))
+ (should (eq token 'test-string))
+ (should (= (length args) 1))
+ (should (symbolp (nth 0 args)))
+ (should (eq (nth 0 args) 'abc))
+ (should (not modifier))
+ (should (= pos (length input-string))))))
+
+(ert-deftest org-edna-parse-form-string-argument ()
+ (let* ((input-string "test-string(abc \"def (ghi)\")")
+ (parsed (org-edna-parse-form input-string)))
+ (should parsed)
+ (should (= (length parsed) 4))
+ (pcase-let* ((`(,token ,args ,modifier ,pos) parsed))
+ (should (eq token 'test-string))
+ (should (= (length args) 2))
+ (should (symbolp (nth 0 args)))
+ (should (eq (nth 0 args) 'abc))
+ (should (stringp (nth 1 args)))
+ (should (string-equal (nth 1 args) "def (ghi)"))
+ (should (not modifier))
+ (should (= pos (length input-string))))))
+
+(ert-deftest org-edna-parse-form-multiple-forms ()
+ (let ((input-string "test-string1 test-string2")
+ pos)
+ (pcase-let* ((`(,token1 ,args1 ,modifier1 ,pos1) (org-edna-parse-form
input-string)))
+ ;; (should (and token1 args1 modifier1 pos1))
+ (should (eq token1 'test-string1))
+ (should (not args1))
+ (should (not modifier1))
+ (should (= pos1 13))
+ (setq pos pos1))
+ (pcase-let* ((`(,token2 ,args2 ,modifier2 ,pos2) (org-edna-parse-form
(substring input-string pos))))
+ (should (eq token2 'test-string2))
+ (should (not args2))
+ (should (not modifier2))
+ (should (= pos2 12)))))
+
+(ert-deftest org-edna-parse-form-empty-argument-list ()
+ (let ((input-string "test-string1()"))
+ (pcase-let* ((`(,token1 ,args1 ,modifier1 ,pos1) (org-edna-parse-form
input-string)))
+ (should (eq token1 'test-string1))
+ (should (not args1))
+ (should (not modifier1))
+ (should (= pos1 (length input-string))))))
+
+(ert-deftest org-edna-parse-form-condition ()
+ (let ((input-string "variable-set?()"))
+ (pcase-let* ((`(,token1 ,args1 ,modifier1 ,pos1) (org-edna-parse-form
input-string))
+ (`(,type . ,func) (org-edna--function-for-key token1)))
+ (should (eq token1 'variable-set?))
+ (should (not args1))
+ (should (not modifier1))
+ (should (= pos1 (length input-string)))
+ (should (eq type 'condition))
+ (should (eq func 'org-edna-condition/variable-set?)))))
+
+
+;; Finders
+
+(defsubst org-edna-heading (pom)
+ (org-with-point-at pom
+ (org-get-heading t t t t)))
+
+(ert-deftest org-edna-finder/match-single-arg ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (targets (org-edna-finder/match "test&1")))
+ (should (= (length targets) 2))
+ (should (string-equal (org-edna-heading (nth 0 targets)) "Tagged Heading
1"))
+ (should (string-equal (org-edna-heading (nth 1 targets)) "Tagged Heading
2"))))
+
+(ert-deftest org-edna-finder/ids-single ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (test-id "caccd0a6-d400-410a-9018-b0635b07a37e")
+ (targets (org-edna-finder/ids test-id)))
+ (should (= (length targets) 1))
+ (should (string-equal (org-edna-heading (nth 0 targets)) "Blocking Test"))
+ (should (string-equal (org-entry-get (nth 0 targets) "ID") test-id))))
+
+(ert-deftest org-edna-finder/ids-multiple ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (test-ids '("0d491588-7da3-43c5-b51a-87fbd34f79f7"
+ "b010cbad-60dc-46ef-a164-eb155e62cbb2"))
+ (targets (apply 'org-edna-finder/ids test-ids)))
+ (should (= (length targets) 2))
+ (should (string-equal (org-edna-heading (nth 0 targets)) "ID Heading 1"))
+ (should (string-equal (org-entry-get (nth 0 targets) "ID") (nth 0
test-ids)))
+ (should (string-equal (org-edna-heading (nth 1 targets)) "ID Heading 2"))
+ (should (string-equal (org-entry-get (nth 1 targets) "ID") (nth 1
test-ids)))))
+
+(ert-deftest org-edna-finder/match-blocker ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (heading (org-id-find "caccd0a6-d400-410a-9018-b0635b07a37e" t))
+ (blocker (org-entry-get heading "BLOCKER")))
+ (should (string-equal "match(\"test&1\")" blocker))
+ (org-with-point-at heading
+ (org-edna-process-form blocker 'condition))
+ (should (string-equal (substring-no-properties org-block-entry-blocking)
+ "TODO Tagged Heading 1 :1:test:"))))
+
+(ert-deftest org-edna-finder/file ()
+ (let* ((targets (org-edna-finder/file org-edna-test-file)))
+ (should (= (length targets) 1))
+ (should (markerp (nth 0 targets)))
+ (org-with-point-at (nth 0 targets)
+ (should (equal (current-buffer) (find-buffer-visiting
org-edna-test-file)))
+ (should (equal (point) 1)))))
+
+(ert-deftest org-edna-finder/org-file ()
+ (let* ((org-directory (file-name-directory org-edna-test-file))
+ (targets (org-edna-finder/org-file (file-name-nondirectory
org-edna-test-file))))
+ (should (= (length targets) 1))
+ (should (markerp (nth 0 targets)))
+ (org-with-point-at (nth 0 targets)
+ (should (equal (current-buffer) (find-buffer-visiting
org-edna-test-file)))
+ (should (equal (point) 1)))))
+
+(ert-deftest org-edna-finder/self ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "82a4ac3d-9565-4f94-bc84-2bbfd8d7d96c" t))
+ (targets (org-with-point-at current (org-edna-finder/self))))
+ (should (= (length targets) 1))
+ (should (equal current (nth 0 targets)))))
+
+(ert-deftest org-edna-finder/siblings ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "82a4ac3d-9565-4f94-bc84-2bbfd8d7d96c" t))
+ (siblings (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ '("72534efa-e932-460b-ae2d-f044a0074815"
+ "06aca55e-ce09-46df-80d7-5b52e55d6505")))
+ (targets (org-with-point-at current
+ (org-edna-finder/siblings))))
+ (should (= (length targets) 2))
+ (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/siblings-wrap ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "72534efa-e932-460b-ae2d-f044a0074815" t))
+ (siblings (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ '("06aca55e-ce09-46df-80d7-5b52e55d6505"
+ "82a4ac3d-9565-4f94-bc84-2bbfd8d7d96c")))
+ (targets (org-with-point-at current
+ (org-edna-finder/siblings-wrap))))
+ (should (= (length targets) 2))
+ (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/rest-of-siblings ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "72534efa-e932-460b-ae2d-f044a0074815" t))
+ (siblings (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ '("06aca55e-ce09-46df-80d7-5b52e55d6505")))
+ (targets (org-with-point-at current
+ (org-edna-finder/rest-of-siblings))))
+ (should (= (length targets) 1))
+ (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/next-sibling ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "72534efa-e932-460b-ae2d-f044a0074815" t))
+ (siblings (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ '("06aca55e-ce09-46df-80d7-5b52e55d6505")))
+ (targets (org-with-point-at current
+ (org-edna-finder/next-sibling))))
+ (should (= (length targets) 1))
+ (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/previous-sibling ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find "06aca55e-ce09-46df-80d7-5b52e55d6505" t))
+ (siblings (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ '("72534efa-e932-460b-ae2d-f044a0074815")))
+ (targets (org-with-point-at current
+ (org-edna-finder/previous-sibling))))
+ (should (= (length targets) 1))
+ (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/first-child ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find org-edna-test-parent-id t))
+ (first-child (list (org-id-find org-edna-test-sibling-one-id t)))
+ (targets (org-with-point-at current
+ (org-edna-finder/first-child))))
+ (should (= (length targets) 1))
+ (should (equal first-child targets))))
+
+(ert-deftest org-edna-finder/children ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find org-edna-test-parent-id t))
+ (children (mapcar
+ (lambda (uuid) (org-id-find uuid t))
+ `(,org-edna-test-sibling-one-id
+ ,org-edna-test-sibling-two-id
+ ,org-edna-test-sibling-three-id)))
+ (targets (org-with-point-at current
+ (org-edna-finder/children))))
+ (should (= (length targets) 3))
+ (should (equal children targets))))
+
+(ert-deftest org-edna-finder/parent ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (current (org-id-find org-edna-test-sibling-one-id t))
+ (parent (list (org-id-find org-edna-test-parent-id t)))
+ (targets (org-with-point-at current
+ (org-edna-finder/parent))))
+ (should (= (length targets) 1))
+ (should (equal parent targets))))
+
+
+;; Actions
+
+(ert-deftest org-edna-action/todo-test ()
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (target (org-id-find "0d491588-7da3-43c5-b51a-87fbd34f79f7" t)))
+ (org-with-point-at target
+ (org-edna-action/todo! nil "DONE")
+ (should (string-equal (org-entry-get nil "TODO") "DONE"))
+ (org-edna-action/todo! nil "TODO")
+ (should (string-equal (org-entry-get nil "TODO") "TODO"))
+ (org-edna-action/todo! nil 'DONE)
+ (should (string-equal (org-entry-get nil "TODO") "DONE"))
+ (org-edna-action/todo! nil 'TODO)
+ (should (string-equal (org-entry-get nil "TODO") "TODO")))))
+
+(ert-deftest org-edna-action-scheduled/wkdy ()
+ ;; Override `current-time' so we can get a deterministic value
+ (cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
+ (org-agenda-files `(,org-edna-test-file))
+ (target (org-id-find "0d491588-7da3-43c5-b51a-87fbd34f79f7" t)))
+ (org-with-point-at target
+ (org-edna-action/scheduled! nil "Mon")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-17 Mon>"))
+ (org-edna-action/scheduled! nil 'rm)
+ (should (not (org-entry-get nil "SCHEDULED")))
+ (org-edna-action/scheduled! nil "Mon 9:00")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-17 Mon 09:00>"))
+ (org-edna-action/scheduled! nil 'rm)
+ (should (not (org-entry-get nil "SCHEDULED"))))))
+
+(ert-deftest org-edna-action-scheduled/cp ()
+ ;; Override `current-time' so we can get a deterministic value
+ (let* ((org-agenda-files `(,org-edna-test-file))
+ (target (org-id-find "0d491588-7da3-43c5-b51a-87fbd34f79f7" t))
+ (source (org-id-find "97e6b0f0-40c4-464f-b760-6e5ca9744eb5" t))
+ (pairs '((cp . rm) (copy . remove) ("cp" . "rm") ("copy" .
"remove"))))
+ (org-with-point-at target
+ (dolist (pair pairs)
+ ;; (message "Pair: %s" pair)
+ (org-edna-action/scheduled! source (car pair))
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-15 Sat 00:00>"))
+ (org-edna-action/scheduled! source (cdr pair))
+ (should (not (org-entry-get nil "SCHEDULED")))))))
+
+(ert-deftest org-edna-action-scheduled/inc ()
+ ;; Override `current-time' so we can get a deterministic value
+ (cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
+ (org-agenda-files `(,org-edna-test-file))
+ (target (org-id-find "97e6b0f0-40c4-464f-b760-6e5ca9744eb5" t)))
+ (org-with-point-at target
+ ;; Time started at Jan 15, 2000
+ ;; Increment 1 minute
+ (org-edna-action/scheduled! nil "+1M")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-15 Sat 00:01>"))
+ (org-edna-action/scheduled! nil "-1M")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-15 Sat 00:00>"))
+ (org-edna-action/scheduled! nil "+1d")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-16 Sun 00:00>"))
+ (org-edna-action/scheduled! nil "++1h")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-15 Sat 01:00>"))
+ (org-edna-action/scheduled! nil "2000-01-15 Sat 00:00")
+ (should (string-equal (org-entry-get nil "SCHEDULED")
+ "<2000-01-15 Sat 00:00>")))))
+
+(ert-deftest org-edna-action-tag ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/tag! nil "tag")
+ (should (equal (org-get-tags) '("tag")))
+ (org-edna-action/tag! nil "")
+ (should-not (org-get-tags)))))
+
+(ert-deftest org-edna-action-property ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/set-property! nil "TEST" "1")
+ (should (equal (org-entry-get nil "TEST") "1"))
+ (org-edna-action/delete-property! nil "TEST")
+ (should-not (org-entry-get nil "TEST")))))
+
+(ert-deftest org-edna-action-clock ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/clock-in! nil)
+ (should (org-clocking-p))
+ (should (equal org-clock-hd-marker pom))
+ (org-edna-action/clock-out! nil)
+ (should-not (org-clocking-p)))))
+
+(ert-deftest org-edna-action-priority ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (org-lowest-priority ?C)
+ (org-highest-priority ?A)
+ (org-default-priority ?B))
+ (org-with-point-at pom
+ (org-edna-action/set-priority! nil "A")
+ (should (equal (org-entry-get nil "PRIORITY") "A"))
+ (org-edna-action/set-priority! nil 'down)
+ (should (equal (org-entry-get nil "PRIORITY") "B"))
+ (org-edna-action/set-priority! nil 'up)
+ (should (equal (org-entry-get nil "PRIORITY") "A"))
+ (org-edna-action/set-priority! nil ?C)
+ (should (equal (org-entry-get nil "PRIORITY") "C"))
+ (org-edna-action/set-priority! nil 'remove)
+ (should (equal (org-entry-get nil "PRIORITY") "B")))))
+
+(ert-deftest org-edna-action-effort ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/set-effort! nil "0:01")
+ (should (equal (org-entry-get nil "EFFORT") "0:01"))
+ (org-edna-action/set-effort! nil 'increment)
+ (should (equal (org-entry-get nil "EFFORT") "0:02"))
+ (org-entry-delete nil "EFFORT"))))
+
+(ert-deftest org-edna-action-archive ()
+ (let ((org-archive-save-context-info '(todo))
+ (pom (org-edna-find-test-heading org-edna-test-archive-heading))
+ ;; Archive it to the same location
+ (org-archive-location "::** Archive")
+ (org-edna-prompt-for-archive nil))
+ (org-with-point-at pom
+ (org-edna-action/archive! nil)
+ (should (equal (org-entry-get nil "ARCHIVE_TODO") "TODO"))
+ (org-entry-delete nil "ARCHIVE_TODO"))))
+
+(ert-deftest org-edna-action-chain ()
+ (let ((old-pom (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (new-pom (org-edna-find-test-heading org-edna-test-id-heading-two)))
+ (org-entry-put old-pom "TEST" "1")
+ (org-with-point-at new-pom
+ (org-edna-action/chain! old-pom "TEST")
+ (should (equal (org-entry-get nil "TEST") "1")))
+ (org-entry-delete old-pom "TEST")
+ (org-entry-delete new-pom "TEST")))
+
+
+;; Conditions
+
+(defun org-edna-test-condition-form (func-sym pom-true pom-false block-true
block-false &rest args)
+ (org-with-point-at pom-true
+ (should-not (apply func-sym t args))
+ (should (equal (apply func-sym nil args) block-true)))
+ (org-with-point-at pom-false
+ (should (equal (apply func-sym t args) block-false))
+ (should-not (apply func-sym nil args))))
+
+(ert-deftest org-edna-condition-done ()
+ (let* ((pom-done (org-edna-find-test-heading org-edna-test-id-heading-four))
+ (pom-todo (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (block-done (org-with-point-at pom-done (org-get-heading)))
+ (block-todo (org-with-point-at pom-todo (org-get-heading))))
+ (org-edna-test-condition-form 'org-edna-condition/done?
+ pom-done pom-todo
+ block-done block-todo)))
+
+(ert-deftest org-edna-condition-todo-state-string ()
+ (let* ((pom-done (org-edna-find-test-heading org-edna-test-id-heading-four))
+ (pom-todo (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (block-done (org-with-point-at pom-done (org-get-heading)))
+ (block-todo (org-with-point-at pom-todo (org-get-heading))))
+ (org-edna-test-condition-form 'org-edna-condition/todo-state?
+ pom-todo pom-done
+ block-todo block-done
+ "TODO")))
+
+(ert-deftest org-edna-condition-todo-state-symbol ()
+ (let* ((pom-done (org-edna-find-test-heading org-edna-test-id-heading-four))
+ (pom-todo (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (block-done (org-with-point-at pom-done (org-get-heading)))
+ (block-todo (org-with-point-at pom-todo (org-get-heading))))
+ (org-edna-test-condition-form 'org-edna-condition/todo-state?
+ pom-todo pom-done
+ block-todo block-done
+ 'TODO)))
+
+(ert-deftest org-edna-condition-headings ()
+ (pcase-let* ((`(,pom-headings ,block-headings)
+ (with-current-buffer (find-file-noselect org-edna-test-file)
+ (list (point-min-marker) (buffer-name))))
+ (`(,pom-no-headings ,block-no-headings)
+ (with-current-buffer (find-file-noselect org-edna-tests-el)
+ (list (point-min-marker) (buffer-name)))))
+ (org-edna-test-condition-form 'org-edna-condition/headings?
+ pom-headings pom-no-headings
+ block-headings block-no-headings)))
+
+(ert-deftest org-edna-condition-variable-set ()
+ (let* ((temp-var t))
+ (should-not (org-edna-condition/variable-set? t 'temp-var t))
+ (should (equal (org-edna-condition/variable-set? nil 'temp-var t)
+ "temp-var == t"))
+ (should (equal (org-edna-condition/variable-set? t 'temp-var nil)
+ "temp-var != nil"))
+ (should-not (org-edna-condition/variable-set? nil 'temp-var nil))))
+
+(ert-deftest org-edna-condition-has-property ()
+ (let* ((pom-true (org-edna-find-test-heading org-edna-test-id-heading-four))
+ (pom-false (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (block-true (org-with-point-at pom-true (org-get-heading)))
+ (block-false (org-with-point-at pom-false (org-get-heading))))
+ (org-edna-test-condition-form 'org-edna-condition/has-property?
+ pom-true pom-false
+ block-true block-false
+ "ID" org-edna-test-id-heading-four)))
+
+(ert-deftest org-edna-condition-re-search ()
+ (pcase-let* ((case-fold-search nil)
+ (string "require")
+ (`(,pom-true ,block-true)
+ (with-current-buffer (find-file-noselect org-edna-tests-el)
+ (list (point-min-marker)
+ (format "Found %s in %s" string (buffer-name)))))
+ (`(,pom-false ,block-false)
+ (with-current-buffer (find-file-noselect org-edna-test-file)
+ (list (point-min-marker)
+ (format "Did Not Find %s in %s" string
(buffer-name))))))
+ (org-edna-test-condition-form 'org-edna-condition/re-search?
+ pom-true pom-false
+ block-true block-false
+ string)))
+
+
+;; Consideration
+
+(ert-deftest org-edna-consideration/all ()
+ (let ((blocks-blocking `("a" nil "b"))
+ (blocks-no-blocking `(nil nil nil)))
+ (should (string-equal (org-edna-handle-consideration 'all blocks-blocking)
"a"))
+ (should (not (org-edna-handle-consideration 'all blocks-no-blocking)))))
+
+(ert-deftest org-edna-consideration/integer ()
+ (let ((blocks-blocking `("a" "c" "b"))
+ (blocks-no-blocking `("a" nil "b"))
+ (blocks-empty `(nil nil nil)))
+ (should (string-equal (org-edna-handle-consideration 1 blocks-blocking)
"a"))
+ (should (not (org-edna-handle-consideration 1 blocks-no-blocking)))
+ (should (not (org-edna-handle-consideration 1 blocks-empty)))))
+
+(ert-deftest org-edna-consideration/float ()
+ (let ((blocks-blocking `("a" "c" "b"))
+ (blocks-no-blocking `("a" nil "b"))
+ (blocks-empty `(nil nil nil)))
+ (should (string-equal (org-edna-handle-consideration 0.25 blocks-blocking)
"a"))
+ (should (not (org-edna-handle-consideration 0.25 blocks-no-blocking)))
+ (should (not (org-edna-handle-consideration 0.25 blocks-empty)))))
+
+(provide 'org-edna-tests)
+
+;;; org-edna-tests.el ends here
diff --git a/packages/org-edna/org-edna-tests.org
b/packages/org-edna/org-edna-tests.org
new file mode 100644
index 0000000..0c2c24e
--- /dev/null
+++ b/packages/org-edna/org-edna-tests.org
@@ -0,0 +1,82 @@
+#+STARTUP: nologdone
+#+PROPERTY: EFFORT_ALL 0:01 0:02 0:03
+
+* COMMENT Copying
+Copyright (C) 2017 Ian Dunn
+
+#+BEGIN_QUOTE
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+#+END_QUOTE
+* Test Pool
+** TODO Tagged Heading 1 :1:test:
+** TODO Tagged Heading 2 :1:test:
+** TODO ID Heading 1
+:PROPERTIES:
+:ID: 0d491588-7da3-43c5-b51a-87fbd34f79f7
+:LOGGING: nil
+:END:
+** TODO ID Heading 2
+:PROPERTIES:
+:ID: b010cbad-60dc-46ef-a164-eb155e62cbb2
+:LOGGING: nil
+:END:
+** TODO ID Heading 3
+SCHEDULED: <2000-01-15 Sat 00:00>
+:PROPERTIES:
+:ID: 97e6b0f0-40c4-464f-b760-6e5ca9744eb5
+:END:
+** DONE ID Heading 4
+:PROPERTIES:
+:ID: 7d4d564b-18b2-445c-a0c8-b1b3fb9ad29e
+:END:
+** Scheduled Headings
+*** TODO Scheduled Heading 1
+SCHEDULED: <2017-01-01 Sun>
+:PROPERTIES:
+:ID: caf27724-0887-4565-9765-ed2f1edcfb16
+:END:
+*** TODO Scheduled Heading 2
+SCHEDULED: <2017-01-01 Sun>
+:PROPERTIES:
+:ID: 5594d4f1-b1bb-400f-9f3d-e2f9b43e82c3
+:END:
+** Sibling Headings
+:PROPERTIES:
+:ID: 21b8f1f5-14e8-4677-873d-69e0389fdc9e
+:END:
+*** Sibling 1
+:PROPERTIES:
+:ID: 82a4ac3d-9565-4f94-bc84-2bbfd8d7d96c
+:END:
+*** Sibling 2
+:PROPERTIES:
+:ID: 72534efa-e932-460b-ae2d-f044a0074815
+:END:
+*** Sibling 3
+:PROPERTIES:
+:ID: 06aca55e-ce09-46df-80d7-5b52e55d6505
+:END:
+** Archive
+*** TODO Archive One
+:PROPERTIES:
+:ID: d7668277-f959-43ba-8e85-8a3c76996862
+:END:
+* Finder Tests
+** Match
+*** TODO Blocking Test
+:PROPERTIES:
+:BLOCKER: match("test&1")
+:ID: caccd0a6-d400-410a-9018-b0635b07a37e
+:LOGGING: nil
+:END:
diff --git a/packages/org-edna/org-edna.el b/packages/org-edna/org-edna.el
new file mode 100644
index 0000000..e0d3cc0
--- /dev/null
+++ b/packages/org-edna/org-edna.el
@@ -0,0 +1,773 @@
+;;; org-edna.el --- Extensible Dependencies 'N' Actions -*- lexical-binding:
t; -*-
+
+;; Copyright (C) 2017 Ian Dunn
+
+;; Author: Ian Dunn <address@hidden>
+;; Maintainer: Ian Dunn <address@hidden>
+;; Keywords: convenience, text, org
+;; URL: https://savannah.nongnu.org/projects/org-edna-el/
+;; Package-Requires: ((emacs "25.1") (seq "2.19") (org "9.0.5"))
+;; Version: 1.0alpha1
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify it
under
+;; the terms of the GNU General Public License as published by the Free
Software
+;; Foundation; either version 3, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+;; details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Edna provides an extensible means of specifying conditions which must be
+;; fulfilled before a task can be completed and actions to take once it is.
+
+;; Org Edna runs when either the BLOCKER or TRIGGER properties are set on a
+;; headline, and when it is changing from a TODO state to a DONE state.
+
+;;; History:
+
+;;; Code:
+
+(require 'org)
+(require 'subr-x)
+(require 'seq)
+
+(defgroup org-edna nil
+ "Extensible Dependencies 'N' Actions"
+ :group 'org)
+
+(defcustom org-edna-use-inheritance nil
+ "Whether Edna should use inheritance when looking for properties.
+
+This only applies to the BLOCKER and TRIGGER properties, not any
+properties used during actions or conditions."
+ :group 'org-edna
+ :type 'boolean)
+
+(defcustom org-edna-prompt-for-archive t
+ "Whether Edna should prompt before archiving a target."
+ :group 'org-edna
+ :type 'boolean)
+
+(defmacro org-edna--syntax-error (msg form pos)
+ "Signal an Edna syntax error.
+
+MSG will be reported to the user and should describe the error.
+FORM is the form that generated the error.
+POS is the position in FORM at which the error occurred."
+ `(signal 'invalid-read-syntax (list :msg ,msg :form ,form :pos ,pos)))
+
+(defun org-edna--print-syntax-error (error-plist)
+ "Prints the syntax error from ERROR-PLIST."
+ (let ((msg (plist-get error-plist :msg))
+ (form (plist-get error-plist :form))
+ (pos (plist-get error-plist :pos)))
+ (message
+ "Org Edna Syntax Error: %s\n%s\n%s"
+ msg form (concat (make-string pos ?\ ) "^"))))
+
+(defun org-edna--transform-arg (arg)
+ "Transform ARG.
+
+Currently, the following are handled:
+
+- UUIDs (as determined by `org-uuidgen-p') are converted to strings"
+ (pcase arg
+ ((and (pred symbolp)
+ (let (pred org-uuidgen-p) (symbol-name arg)))
+ (symbol-name arg))
+ (_
+ arg)))
+
+(defun org-edna-parse-form (form &optional start)
+ "Parse Edna form FORM starting at position START."
+ (setq start (or start 0))
+ (pcase-let* ((`(,token . ,pos) (read-from-string form start))
+ (modifier nil)
+ (args nil))
+ (unless token
+ (org-edna--syntax-error "Invalid Token" form start))
+ ;; Check for either end of string or an opening parenthesis
+ (unless (or (equal pos (length form))
+ (equal (string-match-p "\\s-" form pos) pos)
+ (equal (string-match-p "(" form pos) pos))
+ (org-edna--syntax-error "Invalid character in form" form pos))
+ ;; Parse arguments if we have any
+ (when (equal (string-match-p "(" form pos) pos)
+ (pcase-let* ((`(,new-args . ,new-pos) (read-from-string form pos)))
+ (setq pos new-pos
+ args (mapcar #'org-edna--transform-arg new-args))))
+ ;; Check for a modifier
+ (when (string-match "^\\([!]\\)\\(.*\\)" (symbol-name token))
+ (setq modifier (intern (match-string 1 (symbol-name token))))
+ (setq token (intern (match-string 2 (symbol-name token)))))
+ ;; Move across any whitespace
+ (when (string-match "\\s-+" form pos)
+ (setq pos (match-end 0)))
+ (list token args modifier pos)))
+
+(defun org-edna--function-for-key (key)
+ "Determine the Edna function for KEY.
+
+KEY should be a symbol, the keyword for which to find the Edna
+function."
+ (cond
+ ;; Just return nil if it's not a symbol; `org-edna-process-form' will handle
+ ;; the rest
+ ((or (not key)
+ (not (symbolp key))))
+ ((eq key 'consideration)
+ ;; Function is ignored here
+ (cons 'consideration 'identity))
+ ((string-suffix-p "!" (symbol-name key))
+ ;; Action
+ (let ((func-sym (intern (format "org-edna-action/%s" key))))
+ (when (fboundp func-sym)
+ (cons 'action func-sym))))
+ ((string-suffix-p "?" (symbol-name key))
+ ;; Condition
+ (let ((func-sym (intern (format "org-edna-condition/%s" key))))
+ (when (fboundp func-sym)
+ (cons 'condition func-sym))))
+ (t
+ ;; Everything else is a finder
+ (let ((func-sym (intern (format "org-edna-finder/%s" key))))
+ (when (fboundp func-sym)
+ (cons 'finder func-sym))))))
+
+(defun org-edna--handle-condition (func mod args targets consideration)
+ "Handle a condition."
+ ;; Check the condition at each target
+ (when-let ((blocks
+ (mapcar
+ (lambda (entry-marker)
+ (org-with-point-at entry-marker
+ (apply func mod args)))
+ targets)))
+ ;; Apply consideration
+ (org-edna-handle-consideration consideration blocks)))
+
+(defun org-edna-process-form (form action-or-condition)
+ "Process FORM.
+
+ACTION-OR-CONDITION is a symbol, either 'action or 'condition,
+indicating whether FORM accepts actions or conditions."
+ (let ((targets)
+ (blocking-entry)
+ (consideration 'all)
+ (state nil) ;; Type of operation
+ ;; Keep track of the current headline
+ (last-entry (point-marker))
+ (pos 0))
+ (while (< pos (length form))
+ (pcase-let* ((`(,key ,args ,mod ,new-pos) (org-edna-parse-form form pos))
+ (`(,type . ,func) (org-edna--function-for-key key)))
+ (unless (and key type func)
+ (org-edna--syntax-error "Unrecognized Form" form pos))
+ (pcase type
+ ('finder
+ (unless (eq state 'finder)
+ ;; We just executed some actions, so reset the entries.
+ (setq targets nil))
+ (setq state 'finder)
+ (let ((markers (apply func args)))
+ (setq targets (seq-uniq `(,@targets ,@markers)))))
+ ('action
+ (unless (eq action-or-condition 'action)
+ (org-edna--syntax-error "Actions aren't allowed in this context"
form pos))
+ (unless targets
+ (message "Warning: Action specified without targets"))
+ (setq state 'action)
+ (dolist (target targets)
+ (org-with-point-at target
+ (apply func last-entry args))))
+ ('condition
+ (unless (eq action-or-condition 'condition)
+ (org-edna--syntax-error "Conditions aren't allowed in this
context" form pos))
+ (unless targets
+ (message "Warning: Condition specified without targets"))
+ (setq state 'condition)
+ (setq blocking-entry
+ (or blocking-entry ;; We're already blocking
+ (org-edna--handle-condition func mod args targets
consideration))))
+ ('consideration
+ (unless (= (length args) 1)
+ (org-edna--syntax-error "Consideration requires a single
argument" form pos))
+ ;; Consideration must be at the start of the targets, so clear out
+ ;; any old targets.
+ (setq targets nil
+ consideration (nth 0 args))))
+ (setq pos new-pos)))
+ ;; We exhausted the input string, but didn't find a condition when we were
+ ;; expecting one.
+ (when (and (eq action-or-condition 'condition) ;; Looking for conditions
+ (eq state 'finder) ;; but haven't found any
+ (not blocking-entry)) ;; ever
+ (setq blocking-entry
+ (org-edna--handle-condition 'org-edna-condition/done?
+ t nil targets consideration)))
+ ;; Only blockers care about the return value, and this will be non-nil if
+ ;; the entry should be blocked.
+ (setq org-block-entry-blocking blocking-entry)
+ (not blocking-entry)))
+
+
+
+(defmacro org-edna-run (change-plist &rest body)
+ "Run a TODO state change.
+
+The state information is held in CHANGE-PLIST. If the TODO state
+is changing from a TODO state to a DONE state, run BODY."
+ (declare (indent 1))
+ `(let* ((pos (plist-get ,change-plist :position))
+ (type (plist-get ,change-plist :type))
+ (from (plist-get ,change-plist :from))
+ (to (plist-get ,change-plist :to)))
+ (if (and
+ ;; We are only handling todo-state-change
+ (eq type 'todo-state-change)
+ ;; And only from a TODO state to a DONE state
+ (member from (cons 'todo org-not-done-keywords))
+ (member to (cons 'done org-done-keywords)))
+ (condition-case err
+ ,@body
+ (error
+ (if (eq (car err) 'invalid-read-syntax)
+ (org-edna--print-syntax-error (cdr err))
+ (message "Edna Error: %s" (error-message-string err)))
+ (setq org-block-entry-blocking (org-get-heading))
+ ;; Block
+ nil))
+ ;; Return t for the blocker to let the calling function know that there
+ ;; is no block here.
+ t)))
+
+(defun org-edna-trigger-function (change-plist)
+ "Trigger function work-horse.
+
+See `org-edna-run' for CHANGE-PLIST explanation.
+
+This shouldn't be run from outside of `org-trigger-hook'."
+ (org-edna-run change-plist
+ (when-let ((form (org-entry-get pos "TRIGGER" org-edna-use-inheritance)))
+ (org-edna-process-form form 'action))))
+
+(defun org-edna-blocker-function (change-plist)
+ "Blocker function work-horse.
+
+See `org-edna-run' for CHANGE-PLIST explanation.
+
+This shouldn't be run from outside of `org-blocker-hook'."
+ (org-edna-run change-plist
+ (if-let ((form (org-entry-get pos "BLOCKER" org-edna-use-inheritance)))
+ (org-edna-process-form form 'condition)
+ t)))
+
+;;;###autoload
+(defun org-edna-load ()
+ "Setup the hooks necessary for Org Edna to run.
+
+This means adding to `org-trigger-hook' and `org-blocker-hook'."
+ (interactive)
+ (add-hook 'org-trigger-hook 'org-edna-trigger-function)
+ (add-hook 'org-blocker-hook 'org-edna-blocker-function))
+
+;;;###autoload
+(defun org-edna-unload ()
+ "Unload Org Edna.
+
+Remove Edna's workers from `org-trigger-hook' and
+`org-blocker-hook'."
+ (interactive)
+ (remove-hook 'org-trigger-hook 'org-edna-trigger-function)
+ (remove-hook 'org-blocker-hook 'org-edna-blocker-function))
+
+
+
+;; Tag Finder
+(defun org-edna-finder/match (match-spec &optional scope skip)
+ "Find entries using Org matching.
+
+MATCH-SPEC may be any valid match string; it is passed straight
+into `org-map-entries'.
+
+SCOPE and SKIP are their counterparts in `org-map-entries'.
+SCOPE defaults to agenda, and SKIP defaults to nil.
+
+* TODO Test
+ :PROPERTIES:
+ :BLOCKER: match(\"test&mine\" agenda)
+ :END:
+
+\"Test\" will block until all entries tagged \"test\" and
+\"mine\" in the agenda files are marked DONE."
+ (setq scope (or scope 'agenda))
+ (org-map-entries
+ ;; Find all entries in the agenda files that match the given tag.
+ (lambda nil (point-marker))
+ match-spec scope skip))
+
+;; ID finder
+(defun org-edna-finder/ids (&rest ids)
+ "Find a list of headlines with given IDs.
+
+IDS are all UUIDs as understood by `org-id-find'."
+ (mapcar (lambda (id) (org-id-find id 'marker)) ids))
+
+(defun org-edna-finder/self ()
+ (list (point-marker)))
+
+(defun org-edna-finder/siblings ()
+ (org-with-wide-buffer
+ (let ((self (and (ignore-errors (org-back-to-heading t)) (point)))
+ (markers))
+ (org-up-heading-safe)
+ (org-goto-first-child)
+ (unless (equal (point) self)
+ (push (point-marker) markers))
+ (while (org-get-next-sibling)
+ (unless (equal (point) self)
+ (push (point-marker) markers)))
+ (nreverse markers))))
+
+(defun org-edna-finder/siblings-wrap ()
+ (org-with-wide-buffer
+ (let ((self (and (ignore-errors (org-back-to-heading t)) (point)))
+ (markers))
+ ;; Go from this heading to the end
+ (save-excursion
+ (while (org-get-next-sibling)
+ (unless (equal (point) self)
+ (push (point-marker) markers))))
+ ;; Go to the first heading
+ (org-up-heading-safe)
+ (org-goto-first-child)
+ (save-excursion
+ (while (not (equal (point) self))
+ (push (point-marker) markers)
+ (org-get-next-sibling)))
+ (nreverse markers))))
+
+(defun org-edna-finder/rest-of-siblings ()
+ (org-with-wide-buffer
+ (let ((self (and (ignore-errors (org-back-to-heading t)) (point)))
+ (markers))
+ ;; Go from this heading to the end
+ (while (org-get-next-sibling)
+ (unless (equal (point) self)
+ (push (point-marker) markers)))
+ (nreverse markers))))
+
+(defun org-edna-finder/next-sibling ()
+ (org-with-wide-buffer
+ (and (org-get-next-sibling)
+ (list (point-marker)))))
+
+(defun org-edna-finder/previous-sibling ()
+ (org-with-wide-buffer
+ (and (org-get-last-sibling)
+ (list (point-marker)))))
+
+(defun org-edna-finder/first-child ()
+ (org-with-wide-buffer
+ (and (org-goto-first-child)
+ (list (point-marker)))))
+
+(defun org-edna-finder/children ()
+ (org-with-wide-buffer
+ (let ((markers))
+ (org-goto-first-child)
+ (push (point-marker) markers)
+ (while (org-get-next-sibling)
+ (push (point-marker) markers))
+ (nreverse markers))))
+
+(defun org-edna-finder/parent ()
+ (org-with-wide-buffer
+ (and (org-up-heading-safe)
+ (list (point-marker)))))
+
+(defun org-edna-finder/descendants ()
+ (org-with-wide-buffer
+ (org-map-entries
+ (lambda nil (point-marker))
+ nil 'tree)))
+
+(defun org-edna-finder/ancestors ()
+ "Find a list of ancestors.
+
+Example:
+
+* TODO Heading 1
+** TODO Heading 2
+*** TODO Heading 3
+**** TODO Heading 4
+***** TODO Heading 5
+ :PROPERTIES:
+ :BLOCKER: ancestors
+ :END:
+
+In the above example, Heading 5 will be blocked until Heading 1,
+Heading 3, and Heading 4 are marked DONE, while Heading 2 is
+ignored."
+ (org-with-wide-buffer
+ (let ((markers))
+ (while (org-up-heading-safe)
+ (push (point-marker) markers))
+ (nreverse markers))))
+
+(defun org-edna-finder/olp (file olp)
+ "Find a headline by its outline path.
+
+Finds the heading given by OLP in FILE. Both arguments are strings.
+
+* TODO Test
+ :PROPERTIES:
+ :BLOCKER: olp(\"test.org\" \"path/to/heading\")
+ :END:
+
+Test will block if the heading \"path/to/heading\" in
+\"test.org\" is not DONE."
+ (let ((marker (org-find-olp (cons file (split-string-and-unquote olp "/")))))
+ (when (markerp marker)
+ (list marker))))
+
+;; TODO: Clean up the buffer when it's finished
+
+(defun org-edna-finder/file (file)
+ "Find a file by name.
+
+The `file' finder finds a single file, specified as a string.
+The returned target will be the minimum point in the file.
+
+* TODO Test
+ :PROPERTIES:
+ :BLOCKER: file(\"~/myfile.org\") headings?
+ :END:
+
+Here, \"Test\" will block until myfile.org is clear of headlines.
+
+Note that with the default condition, `file' won't work."
+ ;; If there isn't a buffer visiting file, then there's no point in having a
+ ;; marker to the start of the file, so use `find-file-noselect'.
+ (with-current-buffer (find-file-noselect file)
+ (list (point-min-marker))))
+
+(defun org-edna-finder/org-file (file)
+ "Find a file in `org-directory'.
+
+A special form of `file', `org-file' will find FILE (a string) in
+`org-directory'.
+
+* TODO Test
+ :PROPERTIES:
+ :BLOCKER: org-file(\"test.org\")
+ :END:
+
+Note that the file still requires an extension."
+ (with-current-buffer (find-file-noselect (expand-file-name file
org-directory))
+ (list (point-min-marker))))
+
+(defun org-edna-finder/chain-find (&rest options)
+ "Find a target as org-depend does.
+
+Identical to the chain argument in org-depend, chain-find selects its single
+target using the following method:
+
+1. Creates a list of possible targets
+2. Filters the targets from Step 1
+3. Sorts the targets from Step 2
+
+After this is finished, chain-find selects the first target in the list and
+returns it.
+
+One option from each of the following three categories may be used; if more
than
+one is specified, the last will be used.
+
+*Selection*
+
+- from-top: Select siblings of the current headline, starting at the top
+- from-bottom: As above, but from the bottom
+- from-current: Selects siblings, starting from the headline (wraps)
+- no-wrap: As above, but without wrapping
+
+*Filtering*
+
+- todo-only: Select only targets with TODO state set that isn't a
DONE state
+- todo-and-done-only: Select all targets with a TODO state set
+
+*Sorting*
+
+- priority-up: Sort by priority, highest first
+- priority-down: Same, but lowest first
+- effort-up: Sort by effort, highest first
+- effort-down: Sort by effort, lowest first"
+ ;; sortfun - function to use to sort elements
+ ;; filterfun - Function to use to filter elements
+ ;; Both should handle positioning point
+ (let (targets
+ sortfun
+ ;; From org-depend.el:
+ ;; (and (not todo-and-done-only)
+ ;; (member (second item) org-done-keywords))
+ (filterfun (lambda (target)
+ (member (org-entry-get target "TODO")
org-done-keywords))))
+ (dolist (opt options)
+ (pcase opt
+ ('from-top
+ (setq targets (org-edna-finder/siblings)))
+ ('from-bottom
+ (setq targets (seq-reverse (org-edna-finder/siblings))))
+ ('from-current
+ (setq targets (org-edna-finder/siblings-wrap)))
+ ('no-wrap
+ (setq targets (org-edna-finder/rest-of-siblings)))
+ ('todo-only
+ ;; Remove any entry without a TODO keyword, or with a DONE keyword
+ (setq filterfun
+ (lambda (target)
+ (let ((kwd (org-entry-get target "TODO")))
+ (or (not kwd)
+ (member kwd org-done-keywords))))))
+ ('todo-and-done-only
+ ;; Remove any entry without a TODO keyword
+ (setq filterfun
+ (lambda (target)
+ (not (org-entry-get target "TODO")))))
+ ('priority-up
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((priority-lhs (org-entry-get lhs "PRIORITY"))
+ (priority-rhs (org-entry-get rhs "PRIORITY")))
+ (not (string-lessp priority-lhs priority-rhs))))))
+ ('priority-down
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((priority-lhs (org-entry-get lhs "PRIORITY"))
+ (priority-rhs (org-entry-get rhs "PRIORITY")))
+ (string-lessp priority-lhs priority-rhs)))))
+ ('effort-up
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((effort-lhs (org-duration-to-minutes (org-entry-get lhs
"EFFORT")))
+ (effort-rhs (org-duration-to-minutes (org-entry-get rhs
"EFFORT"))))
+ (not (< effort-lhs effort-rhs))))))
+ ('effort-down
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((effort-lhs (org-duration-to-minutes (org-entry-get lhs
"EFFORT")))
+ (effort-rhs (org-duration-to-minutes (org-entry-get rhs
"EFFORT"))))
+ (< effort-lhs effort-rhs)))))))
+ (when (and targets sortfun)
+ (setq targets (seq-sort sortfun targets)))
+ (when (and targets filterfun)
+ (setq targets (seq-remove filterfun targets)))
+ (when targets
+ (list (seq-elt 0 targets)))))
+
+
+
+;; Set TODO state
+(defun org-edna-action/todo! (last-entry new-state)
+ (ignore last-entry)
+ (org-todo (if (stringp new-state) new-state (symbol-name new-state))))
+
+;; Set planning info
+
+(defun org-edna--mod-timestamp (time-stamp n what)
+ (with-temp-buffer
+ (insert time-stamp)
+ (goto-char (point-min))
+ (org-timestamp-change n what)
+ (buffer-string)))
+
+(defun org-edna--get-planning-info (what)
+ (org-entry-get nil (if (eq what 'scheduled) "SCHEDULED" "DEADLINE")))
+
+(defun org-edna--handle-planning (type last-entry args)
+ ;; Need case-fold-search enabled so org-read-date-get-relative will
recognize "M"
+ (let* ((case-fold-search t)
+ (arg (nth 0 args))
+ (last-ts (org-with-point-at last-entry (org-edna--get-planning-info
type)))
+ (this-ts (org-edna--get-planning-info type))
+ (this-time (and this-ts (org-parse-time-string this-ts)))
+ (current (org-current-time))
+ (current-ts (format-time-string (org-time-stamp-format t) current))
+ (type-map '(("y" . year)
+ ("m" . month)
+ ("d" . day)
+ ("h" . hour)
+ ("M" . minute))))
+ (cond
+ ((member arg '(rm remove "rm" "remove"))
+ (org-add-planning-info nil nil type))
+ ((member arg '(cp copy "cp" "copy"))
+ (unless last-ts
+ (error "Tried to copy but last entry doesn't have a timestamp"))
+ ;; Copy old time verbatim
+ (org-add-planning-info type last-ts))
+ ((string-match-p "\\`[+-]" arg)
+ ;; Starts with a + or -, so assume we're incrementing a timestamp
+ ;; We support hours and minutes, so this must be supported separately,
+ ;; since org-read-date-analyze doesn't
+ (pcase-let* ((`(,n ,what-string ,def) (org-read-date-get-relative arg
this-time current))
+ (ts (if def current-ts this-ts))
+ (what (cdr (assoc-string what-string type-map))))
+ (org--deadline-or-schedule nil type (org-edna--mod-timestamp ts n
what))))
+ (t
+ ;; For everything else, assume `org-read-date-analyze' can handle it
+
+ ;; The third argument to `org-read-date-analyze' specifies the defaults
to
+ ;; use if that time component isn't specified. Since there's no way to
+ ;; tell if a time was specified, tell `org-read-date-analyze' to use nil
+ ;; if no time is found.
+ (let* ((parsed-time (org-read-date-analyze arg this-time '(nil nil nil
nil nil nil)))
+ (have-time (nth 2 parsed-time))
+ (final-time (apply 'encode-time (mapcar (lambda (e) (or e 0))
parsed-time)))
+ (new-ts (format-time-string (if have-time "%F %R" "%F")
final-time)))
+ (org--deadline-or-schedule nil type new-ts))))))
+
+(defun org-edna-action/scheduled! (last-entry &rest args)
+ (org-edna--handle-planning 'scheduled last-entry args))
+
+(defun org-edna-action/deadline! (last-entry &rest args)
+ (org-edna--handle-planning 'deadline last-entry args))
+
+(defun org-edna-action/tag! (last-entry tags)
+ (ignore last-entry)
+ (org-set-tags-to tags))
+
+(defun org-edna-action/set-property! (last-entry property value)
+ (ignore last-entry)
+ (org-entry-put nil property value))
+
+(defun org-edna-action/delete-property! (last-entry property)
+ (ignore last-entry)
+ (org-entry-delete nil property))
+
+(defun org-edna-action/clock-in! (last-entry)
+ (ignore last-entry)
+ (org-clock-in))
+
+(defun org-edna-action/clock-out! (last-entry)
+ (ignore last-entry)
+ (org-clock-out))
+
+(defun org-edna-action/set-priority! (last-entry priority-action)
+ "PRIORITY-ACTION is passed straight to `org-priority'."
+ (ignore last-entry)
+ (org-priority (if (stringp priority-action)
+ (string-to-char priority-action)
+ priority-action)))
+
+(defun org-edna-action/set-effort! (last-entry value)
+ (ignore last-entry)
+ (if (eq value 'increment)
+ (org-set-effort nil value)
+ (org-set-effort value nil)))
+
+(defun org-edna-action/archive! (last-entry)
+ (ignore last-entry)
+ (if org-edna-prompt-for-archive
+ (org-archive-subtree-default-with-confirmation)
+ (org-archive-subtree-default)))
+
+(defun org-edna-action/chain! (last-entry property)
+ (when-let ((old-prop (org-entry-get last-entry property)))
+ (org-entry-put nil property old-prop)))
+
+
+
+;; For most conditions, we return true if condition is true and neg is false,
or
+;; if condition is false and neg is true:
+
+;; | cond | neg | res |
+;; |------+-----+-----|
+;; | t | t | f |
+;; | t | f | t |
+;; | f | t | t |
+;; | f | f | f |
+
+;; This means that we want to take the exclusive-or of condition and neg.
+
+(defun org-edna-condition/done? (neg)
+ (when-let ((condition
+ (if neg
+ (member (org-entry-get nil "TODO") org-not-done-keywords)
+ (member (org-entry-get nil "TODO") org-done-keywords))))
+ (org-get-heading)))
+
+(defun org-edna-condition/todo-state? (neg state)
+ (let ((condition (string-equal (org-entry-get nil "TODO") state)))
+ (when (org-xor condition neg)
+ (org-get-heading))))
+
+;; Block if there are headings
+(defun org-edna-condition/headings? (neg)
+ (let ((condition (not (seq-empty-p (org-map-entries (lambda nil t))))))
+ (when (org-xor condition neg)
+ (buffer-name))))
+
+(defun org-edna-condition/variable-set? (neg var val)
+ (let ((condition (equal (symbol-value var) val)))
+ (when (org-xor condition neg)
+ (format "%s %s= %s" var (if neg "!" "=") val))))
+
+(defun org-edna-condition/has-property? (neg prop val)
+ (let ((condition (string-equal (org-entry-get nil prop) val)))
+ (when (org-xor condition neg)
+ (org-get-heading))))
+
+(defun org-edna-condition/re-search? (neg match)
+ (let ((condition (re-search-forward match nil t)))
+ (when (org-xor condition neg)
+ (format "%s %s in %s" (if neg "Did Not Find" "Found") match
(buffer-name)))))
+
+
+
+(defun org-edna-handle-consideration (consideration blocks)
+ (let ((first-block (seq-find #'identity blocks))
+ (total-blocks (seq-length blocks)))
+ (pcase consideration
+ ('all
+ ;; All of them must be fulfilled, so find the first one that isn't.
+ first-block)
+ ((pred integerp)
+ ;; A fixed number of them must be fulfilled, so check how many aren't.
+ (let* ((fulfilled (seq-count #'not blocks)))
+ (if (>= fulfilled consideration)
+ nil
+ first-block)))
+ ((pred floatp)
+ ;; A certain percentage of them must be fulfilled
+ (let* ((fulfilled (seq-count #'not blocks)))
+ (if (>= (/ (float fulfilled) (float total-blocks)) consideration)
+ nil
+ first-block))))))
+
+
+
+(declare-function lm-report-bug "lisp-mnt" (topic))
+
+(defun org-edna-submit-bug-report (topic)
+ (interactive "sTopic: ")
+ (require 'lisp-mnt)
+ (let* ((src-file (locate-library "org-edna.el" t))
+ (src-buf-live (find-buffer-visiting src-file))
+ (src-buf (find-file-noselect src-file)))
+ (with-current-buffer src-buf
+ (lm-report-bug topic))
+ ;; Kill the buffer if it wasn't live
+ (unless src-buf-live
+ (kill-buffer src-buf))))
+
+(provide 'org-edna)
+
+;;; org-edna.el ends here
diff --git a/packages/org-edna/org-edna.org b/packages/org-edna/org-edna.org
new file mode 100644
index 0000000..bb31c85
--- /dev/null
+++ b/packages/org-edna/org-edna.org
@@ -0,0 +1,876 @@
+#+TITLE: Org Edna
+#+AUTHOR: Ian Dunn
+#+EMAIL: address@hidden
+#+DATE: {{{modification-time}}}
+
+#+STARTUP: overview
+#+STARTUP: indent
+#+TODO: FIXME | FIXED
+#+OPTIONS: toc:2 num:nil timestamp:nil \n:nil |:t ':t email:t
+#+OPTIONS: *:t <:t d:nil todo:nil pri:nil tags:not-in-toc
+
+#+TEXINFO_DIR_CATEGORY: Emacs
+#+TEXINFO_DIR_TITLE: Org Edna: (edna)
+#+TEXINFO_DIR_DESC: Extensible Dependencies 'N' Actions for Org Mode tasks
+
+* Copying
+Copyright (C) 2017 Ian Dunn
+
+#+BEGIN_QUOTE
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+#+END_QUOTE
+* Introduction
+:PROPERTIES:
+:CUSTOM_ID: introduction
+:DESCRIPTION: A Brief Introduction to Edna
+:END:
+
+Extensible Dependencies 'N' Actions (EDNA) for Org Mode tasks
+
+Edna provides an extensible means of specifying conditions which must be
+fulfilled before a task can be completed and actions to take once it is.
+
+Org Edna runs when either the BLOCKER or TRIGGER properties are set on a
+headline, and when it is changing from a TODO state to a DONE state.
+
+For brevity, we use TODO state to indicate any state in
~org-not-done-keywords~,
+and DONE state to indicate any state in ~org-done-keywords~.
+
+** Installation and Setup
+:PROPERTIES:
+:DESCRIPTION: How to install Edna
+:END:
+
+*Requirements*
+
+| Emacs | 25.1 |
+| seq | 2.19 |
+| org | 9.0.5 |
+
+Right now, the only way to install Edna is by cloning the bazaar repo:
+
+#+BEGIN_SRC shell
+bzr branch https://bzr.savannah.gnu.org/r/org-edna-el/ org-edna
+make -C org-edna compile autoloads
+#+END_SRC
+
+After that, add the following to your init file (typically .emacs):
+
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'load-path "/full/path/to/org-edna/")
+(load "/path/to/org-edna/org-edna-autoloads.el")
+(org-edna-load)
+#+END_SRC
+
+If you ever want to disable Edna, run ~org-edna-unload~.
+
+** Basic Operation
+:PROPERTIES:
+:CUSTOM_ID: operation
+:DESCRIPTION: How to use Edna
+:END:
+
+Let's start with an example: Say you want to do laundry, but once you've put
+your clothes in the washer, you forget about it. Even with a tool like
+org-notify or appt, Org won't know when to remind you. If you've got them
+scheduled for an hour after the other, maybe you forgot one time, or ran a
+little late. Now Org will remind you too early.
+
+Edna can handle this for you like so:
+
+#+BEGIN_SRC org
+,* TODO Put clothes in washer
+ SCHEDULED: <2017-04-08 Sat 09:00>
+ :PROPERTIES:
+ :TRIGGER: next-sibling scheduled!("++1h")
+ :END:
+,* TODO Put clothes in dryer
+ :PROPERTIES:
+ :TRIGGER: next-sibling scheduled!("++1h")
+ :BLOCKER: previous-sibling
+ :END:
+,* TODO Fold laundry
+ :PROPERTIES:
+ :TRIGGER: next-sibling scheduled!("++1h")
+ :BLOCKER: previous-sibling
+ :END:
+,* TODO Put clothes away
+ :PROPERTIES:
+ :TRIGGER: next-sibling scheduled!("++1h")
+ :BLOCKER: previous-sibling
+ :END:
+#+END_SRC
+
+After you've put your clothes in the washer and mark the task DONE, Edna will
+schedule the following task for one hour after you set the first headline as
+done.
+
+Another example might be a checklist that you've done so many times that you do
+part of it on autopilot:
+
+#+BEGIN_SRC org
+,* TODO Address all TODOs in code
+,* TODO Commit Code to Repository
+#+END_SRC
+
+The last thing anyone wants is to find out that some part of the code on which
+they've been working for days has a surprise waiting for them. Once again,
Edna
+can help:
+
+#+BEGIN_SRC org
+,* TODO Address all TODOs in code
+ :PROPERTIES:
+ :BLOCKER: file("main.cpp") file("code.cpp") re-search?("TODO")
+ :END:
+,* TODO Commit Code to Repository
+#+END_SRC
+
+** Blockers
+:PROPERTIES:
+:CUSTOM_ID: blockers
+:DESCRIPTION: Blocking a TODO Item
+:END:
+
+A blocker indicates conditions which must be met in order for a headline to be
+marked as DONE. Typically, this will be a list of headlines that must be
marked
+as DONE.
+
+** Triggers
+:PROPERTIES:
+:CUSTOM_ID: triggers
+:DESCRIPTION: Triggering actions after completing a task
+:END:
+
+A trigger is an action to take when a headline is set to done. For example,
+scheduling another task, marking another task as TODO, or renaming a file.
+
+** Syntax
+:PROPERTIES:
+:CUSTOM_ID: syntax
+:DESCRIPTION: Basic explanation of Edna's syntax
+:END:
+#+cindex: syntax
+
+Edna has its own language for commands, the basic form of which is
KEYWORD(ARG1 ARG2 ...)
+
+KEYWORD can be any valid lisp symbol, such as key-word, KEY_WORD!, or keyword?.
+
+Each argument can be one of the following:
+
+- A symbol, such as arg or org-mode
+- A quoted string, such as "hello" or "My name is Edna"
+- A number, such as 0.5, +1e3, or -5
+- A UUID, such as c5e30c76-879a-494d-9281-3a4b559c1a3c
+
+Each argument takes specific datatypes as input, so be sure to read the entry
+before using it.
+
+The parentheses can be omitted for commands with no arguments.
+* Basic Features
+:PROPERTIES:
+:CUSTOM_ID: basic
+:DESCRIPTION: Finders and Actions
+:END:
+
+The most basic features of Edna are *finders* and *actions*.
+
+** Finders
+:PROPERTIES:
+:DESCRIPTION: How to find targets
+:CUSTOM_ID: finders
+:END:
+A finder specifies locations from which to test conditions or perform actions.
+These locations are referred to as "targets".
+
+More than one finder may be used. In this case, the targets are merged
+together, removing any duplicates.
+
+*** ancestors
+:PROPERTIES:
+:DESCRIPTION: Find a list of ancestors
+:CUSTOM_ID: ancestors
+:END:
+
+Syntax: ancestors
+
+The ~ancestors~ finder returns a list of the current headline's ancestors.
+
+For example:
+
+#+BEGIN_SRC org
+,* TODO Heading 1
+,** TODO Heading 2
+,** TODO Heading 3
+,*** TODO Heading 4
+,**** TODO Heading 5
+ :PROPERTIES:
+ :BLOCKER: ancestors
+ :END:
+#+END_SRC
+
+In the above example, "Heading 5" will be blocked until "Heading 1", "Heading
+3", and "Heading 4" are marked "DONE", while "Heading 2" is ignored.
+
+*** chain-find
+:PROPERTIES:
+:CUSTOM_ID: chain-find
+:DESCRIPTION: Find a target as org-depend does
+:END:
+
+Syntax: chain-find(OPTION OPTION...)
+
+Identical to the chain argument in org-depend, chain-find selects its single
+target using the following method:
+
+1. Creates a list of possible targets
+2. Filters the targets from Step 1
+3. Sorts the targets from Step 2
+
+After this is finished, chain-find selects the first target in the list and
+returns it.
+
+One option from each of the following three categories may be used; if more
than
+one is specified, the last will be used.
+
+*Selection*
+
+- from-top: Select siblings of the current headline, starting at the top
+- from-bottom: As above, but from the bottom
+- from-current: Selects siblings, starting from the headline (wraps)
+- no-wrap: As above, but without wrapping
+
+*Filtering*
+
+- todo-only: Select only targets with TODO state set that isn't a
DONE keyword
+- todo-and-done-only: Select all targets with a TODO state set
+
+*Sorting*
+
+- priority-up: Sort by priority, highest first
+- priority-down: Same, but lowest first
+- effort-up: Sort by effort, highest first
+- effort-down: Sort by effort, lowest first
+
+*** children
+:PROPERTIES:
+:CUSTOM_ID: children
+:DESCRIPTION: Find all immediate children
+:END:
+
+Syntax: children
+
+The ~children~ finder returns a list of the *immediate* children of the current
+headline.
+
+In order to get all levels of children of the current headline, use the
+[[#descendants][descendants]] keyword instead.
+
+*** descendants
+:PROPERTIES:
+:CUSTOM_ID: descendants
+:DESCRIPTION: Find all descendants
+:END:
+
+Syntax: descendants
+
+The ~descendants~ finder returns a list of all descendants of the current
+headline.
+
+#+BEGIN_SRC org
+,* TODO Heading 1
+ :PROPERTIES:
+ :BLOCKER: descendants
+ :END:
+,** TODO Heading 2
+,*** TODO Heading 3
+,**** TODO Heading 4
+,***** TODO Heading 5
+#+END_SRC
+
+In the above example, "Heading 1" will block until Headings 2, 3, 4, and 5 are
+DONE.
+
+*** file
+:PROPERTIES:
+:CUSTOM_ID: file
+:DESCRIPTION: Find a file by name
+:END:
+
+- Syntax: file("FILE")
+
+The ~file~ finder finds a single file, specified as a string. The returned
target
+will be the minimum point in the file.
+
+Note that with the default condition, ~file~ won't work. See
[[#conditions][conditions]] for how
+to set a different condition. For example:
+
+#+BEGIN_SRC org
+,* TODO Test
+ :PROPERTIES:
+ :BLOCKER: file("~/myfile.org") headings?
+ :END:
+#+END_SRC
+
+Here, "Test" will block until myfile.org is clear of headlines.
+
+*** first-child
+:PROPERTIES:
+:CUSTOM_ID: first-child
+:DESCRIPTION: Find the first child of a headline
+:END:
+
+- Syntax: first-child
+
+The ~first-child~ finder returns the first child of a headline, if any.
+
+*** ids
+:PROPERTIES:
+:DESCRIPTION: Find a list of headlines with given IDs
+:CUSTOM_ID: ids
+:END:
+
+- Syntax: id(ID1 ID2 ...)
+
+The ~ids~ finder will search for headlines with given IDs, using ~org-id~. Any
+number of UUIDs may be specified. For example:
+
+#+BEGIN_SRC org
+,* TODO Test
+ :PROPERTIES:
+ :BLOCKER: ids(62209a9a-c63b-45ef-b8a8-12e47a9ceed9
6dbd7921-a25c-4e20-b035-365677e00f30)
+ :END:
+#+END_SRC
+
+Here, "Test" will block until the headline with ID
+62209a9a-c63b-45ef-b8a8-12e47a9ceed9 and the headline with ID
+6dbd7921-a25c-4e20-b035-365677e00f30 are set to "DONE".
+
+Note that UUIDs need not be quoted; Edna will handle that for you.
+
+*** match
+:PROPERTIES:
+:CUSTOM_ID: match
+:DESCRIPTION: Good old tag matching
+:END:
+
+- Syntax: match("MATCH-STRING" SCOPE SKIP)
+
+The ~match~ keyword will take any arguments that ~org-map-entries~ usually
takes.
+In fact, the arguments to ~match~ are passed straight into ~org-map-entries~.
+
+#+BEGIN_SRC org
+,* TODO Test
+ :PROPERTIES:
+ :BLOCKER: match("test&mine" agenda)
+ :END:
+#+END_SRC
+
+"Test" will block until all entries tagged "test" and "mine" in the agenda
files
+are marked DONE.
+
+See the documentation for ~org-map-entries~ for a full explanation of the first
+argument.
+
+*** next-sibling
+:PROPERTIES:
+:CUSTOM_ID: next-sibling
+:DESCRIPTION: Find the next sibling
+:END:
+
+- Syntax: next-sibling
+
+The ~next-sibling~ keyword returns the next sibling of the current heading, if
+any.
+
+*** olp
+:PROPERTIES:
+:CUSTOM_ID: olp
+:DESCRIPTION: Find a headline by its outline path
+:END:
+
+- Syntax: olp("FILE" "OLP")
+
+Finds the heading given by OLP in FILE. Both arguments are strings.
+
+#+BEGIN_SRC org
+,* TODO Test
+ :PROPERTIES:
+ :BLOCKER: olp("test.org" "path/to/heading")
+ :END:
+#+END_SRC
+
+"Test" will block if the heading "path/to/heading" in "test.org" is not DONE.
+
+*** org-file
+:PROPERTIES:
+:CUSTOM_ID: org-file
+:DESCRIPTION: Find a file in org-directory
+:END:
+
+- Syntax: org-file("FILE")
+
+A special form of ~file~, ~org-file~ will find FILE in ~org-directory~.
+
+#+BEGIN_SRC org
+,* TODO Test
+ :PROPERTIES:
+ :BLOCKER: org-file("test.org")
+ :END:
+#+END_SRC
+
+Note that the file still requires an extension.
+
+*** parent
+:PROPERTIES:
+:CUSTOM_ID: parent
+:DESCRIPTION: Find a parent
+:END:
+
+- Syntax: parent
+
+Returns the parent of the current headline, if any.
+
+*** previous-sibling
+:PROPERTIES:
+:CUSTOM_ID: previous-sibling
+:DESCRIPTION: Find the previous sibling
+:END:
+
+- Syntax: previous-sibling
+
+Returns the previous sibling of the current headline on the same level.
+
+*** rest-of-siblings
+:PROPERTIES:
+:CUSTOM_ID: rest-of-siblings
+:DESCRIPTION: Find the remaining siblings
+:END:
+
+- Syntax: rest-of-siblings
+
+Starting from the headline following the current one, all same-level siblings
+are returned.
+
+*** self
+:PROPERTIES:
+:CUSTOM_ID: self
+:END:
+
+- Syntax: self
+
+Returns the current headline.
+
+*** siblings
+:PROPERTIES:
+:CUSTOM_ID: siblings
+:DESCRIPTION: Find all the siblings
+:END:
+
+- Syntax: siblings
+
+Returns all siblings of the source heading as targets.
+
+*** siblings-wrap
+:PROPERTIES:
+:CUSTOM_ID: siblings-wrap
+:DESCRIPTION: Find the siblings, but wrap around
+:END:
+
+- Syntax: siblings-wrap
+
+Finds the siblings on the same level as the current headline, wrapping when it
+reaches the end.
+
+** Actions
+:PROPERTIES:
+:DESCRIPTION: Next steps
+:END:
+Once Edna has collected its targets for a trigger, it will perform actions on
+them.
+
+Actions must always end with '!'.
+
+*** Scheduled/Deadline
+:PROPERTIES:
+:CUSTOM_ID: planning
+:END:
+
+- Syntax: scheduled!(OPTIONS)
+- Syntax: deadline!(OPTIONS)
+
+There are several forms that the planning keywords can take:
+
+- PLANNING("WKDY[ TIME]")
+
+ Sets PLANNING to the following weekday WKDY at TIME. If TIME is not
+ specified, only a date will be added to the target.
+
+ WKDY is a weekday or weekday abbreviation (see ~org-read-date~)
+
+ TIME is a time string HH:MM, etc.
+
+- PLANNING(rm|remove)
+
+ Remove PLANNING from all targets. The argument to this form may be either a
+ string or a symbol.
+
+- PLANNING(copy|cp)
+
+ Copy PLANNING info verbatim from the current headline to all targets. The
+ argument to this form may be either a string or a symbol.
+
+- PLANNING("[+|-][+|-]NTHING")
+
+ Increment(+) or decrement(-) source (double) or current (single) PLANNING by
N
+ THINGs
+
+ N is an integer
+
+ THING is one of y (years), m (months), d (days), h (hours), or M (minutes)
+
+Examples:
+
+scheduled!("Mon 09:00") -> Set SCHEDULED to the following Monday at 9:00
+*** TODO State
+
+- Syntax: todo!(NEW-STATE)
+
+Sets the TODO state of the target headline to NEW-STATE.
+
+NEW-STATE may either be a string or a symbol denoting the new TODO state.
+
+*** Archive
+:PROPERTIES:
+:CUSTOM_ID: archive!
+:END:
+
+- Syntax: archive!
+
+Archives all targets with confirmation.
+
+Confirmation is controlled with ~org-edna-prompt-for-archive~. If this option
is
+nil, Edna will not ask before archiving the target.
+
+*** Chain Property
+
+- Syntax: chain!("PROPERTY")
+
+Copies PROPERTY from the source entry to all targets.
+
+*** Clocking
+
+- Syntax: clock-in!
+- Syntax: clock-out!
+
+Clocks into or out of all targets.
+
+~clock-in!~ has no special handling of targets, so be careful when specifying
+multiple targets.
+
+*** Property
+
+- Syntax: set-property!("PROPERTY","VALUE")
+
+Sets the property PROPERTY on all targets to VALUE.
+
+- Syntax: delete-property!("PROPERTY")
+
+Deletes the property PROPERTY from all targets.
+
+*** Priority
+
+- Syntax: set-priority!(PRIORITY)
+
+Sets the priority of all targets to PRIORITY. PRIORITY is processed as
follows:
+
+- If PRIORITY is a string, the first character is used as the priority
+- Any other value is passed into ~org-priority~ verbatim, so it can be 'up,
'down, or an integer
+
+*** Tag
+
+- Syntax: tag!("TAG-SPEC")
+
+Tags all targets with TAG-SPEC, which is any valid tag specification,
+e.g. tag1:tag2
+
+*** Effort
+
+- Syntax: set-effort!(VALUE)
+
+Sets the effort of all targets according to VALUE:
+
+- If VALUE is a string, then the effort is set to VALUE
+- If VALUE is an integer, then set the value to the VALUE'th allowed effort
property
+- If VALUE is the symbol 'increment, increment effort
+
+* Advanced Features
+:PROPERTIES:
+:CUSTOM_ID: advanced
+:END:
+** Conditions
+:PROPERTIES:
+:CUSTOM_ID: conditions
+:END:
+
+Edna gives you he option to specify *blocking conditions*. Each condition is
checked
+for each of the specified targets; if one of the conditions returns true for
+that target, then that headline is blocked.
+
+*** done
+:PROPERTIES:
+:CUSTOM_ID: done
+:END:
+
+- Syntax: done?
+
+Blocks the current headline if any target is DONE.
+
+*** headings
+:PROPERTIES:
+:CUSTOM_ID: headings
+:END:
+
+- Syntax: headings?
+
+Blocks the current headline if any target belongs to a file that has an Org
heading.
+
+#+BEGIN_EXAMPLE
+org-file("refile.org") headings?
+#+END_EXAMPLE
+
+The above example blocks if refile.org has any headings.
+
+*** todo-state
+:PROPERTIES:
+:CUSTOM_ID: todo-state
+:END:
+
+- Syntax: todo-state?(STATE)
+
+Blocks if any target has a headline with TODO state set to STATE.
+
+STATE may be a string or a symbol.
+
+*** variable-set
+:PROPERTIES:
+:CUSTOM_ID: variable-set
+:END:
+
+- Syntax: variable-set?(VARIABLE,VALUE)
+
+Blocks the current headline if VARIABLE is set to VALUE.
+
+VARIABLE should be a symbol, and VALUE is any valid lisp expression
+
+#+BEGIN_EXAMPLE
+self variable-set?(test-variable,12)
+#+END_EXAMPLE
+
+*** has-property
+:PROPERTIES:
+:CUSTOM_ID: has-property
+:END:
+
+- Syntax: has-property?("PROPERTY","VALUE")
+
+Tests each target for the property PROPERTY, and blocks if it's set to VALUE.
+
+*** re-search
+:PROPERTIES:
+:CUSTOM_ID: re-search
+:DESCRIPTION: Search for a regular expression
+:END:
+
+- Syntax: re-search?("REGEXP")
+
+Blocks the current headline if the regular expression REGEXP is present in any
+of the targets.
+
+The targets are expected to be files, although this will work with other
targets
+as well.
+
+*** Negating Conditions
+:PROPERTIES:
+:CUSTOM_ID: negate
+:END:
+Any condition can be negated using '!'.
+
+#+BEGIN_EXAMPLE
+match("test") !has-property?("PROP","1")
+#+END_EXAMPLE
+
+The above example will cause the current headline to block if any headline
+tagged "test" does *not* have the property PROP set to "1".
+** Consideration
+Special keyword that's only valid for blockers.
+
+This keyword can allow specifying only a portion of tasks to consider:
+
+1. consider(PERCENT)
+2. consider(NUMBER)
+3. consider(all) (Default)
+
+(1) tells the blocker to only consider some portion of the targets. If at
least
+PERCENT of them are in a DONE state, allow the task to be set to DONE. PERCENT
+must be a decimal.
+
+(2) tells the blocker to only consider NUMBER of the targets.
+
+(3) tells the blocker to consider all following targets.
+
+A consideration must be specified before the targets to which it applies:
+
+#+BEGIN_EXAMPLE
+consider(0.5) siblings consider(all) match("find_me")
+#+END_EXAMPLE
+
+The above code will allow task completion if at least half the siblings are
+complete, and all tasks tagged "find_me" are complete.
+
+#+BEGIN_SRC emacs-lisp
+consider(1) ids(ID1 ID2 ID3) consider(2) ids(ID3 ID4 ID5 ID6)
+#+END_SRC
+
+The above code will allow task completion if at least one of ID1, ID2, and ID3
+are complete, and at least two of ID3, ID4, ID5, and ID6 are complete.
+
+If no consideration is given, ALL is assumed.
+* Extending Edna
+:PROPERTIES:
+:DESCRIPTION: What else can it do?
+:END:
+
+Extending Edna is (relatively) simple.
+
+During operation, Edna searches for functions of the form
org-edna-TYPE/KEYWORD.
+
+** Naming Conventions
+:PROPERTIES:
+:DESCRIPTION: How to name new functions
+:END:
+
+In order to distinguish between actions, finders, and conditions, we add '?' to
+conditions and '!' to actions. This is taken from the practice in Guile and
+Scheme to suffix destructive functions with '!' and predicates with '?'.
+
+Thus, one can have an action that files a target, and a finder that finds a
+file.
+
+** Finders
+:PROPERTIES:
+:DESCRIPTION: Making a new finder
+:END:
+
+Finders have the form org-edna-finder/KEYWORD, like so:
+
+#+BEGIN_SRC emacs-lisp
+(defun org-edna-finder/test-finder ()
+ (list (point-marker)))
+#+END_SRC
+
+All finders must return a list of markers, one for each target found, or nil if
+no targets were found.
+
+** Actions
+:PROPERTIES:
+:DESCRIPTION: Making a new action
+:END:
+
+Actions have the form org-edna-action/KEYWORD!:
+
+#+BEGIN_SRC emacs-lisp
+(defun org-edna-action/test-action! (last-entry arg1 arg2)
+ )
+#+END_SRC
+
+Each action has at least one argument: ~last-entry~. This is a marker for the
+current entry (not to be confused with the current target).
+
+The rest of the arguments are the arguments specified in the form.
+
+** Conditions
+:PROPERTIES:
+:DESCRIPTION: Making a new condition
+:END:
+
+#+BEGIN_SRC emacs-lisp
+(defun org-edna-condition/test-cond? (neg))
+#+END_SRC
+
+All conditions have at least one argument, "NEG". If NEG is non-nil, the
+condition should be negated.
+
+Most conditions have the following form:
+
+#+BEGIN_SRC emacs-lisp
+(defun org-edna-condition/test-condition? (neg)
+ (let ((condition (my-test-for-condition)))
+ (when (org-xor condition neg)
+ (string-for-blocking-entry-here))))
+#+END_SRC
+
+For conditions, we return true if condition is true and neg is false, or if
+condition is false and neg is true:
+
+| cond | neg | res |
+|------+-----+-----|
+| t | t | f |
+| t | f | t |
+| f | t | t |
+| f | f | f |
+
+This is an XOR table, so we pass CONDITION and NEG into ~org-xor~ to get our
+result.
+
+A condition must return a string if the current entry should be blocked.
+* Contributing
+:PROPERTIES:
+:DESCRIPTION: I wanna help!
+:END:
+
+We are all happy for any help you may provide.
+
+First, check out the source code on Savannah:
https://savannah.nongnu.org/projects/org-edna-el/
+
+#+BEGIN_SRC shell
+bzr branch https://bzr.savannah.gnu.org/r/org-edna-el/ org-edna
+#+END_SRC
+
+You'll also want a copy of the most recent Org Mode source:
+
+#+BEGIN_SRC shell
+git clone git://orgmode.org/org-mode.git
+#+END_SRC
+
+*Bugs*
+
+There are two ways to submit bug reports:
+
+1. Using the bug tracker at Savannah
+2. Sending an email using ~org-edna-submit-bug-report~
+
+When submitting a bug report, be sure to include the Edna form that caused the
+bug, with as much context as possible.
+
+*Development*
+
+Submitting patches along with a bug report is the easiest way.
+
+There are a few rules to follow:
+
+- Verify that any new Edna keywords follow the appropriate naming conventions
+- Any new keywords should be documented
+- Run 'make check' to verify that your mods don't break anything
+- Avoid additional or altered dependencies if at all possible
+ - Exception: New versions of Org mode are allowed
- [elpa] scratch/org-edna 50652ab 58/72: Added installation and setup instructions to documentation, (continued)
- [elpa] scratch/org-edna 50652ab 58/72: Added installation and setup instructions to documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 191c938 41/72: Added copyright and licensing information to all files, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 7e1dafb 44/72: Fixed license blocks in elisp files, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 831ef13 54/72: Fixed variable-set condition, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 628869b 56/72: Fixed error reporting, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna a82892c 47/72: Fixed bugs from last commit, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna e3d2e89 61/72: Documented delete-property! action, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 0035a7b 46/72: Various parsing fixes, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna b4d1b1f 70/72: Added more docstrings, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 226195b 68/72: Added docstrings to some finders, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 901a84a 72/72: Add 'packages/org-edna/' from commit 'ce425a365cc305142a6ec7ec95ebe5fd636100e3',
Ian Dunn <=