pkg update and first config fix

org-brain not working, add org-roam
This commit is contained in:
2022-12-19 23:02:34 +01:00
parent 02b3e07185
commit 82f05baffe
885 changed files with 356098 additions and 36993 deletions

View File

@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
<https://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
<https://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,198 @@
This repository contains add-ons to Org.
You can use them by installing the `org-contrib' NonGNU ELPA package
from <https://elpa.nongnu.org/nongnu/>.
1 Please help maintaining these add-ons
═══════════════════════════════════════
Files in this repository used to live in the Org repository but have
been filtered out of the Org 9.5 release. The `contrib/' directory
used to contain a `scripts/' directory that now lives on [the Worg
repository].
*Files in this repository receive little if no maintainance and there
is no guaranty that they are compatible with the Org stable version.*
For files a `Maintainer' header and a `Homepage' pointing outside of
this repository are in transition: they are maintained and will be
removed from the next minor or major release of this repository. As a
user, please carefully track the new URL where the add-on is now
maintained.
If you want to maintain some of these add-ons, please send me an email
at `bzg@gnu.org' once you set up a separate repository for them.
[the Worg repository]
<https://code.orgmode.org/bzg/worg/src/master/code>
2 License
═════════
All files in this repository are licensed under the GNU General Public
License, either version 3 of the License, or (at your option) any
later version. See [COPYING].
[COPYING] <file:COPYING>
3 Files to remove from the next release
═══════════════════════════════════════
If a file has a "Homepage:" keyword, it will be removed from the next
minor or major release.
4 Other files
═════════════
4.1 Org utils
─────────────
org-annotate-file.el
Annotate a file with org syntax
org-bibtex-extras.el
Extras for working with org-bibtex entries
org-checklist.el
org functions for checklist handling
org-choose.el
Use TODO keywords to mark decision states
org-collector.el
Collect properties into tables
org-contribdir.el
Dummy file to mark the org contrib Lisp directory
org-depend.el
TODO dependencies for Org-mode
org-effectiveness.el
Measuring your personal effectiveness
org-eldoc.el
Eldoc documentation for SRC blocks
org-eval.el
The <lisp> tag, adapted from Muse
org-eval-light.el
Evaluate in-buffer code on demand
org-expiry.el
Expiry mechanism for Org entries
org-git-link.el
Provide org links to specific file version
org-interactive-query.el
Interactive modification of tags query
org-invoice.el
Help manage client invoices in OrgMode
org-learn.el
SuperMemo's incremental learning algorithm
org-license.el
Insert free licenses to your org documents
org-mac-iCal.el
Imports events from iCal.app to the Emacs diary
org-mairix.el
Hook mairix search into Org for different MUAs
org-panel.el
Simple routines for us with bad memory
org-registry.el
A registry for Org links
org-screen.el
Visit screen sessions through Org-mode links
org-screenshot.el
Take and manage screenshots in Org-mode files
org-secretary.el
Team management with org-mode
org-static-mathjax.el
Muse-like tags in Org-mode
org-sudoku.el
Create and solve SUDOKU puzzles in Org tables
org-toc.el
Table of contents for Org-mode buffer
org-track.el
Keep up with Org development
org-wikinodes.el
CamelCase wiki-like links for Org
4.2 Org exporters
─────────────────
ox-bibtex.el
Export bibtex fragments
ox-confluence.el
Confluence Wiki exporter
ox-deck.el
deck.js presentations exporter
ox-extra.el
Convenience functions for org export
ox-freemind.el
Freemind exporter
ox-groff.el
Groff exporter
ox-s5.el
S5 presentations exporter
ox-taskjuggler.el
TaskJuggler exporter
4.3 Org link
────────────
ol-bookmark.el
Links to bookmarks
ol-elisp-symbol.el
Links to Emacs-lisp symbols
ol-git-link.el
Links to specific file version
ol-mew.el
Links to Mew messages
ol-vm.el
Support for links to VM messages
ol-wl.el
Support for links to Wanderlust messages
4.4 Org Babel languages
───────────────────────
ob-abc.el
Org-mode Babel Functions for ABC
ob-asymptote.el
Org-mode Babel Functions for Asymptote
ob-coq.el
Org-mode Babel Functions for Coq
ob-csharp.el
Org-mode Babel Functions for csharp evaluation
ob-ebnf.el
Org-mode Babel Functions for EBNF
ob-eukleides.el
Org-mode Babel Functions for eukleides evaluation
ob-fomus.el
Org-mode Babel Functions for fomus evaluation
ob-hledger.el
Org-mode Babel Functions for hledger
ob-io.el
Org-mode Babel Functions for Io
ob-J.el
Org-mode Babel Functions for J
ob-ledger.el
Org-mode Babel Functions for Ledger
ob-mathomatic.el
Org-mode Babel Functions for mathomatic evaluation
ob-mscgen.el
Org-mode Babel Functions for Mscgen
ob-oz.el
Org-mode Babel Functions for Oz evaluation
ob-picolisp.el
Org-mode Babel Functions for Picolisp
ob-shen.el
Org-mode Babel Functions for Shen
ob-stan.el
Babel Functions for Stan
ob-stata.el
Org-mode Babel Functions for Stata evaluation
ob-tcl.el
Org-mode Babel Functions for tcl evaluation
ob-vala.el
Org-mode Babel Functions for Vala
ob-vbnet.el
Org-mode Babel Functions for VB.Net evaluation

View File

@@ -14,8 +14,8 @@ is no guaranty that they are compatible with the Org stable version.*
For files a =Maintainer= header and a =Homepage= pointing outside of this
repository are in transition: they are maintained and will be removed
from the next release of this repository. As a user, please carefully
track the new URL where the add-on is now maintained.
from the next minor or major release of this repository. As a user,
please carefully track the new URL where the add-on is now maintained.
If you want to maintain some of these add-ons, please send me an email
at =bzg@gnu.org= once you set up a separate repository for them.
@@ -28,36 +28,17 @@ later version. See [[file:COPYING][COPYING]].
** Files to remove from the next release
These files are maintained in a separate repository, which you can
find after the "Homepage:" keyword in the files themselves:
- ob-arduino.el :: Org-mode Babel support for Arduino
- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
- ob-mathematica.el :: org-babel functions for Mathematica evaluation
- ob-php.el :: Execute PHP within org-mode blocks
- ob-redis.el :: Execute Redis queries within org-mode blocks
- ob-sclang.el :: SCLang support for Org-mode Babel
- ob-smiles.el :: Org-mode Babel support for SMILES
- ob-spice.el :: org-babel functions for spice evaluation
- ol-notmuch.el :: Links to notmuch messages
- org-attach-embedded-images.el :: Transmute images to attachments
- org-link-edit.el :: Slurp and barf with Org links
- org-mac-link.el :: Insert org-mode links to items selected in various Mac apps
- org-notify.el :: Notifications for Org-mode
- org-passwords.el :: org derived mode for managing passwords
- org-velocity.el :: something like Notational Velocity for Org
- ox-rss.el :: RSS 2.0 Back-End for Org Export Engine
If a file has a "Homepage:" keyword, it will be removed from the next
minor or major release.
** Other files
*** Org utils
- org-annotate-file.el :: Annotate a file with org syntax
- org-attach-embedded-images.el :: Transmute images to attachments
- org-bibtex-extras.el :: Extras for working with org-bibtex entries
- org-checklist.el :: org functions for checklist handling
- org-choose.el :: Use TODO keywords to mark decision states
- org-collector.el :: Collect properties into tables
- org-contacts.el :: Contacts management
- org-contribdir.el :: Dummy file to mark the org contrib Lisp directory
- org-depend.el :: TODO dependencies for Org-mode
- org-effectiveness.el :: Measuring your personal effectiveness
@@ -70,13 +51,9 @@ find after the "Homepage:" keyword in the files themselves:
- org-invoice.el :: Help manage client invoices in OrgMode
- org-learn.el :: SuperMemo's incremental learning algorithm
- org-license.el :: Insert free licenses to your org documents
- org-link-edit.el :: Slurp and barf with Org links
- org-mac-iCal.el :: Imports events from iCal.app to the Emacs diary
- org-mac-link.el :: Grab links and URLs from various Mac applications
- org-mairix.el :: Hook mairix search into Org for different MUAs
- org-notify.el :: Notifications for Org-mode
- org-panel.el :: Simple routines for us with bad memory
- org-passwords.el :: Org derived mode for managing passwords
- org-registry.el :: A registry for Org links
- org-screen.el :: Visit screen sessions through Org-mode links
- org-screenshot.el :: Take and manage screenshots in Org-mode files
@@ -85,7 +62,6 @@ find after the "Homepage:" keyword in the files themselves:
- org-sudoku.el :: Create and solve SUDOKU puzzles in Org tables
- org-toc.el :: Table of contents for Org-mode buffer
- org-track.el :: Keep up with Org development
- org-velocity.el :: something like Notational Velocity for Org
- org-wikinodes.el :: CamelCase wiki-like links for Org
*** Org exporters
@@ -96,7 +72,6 @@ find after the "Homepage:" keyword in the files themselves:
- ox-extra.el :: Convenience functions for org export
- ox-freemind.el :: Freemind exporter
- ox-groff.el :: Groff exporter
- ox-rss.el :: RSS 2.0 exporter
- ox-s5.el :: S5 presentations exporter
- ox-taskjuggler.el :: TaskJuggler exporter
@@ -106,16 +81,13 @@ find after the "Homepage:" keyword in the files themselves:
- ol-elisp-symbol.el :: Links to Emacs-lisp symbols
- ol-git-link.el :: Links to specific file version
- ol-mew.el :: Links to Mew messages
- ol-notmuch.el :: Links to notmuch messages
- ol-vm.el :: Support for links to VM messages
- ol-wl.el :: Support for links to Wanderlust messages
*** Org Babel languages
- ob-abc.el :: Org-mode Babel Functions for ABC
- ob-arduino.el :: Org-mode Babel Functions for Arduino
- ob-asymptote.el :: Org-mode Babel Functions for Asymptote
- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
- ob-coq.el :: Org-mode Babel Functions for Coq
- ob-csharp.el :: Org-mode Babel Functions for csharp evaluation
- ob-ebnf.el :: Org-mode Babel Functions for EBNF
@@ -125,17 +97,11 @@ find after the "Homepage:" keyword in the files themselves:
- ob-io.el :: Org-mode Babel Functions for Io
- ob-J.el :: Org-mode Babel Functions for J
- ob-ledger.el :: Org-mode Babel Functions for Ledger
- ob-mathematica.el :: Org-mode Babel Functions for Mathematica evaluation
- ob-mathomatic.el :: Org-mode Babel Functions for mathomatic evaluation
- ob-mscgen.el :: Org-mode Babel Functions for Mscgen
- ob-oz.el :: Org-mode Babel Functions for Oz evaluation
- ob-php.el :: Execute PHP within org-mode blocks
- ob-picolisp.el :: Org-mode Babel Functions for Picolisp
- ob-redis.el :: Execute Redis queries within org-mode blocks
- ob-sclang.el :: SCLang support for Org-mode Babel
- ob-shen.el :: Org-mode Babel Functions for Shen
- ob-smiles.el :: Org-mode Babel support for SMILES
- ob-spice.el :: Org-mode Babel Functions for spice evaluation
- ob-stan.el :: Babel Functions for Stan
- ob-stata.el :: Org-mode Babel Functions for Stata evaluation
- ob-tcl.el :: Org-mode Babel Functions for tcl evaluation

View File

@@ -5,7 +5,7 @@
;; Author: Oleh Krehel
;; Maintainer: Joseph Novakovich <josephnovakovich@gmail.com>
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,117 +0,0 @@
;;; ob-arduino.el --- Org-mode Babel support for Arduino
;;
;; Authors: stardiviner <numbchild@gmail.com>
;; Package-Requires: ((emacs "24.4") (org "24.1"))
;; Package-Version: 1.0
;; Keywords: arduino org babel
;; homepage: https://github.com/stardiviner/arduino-mode/blob/master/ob-arduino.el
;;
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; Like the following src block, press =[C-c C-c]= to upload to Arduino board.
;;
;; #+begin_src arduino
;; // the setup function runs once when you press reset or power the board
;; void setup() {
;; // initialize digital pin LED_BUILTIN as an output.
;; pinMode(LED_BUILTIN, OUTPUT);
;; }
;;
;; // the loop function runs over and over again forever
;; void loop() {
;; digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
;; delay(100); // wait for 0.1 second
;; digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
;; delay(100); // wait for 0.1 second
;; }
;; #+end_src
;;
;;; Code:
(require 'org)
(require 'ob)
(require 'arduino-mode nil t)
(defgroup ob-arduino nil
"org-mode blocks for Arduino."
:group 'org)
(defcustom ob-arduino:program "arduino"
"Default Arduino program name."
:group 'ob-arduino
:type 'string)
(defcustom ob-arduino:port "/dev/ttyACM0"
"Default Arduino port."
:group 'ob-arduino
:type 'string)
(defcustom ob-arduino:board "arduino:avr:uno"
"Default Arduino board."
:group 'ob-arduino
:type 'string)
(defvar org-babel-default-header-args:sclang nil)
;;;###autoload
(defun org-babel-execute:arduino (body params)
"org-babel arduino hook."
(let* ((port (cdr (assoc :port params)))
(board (cdr (assoc :board params)))
(cmd (mapconcat 'identity (list
ob-arduino:program "--upload"
(if port (concat "--port " port))
(if board (concat "--board " board))
) " "))
(code (org-babel-expand-body:generic body params))
(src-file (org-babel-temp-file "ob-arduino-" ".ino")))
;; delete all `ob-arduino' temp files, otherwise arduino will compile all
;; ob-arduino temp files, and report error.
(mapc
(lambda (f)
(unless (file-directory-p f)
(delete-file (expand-file-name f org-babel-temporary-directory))))
(directory-files
(file-name-directory (org-babel-temp-file "ob-arduino-" ".ino"))
nil ".ino"))
;; specify file for arduino command.
(with-temp-file src-file
(insert code))
(org-babel-eval
(concat ob-arduino:program
" " "--upload"
" " (if port (concat "--port " port))
" " (if board (concat "--board " board))
" " src-file)
"" ; pass empty string "" as `BODY' to `org-babel--shell-command-on-region'
;; to fix command `arduino' don't accept string issue.
)
))
;;;###autoload
(eval-after-load 'org
'(add-to-list 'org-src-lang-modes '("arduino" . arduino)))
(provide 'ob-arduino)
;;; ob-arduino.el ends here

View File

@@ -3,9 +3,9 @@
;; Copyright (C) 2009-2021 Free Software Foundation, Inc.
;; Author: Eric Schulte
;; Maintainer: Luc Pellissier <luc.pellissier@crans.org>
;; Maintainer: Jarmo Hurri <jarmo.hurri@iki.fi>
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,306 +0,0 @@
;;; ob-clojure-literate.el --- Clojure's Org-mode Literate Programming
;; Authors: stardiviner <numbchild@gmail.com>
;; Package-Requires: ((emacs "24.4") (org "9") (cider "0.16.0") (dash "2.12.0"))
;; Package-Version: 1.1
;; Keywords: tools
;; homepage: https://github.com/stardiviner/ob-clojure-literate
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Auto setup ob-clojure-literate scaffold and jack-in Clojure project.
;;
;; Usage:
;;
;; [M-x ob-clojure-literate-mode] to toggle this minor mode.
;;; Code:
(require 'ob-clojure)
(require 'cider nil t)
(defgroup ob-clojure-literate nil
"Clojure's Org-mode Literate Programming."
:prefix "ob-clojure-literate-"
:group 'ob-babel)
;;;###autoload
(defcustom ob-clojure-literate-auto-jackin-p nil
"Auto jack in ob-clojure project.
Don't auto jack in by default for not rude."
:type 'boolean
:group 'ob-clojure-literate)
(defcustom ob-clojure-literate-project-location nil
"The location for `ob-clojure-literate' scaffold project.
If it is nil, then `cider-jack-in' will jack-in outside of Clojure project.
If it is a directory, `ob-clojure-literate' will try to create Clojure project automatically."
:type 'string
:group 'ob-clojure-literate)
(defvar ob-clojure-literate-session nil)
(defvar ob-clojure-literate-original-ns nil)
(defvar ob-clojure-literate-session-ns nil)
(defvar ob-clojure-literate-cider-connections nil)
(defcustom ob-clojure-literate-default-session "*cider-repl localhost*"
"The default session name for `ob-clojure-literate'."
:type 'string
:group 'ob-clojure-literate)
(defun ob-clojure-literate-any-connection-p ()
"Return t if have any CIDER connection."
(and
;; handle the case `cider-jack-in' is not finished creating connection, but `ob-clojure-literate-mode' is enabled.
(not (null (cider-connections)))
(not (null ob-clojure-literate-session)) ; before mode enabled, it is nil.
(not (string-empty-p ob-clojure-literate-session)) ; after disable, it is "".
))
(defun ob-clojure-literate-get-session-list ()
"Return a list of available started CIDER REPL sessions list."
(mapcar #'buffer-name
;; for multiple connections case.
;; get global value instead of buffer local.
(default-value 'cider-connections)))
;;; Do not allow "ob-clojure" project session name.
(defun ob-clojure-literate-set-session ()
"Set session name for buffer local."
;; if default session is the only one in connections list.
(if (and (= (length (ob-clojure-literate-get-session-list)) 1)
(member ob-clojure-literate-default-session (ob-clojure-literate-get-session-list)))
(setq-local ob-clojure-literate-session ob-clojure-literate-default-session)
;; if have any connections, choose one from them.
(if (ob-clojure-literate-any-connection-p)
(setq-local ob-clojure-literate-session
(completing-read "Choose ob-clojure-literate :session : "
(ob-clojure-literate-get-session-list)))
;; if none, set to default session name to fix `ob-clojure-literate-mode'
;; is enabled before `cider-jack-in' generated connections.
(setq-local ob-clojure-literate-session
ob-clojure-literate-default-session))))
;;;###autoload
(defun ob-clojure-literate-specify-session ()
"Specify ob-clojure header argument :session with value selected from a list of available sessions."
(interactive)
(let ((lang (nth 0 (org-babel-get-src-block-info))))
(if (and (string= lang "clojure") ; only in clojure src block.
(car (seq-filter ; only when :session is not specified yet.
(lambda (header-argument)
(if (eq (car header-argument) :session)
(not (null (cdr header-argument)))))
(nth 2 (org-babel-get-src-block-info)))))
(org-babel-insert-header-arg
"session"
(format "\"%s\""
(completing-read
"Choose :session for ob-clojure-literate: "
(ob-clojure-literate-get-session-list))))
(message "This function only used in `clojure' src block.")))
)
;;; Auto start CIDER REPL session in a complete Leiningen project environment for Org-mode Babel to jack-in.
;;;###autoload
(defun ob-clojure-literate-auto-jackin ()
"Auto setup ob-clojure-literate scaffold and jack-in Clojure project."
(interactive)
(cond
;; jack-in outside of Clojure project.
((null ob-clojure-literate-project-location)
(if (member (get-buffer "*cider-repl localhost*") cider-connections)
(message "CIDER default session already launched.")
(cider-jack-in nil)))
((not (null ob-clojure-literate-project-location))
(unless (file-directory-p (expand-file-name ob-clojure-literate-project-location))
(make-directory ob-clojure-literate-project-location t)
(let ((default-directory ob-clojure-literate-project-location))
(shell-command "lein new ob-clojure")))
(unless (or
(and (cider-connected-p)
(if (not (null ob-clojure-literate-session))
(seq-contains cider-connections (get-buffer ob-clojure-literate-session))))
cider-connections
(ob-clojure-literate-any-connection-p))
;; return back to original file.
(if (not (and (= (length (ob-clojure-literate-get-session-list)) 1)
(member ob-clojure-literate-default-session (ob-clojure-literate-get-session-list))))
(save-window-excursion
(find-file (expand-file-name (concat ob-clojure-literate-project-location "ob-clojure/src/ob_clojure/core.clj")))
(with-current-buffer "core.clj"
(cider-jack-in))))))))
(defun ob-clojure-literate-set-local-cider-connections (toggle?)
"Set buffer local `cider-connections' for `ob-clojure-literate-mode' `TOGGLE?'."
(if toggle?
(progn
(setq ob-clojure-literate-cider-connections cider-connections)
(unless (local-variable-if-set-p 'cider-connections)
(make-local-variable 'cider-connections))
(setq-local cider-connections ob-clojure-literate-cider-connections))
;; store/restore emptied CIDER connections by `ob-clojure-literate-enable'.
(kill-local-variable 'cider-connections) ; kill local variable so that I can get the original global variable value.
;; Empty all CIDER connections to avoid `cider-current-connection' return any connection.
;; FIXME: when try to enable, `cider-connections' is local and nil.
;; (if (and (= (length (ob-clojure-literate-get-session-list)) 1)
;; (member ob-clojure-literate-default-session (ob-clojure-literate-get-session-list))))
;; (unless (local-variable-if-set-p 'cider-connections)
;; (make-local-variable 'cider-connections))
;; (setq-local cider-connections '())
))
(defun ob-clojure-literate-set-ns (body params)
"Fix the issue that `cider-current-ns' try to invoke `clojure-find-ns' to extract ns from buffer."
;; TODO: Is it possible to find ns in `body'?
(when (ob-clojure-literate-any-connection-p)
(setq ob-clojure-literate-original-ns (cider-current-ns))
(with-current-buffer ob-clojure-literate-session
(setq ob-clojure-literate-session-ns cider-buffer-ns))
(setq-local cider-buffer-ns (or (cdr (assq :ns params))
ob-clojure-literate-session-ns)))
(message (format "ob-clojure-literate: current CIDER ns is [%s]." cider-buffer-ns)))
(defun ob-clojure-literate-set-local-session (toggle?)
"Set buffer local `org-babel-default-header-args:clojure' for `ob-clojure-literate-mode' `TOGGLE?'."
(if toggle?
(progn
;; set local default session for ob-clojure.
(setq ob-clojure-literate-session (ob-clojure-literate-set-session))
(unless (local-variable-if-set-p 'org-babel-default-header-args:clojure)
(make-local-variable 'org-babel-default-header-args:clojure))
(add-to-list 'org-babel-default-header-args:clojure
`(:session . ,ob-clojure-literate-session))
)
;; remove :session from buffer local default header arguments list.
(unless (local-variable-if-set-p 'org-babel-default-header-args:clojure)
(make-local-variable 'org-babel-default-header-args:clojure))
(setq org-babel-default-header-args:clojure
(delq t
(mapcar
(lambda (cons) (if (eq (car cons) :session) t cons))
org-babel-default-header-args:clojure)))))
;;; Support header arguments :results graphics :file "image.png" by inject Clojure code.
(defun ob-clojure-literate-inject-code (args)
"Inject Clojure code into `BODY' in `ARGS'.
It is used to change Clojure currently working directory in a FAKE way.
And generate inline graphics image file link result.
Use header argument like this:
:results graphics :file \"incanter-plot.png\"
Then you need to assign image variable to this :file value like:
(def incanter-plot (histogram (sample-normal 1000)))
*NOTE*: Currently only support Incanter's `save' function.
"
(let* ((body (nth 0 args))
(params (nth 1 args))
(dir (cdr (assq :dir params)))
(default-directory (and (buffer-file-name) (file-name-directory (buffer-file-name))))
(directory (and dir (file-name-as-directory (expand-file-name dir))))
(result-type (cdr (assq :results params)))
(file (cdr (assq :file params)))
(file-name (and file (file-name-base file)))
;; TODO: future support `:graphics-file' to avoid collision.
(graphics-result (member "graphics" (cdr (assq :result-params params))))
;; (graphics-file (cdr (assq :graphics-file params)))
;; (graphics-name (file-name-base graphics-file))
(prepend-to-body (lambda (code)
(setq body (concat code "\n" body))))
(append-to-body (lambda (code)
(setq body (concat body "\n" code "\n"))))
)
(when directory
(unless (file-directory-p (expand-file-name directory))
(warn (format "Target directory %s does not exist, please create it." dir))))
(when file
(funcall append-to-body
(format "(save %s \"%s\")" file-name (concat directory file)))
)
(list body params) ; return modified argument list
))
;;; support :results graphics :dir "data/image" :file "incanter-plot.png"
(defun ob-clojure-literate-support-graphics-result (result)
"Support :results graphics :dir \"data/images\" :file \"incanter-plot.png\"
reset `RESULT' to `nil'."
(let* ((params (nth 2 info))
(graphics-result (member "graphics" (cdr (assq :result-params params)))))
(if graphics-result
(setq result nil))
result))
(defvar ob-clojure-literate-mode-map
(let ((map (make-sparse-keymap)))
map)
"Keymap for `ob-clojure-literate-mode'.")
(define-key org-babel-map (kbd "M-s") 'ob-clojure-literate-specify-session)
(define-key org-babel-map (kbd "M-j") 'ob-clojure-literate-auto-jackin)
;; (define-key org-babel-map (kbd "M-e") 'cider-eval-last-sexp)
;; (define-key org-babel-map (kbd "M-d") 'cider-doc)
;;;###autoload
(defun ob-clojure-literate-enable ()
"Enable Org-mode buffer locally for `ob-clojure-literate'."
(when (and (not (null cider-connections)) ; only enable `ob-clojure-literate-mode' when has CIDER connections.
(equal major-mode 'org-mode)) ; `ob-clojure-literate-mode' only works in `org-mode'.
(ob-clojure-literate-set-local-cider-connections ob-clojure-literate-mode)
(ob-clojure-literate-set-local-session ob-clojure-literate-mode)
(advice-add 'org-babel-execute:clojure :before #'ob-clojure-literate-set-ns)
(advice-add 'org-babel-expand-body:clojure :filter-args #'ob-clojure-literate-inject-code)
(advice-add 'org-babel-execute:clojure :filter-return #'ob-clojure-literate-support-graphics-result)
(message "ob-clojure-literate minor mode enabled.")))
;;;###autoload
(defun ob-clojure-literate-disable ()
"Disable Org-mode buffer locally for `ob-clojure-literate'."
(advice-remove 'org-babel-execute:clojure #'ob-clojure-literate-set-ns)
(advice-remove 'org-babel-expand-body:clojure #'ob-clojure-literate-inject-code)
(advice-remove 'org-babel-execute:clojure #'ob-clojure-literate-support-graphics-result)
(setq-local cider-buffer-ns ob-clojure-literate-original-ns)
(ob-clojure-literate-set-local-cider-connections ob-clojure-literate-mode)
(ob-clojure-literate-set-local-session ob-clojure-literate-mode)
(message "ob-clojure-literate minor mode disabled."))
;;;###autoload
(if ob-clojure-literate-auto-jackin-p (ob-clojure-literate-auto-jackin))
;;;###autoload
(define-minor-mode ob-clojure-literate-mode
"A minor mode to toggle `ob-clojure-literate'."
:require 'ob-clojure-literate
:init-value nil
:lighter " clj-lp"
:group 'ob-clojure-literate
:keymap ob-clojure-literate-mode-map
:global nil
(if ob-clojure-literate-mode
(ob-clojure-literate-enable)
(ob-clojure-literate-disable))
)
(provide 'ob-clojure-literate)
;;; ob-clojure-literate.el ends here

View File

@@ -5,7 +5,7 @@
;; Author: Eric Schulte
;; Maintainer: Luc Pellissier <luc.pellissier@crans.org>
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: thomas "at" friendlyvillagers.com based on ob-java.el by Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Michael Gauland
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Luis Anaya
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Torsten Anders
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Simon Michael
;; Keywords: literate programming, reproducible research, plain text accounting
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Andrzej Lichnerowicz
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -5,7 +5,7 @@
;; Author: Eric S Fraga
;; Maintainer: Eric S Fraga
;; Keywords: literate programming, reproducible research, accounting
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,95 +0,0 @@
;;; ob-mathematica.el --- org-babel functions for Mathematica evaluation
;; Copyright (C) 2014, 2021 Yi Wang
;; Authors: Yi Wang
;; Keywords: literate programming, reproducible research
;; Homepage: https://github.com/tririver/ob-mathematica/
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;; Org-Babel support for evaluating Mathematica source code.
;;; Code:
(require 'ob)
(require 'ob-ref)
(require 'ob-comint)
(require 'ob-eval)
(declare-function org-trim "org" (s &optional keep-lead))
;; Optionally require mma.el for font lock, etc
(require 'mma nil 'noerror)
(add-to-list 'org-src-lang-modes '("mathematica" . "mma"))
(defvar org-babel-tangle-lang-exts)
(add-to-list 'org-babel-tangle-lang-exts '("mathematica" . "m"))
(defvar org-babel-default-header-args:mathematica '())
(defvar org-babel-mathematica-command "MathematicaScript -script"
"Name of the command for executing Mathematica code.")
(defvar org-babel-mathematica-command-alt "math -noprompt"
"Name of the command for executing Mathematica code.")
(defun org-babel-expand-body:mathematica (body params)
"Expand BODY according to PARAMS, return the expanded body."
(let ((vars (org-babel--get-vars params)))
(concat
(mapconcat ;; define any variables
(lambda (pair)
(format "%s=%s;"
(car pair)
(org-babel-mathematica-var-to-mathematica (cdr pair))))
vars "\n") "\nPrint[\n" body "\n]\n")))
(defun org-babel-execute:mathematica (body params)
"Execute a block of Mathematica code with org-babel. This function is
called by `org-babel-execute-src-block'"
(let* ((result-params (cdr (assq :result-params params)))
(full-body (org-babel-expand-body:mathematica body params))
(tmp-script-file (org-babel-temp-file "mathematica-"))
(cmd org-babel-mathematica-command))
;; actually execute the source-code block
(with-temp-file tmp-script-file (insert full-body))
;; (with-temp-file "/tmp/dbg" (insert full-body))
((lambda (raw)
(if (or (member "code" result-params)
(member "pp" result-params)
(and (member "output" result-params)
(not (member "table" result-params))))
raw
(org-babel-script-escape (org-trim raw))))
(org-babel-eval (concat cmd " " tmp-script-file) ""))))
(defun org-babel-prep-session:mathematica (session params)
"This function does nothing so far"
(error "Currently no support for sessions"))
(defun org-babel-prep-session:mathematica (session body params)
"This function does nothing so far"
(error "Currently no support for sessions"))
(defun org-babel-mathematica-var-to-mathematica (var)
"Convert an elisp value to a Mathematica variable.
Convert an elisp value, VAR, into a string of Mathematica source code
specifying a variable of the same value."
(if (listp var)
(concat "{" (mapconcat #'org-babel-mathematica-var-to-mathematica var ", ") "}")
(format "%S" var)))
(provide 'ob-mathematica)

View File

@@ -7,7 +7,7 @@
;; Luis Anaya (Mathomatic)
;; Keywords: literate programming, reproducible research, mathomatic
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -5,7 +5,7 @@
;; Author: Juan Pechiar
;; Maintainer: Justin Abrahms
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Torsten Anders and Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.02
;; This file is not part of GNU Emacs.

View File

@@ -1,73 +0,0 @@
;;; ob-php.el --- Execute PHP within org-mode blocks
;; Copyright 2016, 2021 stardiviner
;; Author: stardiviner <numbchild@gmail.com>
;; Maintainer: stardiviner <numbchild@gmail.com>
;; Homepage: https://github.com/stardiviner/ob-php
;; Keywords: org babel php
;; Homepage: https://github.com/stardiviner/ob-php
;; Created: 04th May 2016
;; Version: 0.0.1
;; Package-Requires: ((org "8"))
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Execute PHP within org-mode blocks.
;;; Code:
(require 'org)
(require 'ob)
(defgroup ob-php nil
"org-mode blocks for PHP."
:group 'org)
(defcustom org-babel-php-command "php"
"The command to execute babel body code."
:group 'ob-php
:type 'string)
(defcustom org-babel-php-command-options nil
"The php command options to use when execute code."
:group 'ob-php
:type 'string)
(defcustom ob-php:inf-php-buffer "*php*"
"Default PHP inferior buffer."
:group 'ob-php
:type 'string)
;;;###autoload
(defun org-babel-execute:php (body params)
"Orgmode Babel PHP evaluate function for `BODY' with `PARAMS'."
(let* ((cmd (concat org-babel-php-command " " org-babel-php-command-options))
(body (concat "<?php\n" body "\n?>")))
(org-babel-eval cmd body)))
;;;###autoload
(eval-after-load 'org
'(add-to-list 'org-src-lang-modes '("php" . php)))
(defvar org-babel-default-header-args:php '())
(add-to-list 'org-babel-default-header-args:php
'(:results . "output"))
(provide 'ob-php)
;;; ob-php.el ends here

View File

@@ -5,7 +5,7 @@
;; Authors: Thorsten Jolitz
;; Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,59 +0,0 @@
;;; ob-redis.el --- Execute Redis queries within org-mode blocks
;; Copyright 2016-2021 stardiviner
;; Author: stardiviner <numbchild@gmail.com>
;; Maintainer: stardiviner <numbchild@gmail.com>
;; Keywords: org babel redis
;; Homepage: https://github.com/stardiviner/ob-redis
;; Created: 28th Feb 2016
;; Version: 0.0.1
;; Package-Requires: ((org "8"))
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Execute Redis queries within org-mode blocks.
;;; Code:
(require 'org)
(require 'ob)
(defgroup ob-redis nil
"org-mode blocks for Redis."
:group 'org)
(defcustom ob-redis:default-db "127.0.0.1:6379"
"Default Redis database."
:group 'ob-redis
:type 'string)
;;;###autoload
(defun org-babel-execute:redis (body params)
"org-babel redis hook."
(let* ((db (or (cdr (assoc :db params))
ob-redis:default-db))
(cmd (mapconcat 'identity (list "redis-cli") " ")))
(org-babel-eval cmd body)
))
;;;###autoload
(eval-after-load 'org
'(add-to-list 'org-src-lang-modes '("redis" . redis)))
(provide 'ob-redis)
;;; ob-redis.el ends here

View File

@@ -1,93 +0,0 @@
;;; ob-sclang.el --- SCLang support for Org-mode Babel
;;; -*- coding: utf-8 -*-
;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
;; Authors: stardiviner <numbchild@gmail.com>
;; Homepage: https://github.com/stardiviner/ob-sclang
;; Package-Version: 0.1
;; Keywords: babel sclang
;; This file is not part of GNU Emacs.
;; GNU Emacs 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.
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; `ob-sclang' requires `sclang' from SuperCollider.
;; Usually SuperCollider dependencies for Emacs are at /usr/share/emacs/site-lisp/SuperCollider/
;; You can install SuperCollider following this article:
;; https://github.com/supercollider/supercollider#building-the-source-code
;; Usage:
;; Support to evaluate sclang Org-mode src block with function `sclang-eval-string'.
;; For example:
;; #+BEGIN_SRC sclang :results none
;; "Hello World".postln;
;; #+END_SRC
;;
;; *NOTE* Temporary output to org-babel result output is not supported.
;; Because `sclang-eval-string' will send output to Sclang Post Buffer.
;; And command line `sclang' execute will not automatically stop after finished execution.
;;
;; #+BEGIN_SRC sclang :results none
;; // modulate a sine frequency and a noise amplitude with another sine
;; // whose frequency depends on the horizontal mouse pointer position
;; {
;; var x = SinOsc.ar(MouseX.kr(1, 100));
;; SinOsc.ar(300 * x + 800, 0, 0.1)
;; +
;; PinkNoise.ar(0.1 * x + 0.1)
;; }.play;
;; #+END_SRC
;;; Code:
;;; ----------------------------------------------------------------------------
(require 'org)
(require 'ob)
(require 'sclang nil t)
(defgroup ob-sclang nil
"org-mode blocks for SuperCollider SCLang."
:group 'org)
;;;###autoload
(defun org-babel-execute:sclang (body params)
"Org-mode Babel sclang hook for evaluate `BODY' with `PARAMS'."
(unless (or (equal (buffer-name) sclang-post-buffer)
(sclang-get-process))
(sclang-start))
(sclang-eval-string body t))
(defvar org-babel-default-header-args:sclang nil)
(setq org-babel-default-header-args:sclang
'((:session . "*SCLang:Workspace*")
;; TODO: temporary can't find way to let sclang output to stdout for org-babel.
(:output . "none")))
(eval-after-load 'org
'(progn
(add-to-list 'org-src-lang-modes '("sclang" . sclang))))
;;; ----------------------------------------------------------------------------
(provide 'ob-sclang)
;;; ob-sclang.el ends here

View File

@@ -4,7 +4,7 @@
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research, shen
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,71 +0,0 @@
;;; ob-smiles.el --- Org-mode Babel support for SMILES
;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
;; Maintainer: stardiviner <numbchild@gmail.com>
;; Homepage: https://github.com/stardiviner/ob-smiles
;; Keywords: org babel SMILES
;; Version: 0.0.1
;; Package-Requires: ((smiles-mode "0.0.1") (org "8"))
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs 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.
;;
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; I copy code from:
;;; https://kitchingroup.cheme.cmu.edu/blog/2016/03/26/A-molecule-link-for-org-mode
;;; Code:
(require 'ob)
(require 'org-element)
;; Org-mode Babel
(defun org-babel-execute:smiles (body params)
"Execute SMILES babel `BODY' with `PARAMS'."
(shell-command-to-string
(format "obabel -:\"%s\" -osvg 2> /dev/null" body)))
;; Org-mode link
(defun molecule-jump (name)
"Jump to molecule `NAME' definition."
(org-mark-ring-push)
(org-link-open-from-string (format "[[%s]]" name)))
(defun molecule-export (path desc backend)
"Export molecule to HTML format on `PATH' with `DESC' and `BACKEND'."
(let ((name (save-window-excursion
(molecule-jump path)
(org-element-property :name (org-element-context)))))
(cond
((eq 'html backend)
(format "<a href=\"#%s\">%s</a>" name name)))))
(org-link-set-parameters
"molecule"
:follow 'molecule-jump
:export 'molecule-export)
;; org-mode element
(org-element-map (org-element-parse-buffer)
'src-block
(lambda (src)
(when (string= "smiles" (org-element-property :language src))
(org-element-property :name src))))
(provide 'ob-smiles)
;;; ob-smiles.el ends here

View File

@@ -3,7 +3,7 @@
;; Author: Tiago Oliveira Weber
;; Maintainer: stardiviner <numbchild@gmail.com>
;; Homepage: https://github.com/stardiviner/ob-spice
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.4
;; Package-Requires: ((spice-mode "0.0.1") (org "8"))

View File

@@ -1,86 +0,0 @@
;;; ob-stan.el --- Babel Functions for Stan -*- lexical-binding: t; -*-
;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
;; Author: Kyle Meyer
;; Keywords: literate programming, reproducible research
;; Homepage: https://git.kyleam.com/ob-stan
;; This file is not part of GNU Emacs.
;; GNU Emacs 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.
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Org-Babel support for evaluating Stan [1] source code.
;;
;; Evaluating a Stan block can produce two different results.
;;
;; 1) Dump the source code contents to a file.
;;
;; This file can then be used as a variable in other blocks, which
;; allows interfaces like RStan to use the model.
;;
;; 2) Compile the contents to a model file.
;;
;; This provides access to the CmdStan interface. To use this, set
;; `org-babel-stan-cmdstan-directory' and provide a :file argument
;; that does not end in ".stan".
;;
;; For more information and usage examples, visit
;; https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
;;
;; [1] https://mc-stan.org/
;;; Code:
(require 'ob)
(require 'org-compat)
(defcustom org-babel-stan-cmdstan-directory nil
"CmdStan source directory.
Call \"make\" from this directory to compile the Stan block.
When nil, executing Stan blocks dumps the content to a file."
:group 'org-babel
:type '(choice
(directory :tag "Compilation directory")
(const :tag "Dump to a file" nil)))
(defvar org-babel-default-header-args:stan
'((:results . "file")))
(defun org-babel-execute:stan (body params)
"Generate Stan file from BODY according to PARAMS.
A :file header argument must be given. If
`org-babel-stan-cmdstan-directory' is non-nil and the file name
does not have a \".stan\" extension, save an intermediate
\".stan\" file and compile the block to the named file.
Otherwise, write the Stan code directly to the named file."
(let ((file (expand-file-name
(or (cdr (assq :file params))
(user-error "Set :file argument to execute Stan blocks")))))
(if (or (not org-babel-stan-cmdstan-directory)
(string-match-p "\\.stan\\'" file))
(with-temp-file file (insert body))
(with-temp-file (concat file ".stan") (insert body))
(let ((default-directory org-babel-stan-cmdstan-directory))
(call-process-shell-command (concat "make " file))))
nil)) ; Signal that output has been written to file.
(defun org-babel-prep-session:stan (_session _params)
"Return an error because Stan does not support sessions."
(user-error "Stan does not support sessions"))
(provide 'ob-stan)
;;; ob-stan.el ends here

View File

@@ -7,7 +7,7 @@
;; Luis Anaya (tcl)
;;
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Christian Garbs <mitch@cgarbs.de>
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: thomas "at" friendlyvillagers.com based on ob-java.el by Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; This file is not part of GNU Emacs.

View File

@@ -1,155 +0,0 @@
;;; ol-notmuch.el --- Links to notmuch messages
;; Copyright (C) 2010-2014, 2021 Matthieu Lemerre
;; Author: Matthieu Lemerre <racin@free.fr>
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://git.sr.ht/~tarsius/ol-notmuch
;; This file is not part of GNU Emacs.
;; This file 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 file 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file implements links to notmuch messages and "searches". A
;; search is a query to be performed by notmuch; it is the equivalent
;; to folders in other mail clients. Similarly, mails are referred to
;; by a query, so both a link can refer to several mails.
;; Links have one the following form
;; notmuch:<search terms>
;; notmuch-search:<search terms>.
;; The first form open the queries in notmuch-show mode, whereas the
;; second link open it in notmuch-search mode. Note that queries are
;; performed at the time the link is opened, and the result may be
;; different from when the link was stored.
;;; Code:
(require 'ol)
;; customisable notmuch open functions
(defcustom org-notmuch-open-function
'org-notmuch-follow-link
"Function used to follow notmuch links.
Should accept a notmuch search string as the sole argument."
:group 'org-notmuch
:version "24.4"
:package-version '(Org . "8.0")
:type 'function)
(defcustom org-notmuch-search-open-function
'org-notmuch-search-follow-link
"Function used to follow notmuch-search links.
Should accept a notmuch search string as the sole argument."
:group 'org-notmuch
:version "24.4"
:package-version '(Org . "8.0")
:type 'function)
(make-obsolete-variable 'org-notmuch-search-open-function nil "9.3")
;; Install the link type
(org-link-set-parameters "notmuch"
:follow #'org-notmuch-open
:store #'org-notmuch-store-link)
(defun org-notmuch-store-link ()
"Store a link to a notmuch search or message."
(when (memq major-mode '(notmuch-show-mode notmuch-tree-mode))
(let* ((message-id (notmuch-show-get-message-id t))
(subject (notmuch-show-get-subject))
(to (notmuch-show-get-to))
(from (notmuch-show-get-from))
(date (org-trim (notmuch-show-get-date)))
desc link)
(org-link-store-props :type "notmuch" :from from :to to :date date
:subject subject :message-id message-id)
(setq desc (org-link-email-description))
(setq link (concat "notmuch:id:" message-id))
(org-link-add-props :link link :description desc)
link)))
(defun org-notmuch-open (path _)
"Follow a notmuch message link specified by PATH."
(funcall org-notmuch-open-function path))
(defun org-notmuch-follow-link (search)
"Follow a notmuch link to SEARCH.
Can link to more than one message, if so all matching messages are shown."
(require 'notmuch)
(notmuch-show search))
(org-link-set-parameters "notmuch-search"
:follow #'org-notmuch-search-open
:store #'org-notmuch-search-store-link)
(defun org-notmuch-search-store-link ()
"Store a link to a notmuch search or message."
(when (eq major-mode 'notmuch-search-mode)
(let ((link (concat "notmuch-search:" notmuch-search-query-string))
(desc (concat "Notmuch search: " notmuch-search-query-string)))
(org-link-store-props :type "notmuch-search"
:link link
:description desc)
link)))
(defun org-notmuch-search-open (path _)
"Follow a notmuch message link specified by PATH."
(message "%s" path)
(org-notmuch-search-follow-link path))
(defun org-notmuch-search-follow-link (search)
"Follow a notmuch link by displaying SEARCH in notmuch-search mode."
(require 'notmuch)
(notmuch-search search))
(org-link-set-parameters "notmuch-tree"
:follow #'org-notmuch-tree-open
:store #'org-notmuch-tree-store-link)
(defun org-notmuch-tree-store-link ()
"Store a link to a notmuch search or message."
(when (eq major-mode 'notmuch-tree-mode)
(let ((link (concat "notmuch-tree:" (notmuch-tree-get-query)))
(desc (concat "Notmuch tree: " (notmuch-tree-get-query))))
(org-link-store-props :type "notmuch-tree"
:link link
:description desc)
link)))
(defun org-notmuch-tree-open (path _)
"Follow a notmuch message link specified by PATH."
(message "%s" path)
(org-notmuch-tree-follow-link path))
(defun org-notmuch-tree-follow-link (search)
"Follow a notmuch link by displaying SEARCH in notmuch-tree mode."
(require 'notmuch)
(notmuch-tree search))
(provide 'ol-notmuch)
;;; ol-notmuch.el ends here

View File

@@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;;
;; Support for IMAP folders added
;; by Konrad Hinsen <konrad dot hinsen at fastmail dot net>

View File

@@ -5,7 +5,7 @@
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
;; David Maus <dmaus at ictsoc dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;;
;; This file is not part of GNU Emacs.
;;

View File

@@ -1,132 +0,0 @@
;;; org-attach-embedded-images.el --- Transmute images to attachments
;;
;; Copyright 2018-2021 Free Software Foundation, Inc.
;;
;; Author: Marco Wahl
;; Homepage: https://gitlab.com/marcowahl/org-attach-embedded-imagse
;; Version: 0.1
;; Keywords: org, media
;;
;; 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; There are occasions when images are displayed in a subtree which
;; are not org attachments. For example if you copy and paste a part
;; of a web page (containing images) from eww to an org subtree.
;; This module provides command `org-attach-embedded-images-in-subtree'
;; to save such images as attachments and insert org links to them.
;; Install:
;; To use this module insert it to `org-modules'. The insert can be
;; performed via {M-x customize-variable RET org-modules RET} followed
;; by insertion of `org-attach-embedded-images' to the external
;; modules section.
;; Alternatively you can add the line
;; (require 'org-attach-embedded-images)
;; to your emacs configuration.
;; Use
;; M-x org-attach-embedded-images-in-subtree
;; in a subtree with embedded images. The images get attached and can
;; later be reviewed.
;; Note: Possibly
;; M-x org-toggle-inline-images
;; is needed to see the images in the Org mode window.
;; Code:
(require 'org)
(require 'org-attach)
;; Auxiliary functions
(defun org-attach-embedded-images--next-property-display-data (position limit)
"Return position of the next property-display location with image data.
Return nil if there is no next display property.
POSITION and LIMIT as in `next-single-property-change'."
(let ((pos (next-single-property-change position 'display nil limit)))
(while (and (< pos limit)
(let ((display-prop
(plist-get (text-properties-at pos) 'display)))
(or (not display-prop)
(not (plist-get (cdr display-prop) :data)))))
(setq pos (next-single-property-change pos 'display nil limit)))
pos))
(defun org-attach-embedded-images--attach-with-sha1-name (data)
"Save the image given as DATA as org attachment with its sha1 as name.
Return the filename."
(let* ((extension (symbol-name (image-type-from-data data)))
(basename (concat (sha1 data) "." extension))
(dir (org-attach-dir t))
(filename (concat dir "/" basename)))
(unless (file-exists-p filename)
(with-temp-file filename
(setq buffer-file-coding-system 'binary)
(set-buffer-multibyte nil)
(insert data)))
(org-attach-sync)
basename))
;; Command
;;;###autoload
(defun org-attach-embedded-images-in-subtree ()
"Save the displayed images as attachments and insert links to them."
(interactive)
(when (org-before-first-heading-p)
(user-error "Before first heading. Nothing has been attached."))
(save-excursion
(org-attach-dir t)
(let ((beg (progn (org-back-to-heading) (point)))
(end (progn (org-end-of-subtree) (point)))
names)
;; pass 1
(goto-char beg)
(while (< (goto-char (org-attach-embedded-images--next-property-display-data (point) end)) end)
(let ((data (plist-get (cdr (plist-get (text-properties-at (point)) 'display)) :data)))
(assert data)
(push (org-attach-embedded-images--attach-with-sha1-name data)
names)))
;; pass 2
(setq names (nreverse names))
(goto-char beg)
(while names
(goto-char (org-attach-embedded-images--next-property-display-data (point) end))
(while (get-text-property (point) 'display)
(goto-char (next-property-change (point) nil end)))
(skip-chars-forward "]")
(insert (concat "\n[[attachment:" (pop names) "]]"))))))
(provide 'org-attach-embedded-images)
;;; org-attach-embedded-images.el ends here

View File

@@ -4,7 +4,7 @@
;; Author: Eric Schulte <eric dot schulte at gmx dot com>
;; Keywords: outlines, hypermedia, bibtex, d3
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.01
;; This file is not part of GNU Emacs.
@@ -103,12 +103,12 @@ For example, to point to your `obe-bibtex-file' use the following.
(col (k) (mapcar (lambda (r) (cdr (assoc k r))) meta))
(add (lst)
(dolist (el lst) (push (cons el counter) nodes))
(incf counter)))
(cl-incf counter)))
;; build the nodes of the graph
(add (col :title))
(add (remove-if (lambda (author) (string-match "others" author))
(remove-duplicates (apply #'append (col :authors))
:test #'string=)))
(add (cl-remove-if (lambda (author) (string-match "others" author))
(remove-duplicates (apply #'append (col :authors))
:test #'string=)))
(dolist (field fields)
(add (remove-duplicates (col field) :test #'string=)))
;; build the links in the graph

View File

@@ -93,10 +93,10 @@ of checkbox items"
"-" (format-time-string
org-checklist-export-time-format)
".org"))
(print (case (org-entry-get (point) "PRINT_EXPORT" nil)
(print (cl-case (org-entry-get (point) "PRINT_EXPORT" nil)
(("" "nil" nil) nil)
(t t)
(nil (y-or-n-p "Print list? "))))
(nil (y-or-n-p "Print list? "))
(t t)))
exported-lines
(title "Checklist export"))
(save-restriction

View File

@@ -201,7 +201,7 @@ interpretation."
(setq top-upper-range index))
((eq type 'default-mark)
(setq static-default index)))
(incf index)
(cl-incf index)
(push vanilla-text all-mark-texts)
(push vanilla-mark vanilla-list)))

View File

@@ -5,7 +5,7 @@
;; Author: Eric Schulte <schulte dot eric at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp, experimentation,
;; organization, properties
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.01
;; This file is not part of GNU Emacs.

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,2 @@
;; Generated package description from org-contrib.el -*- no-byte-compile: t -*-
(define-package "org-contrib" "0.3" "Unmaintained add-ons for Org-mode" '((emacs "25.1") (org "9.4.6")) :authors '(("Bastien Guerry" . "bzg@gnu.org")) :maintainer '("Bastien Guerry" . "bzg@gnu.org") :keywords '("org") :url "https://git.sr.ht/~bzg/org-contrib")
(define-package "org-contrib" "0.4.1" "Unmaintained add-ons for Org-mode" '((emacs "25.1") (org "9.4.6")) :commit "d0cebebb301b5de93e9c5228a91e3e4f5d41902b" :authors '(("Bastien Guerry" . "bzg@gnu.org")) :maintainer '("Bastien Guerry" . "bzg@gnu.org") :keywords '("org") :url "https://git.sr.ht/~bzg/org-contrib")

View File

@@ -5,7 +5,7 @@
;; Author: Bastien Guerry <bzg@gnu.org>
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Package-Requires: ((emacs "25.1") (org "9.4.6"))
;; Version: 0.3
;; Version: 0.4.1
;; Keywords: org
;; SPDX-License-Identifier: GPL-3.0-or-later

View File

@@ -3,7 +3,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.01
;;
;; This file is not part of GNU Emacs.

View File

@@ -3,7 +3,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.08
;;
;; This file is not part of GNU Emacs.
@@ -281,13 +281,13 @@ This does two different kinds of triggers:
(from-bottom items)
((or from-current no-wrap)
(let* ((items (nreverse items))
(pos (position this-item items :key #'first))
(items-before (subseq items 0 pos))
(items-after (subseq items pos)))
(pos (cl-position this-item items :key #'cl-first))
(items-before (cl-subseq items 0 pos))
(items-after (cl-subseq items pos)))
(if no-wrap items-after
(append items-after items-before))))
(t (nreverse items))))
(setq items (remove-if
(setq items (cl-remove-if
(lambda (item)
(or (equal (first item) this-item)
(and (not todo-and-done-only)

View File

@@ -4,7 +4,7 @@
;; Author: David Arroyo Menéndez <davidam@es.gnu.org>
;; Keywords: effectiveness, plot
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;;
;; This file is not part of GNU Emacs.
;;

View File

@@ -6,7 +6,7 @@
;; Maintainer: Łukasz Gruner <lukasz@gruner.lu>
;; Version: 6
;; Package-Requires: ((org "8"))
;; Homepage: https://bitbucket.org/ukaszg/org-eldoc
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Created: 25/05/2014
;; Keywords: eldoc, outline, breadcrumb, org, babel, minibuffer
@@ -81,11 +81,13 @@
": "
(mapconcat
(lambda (elem)
(when (and (cdr elem) (not (string= "" (cdr elem))))
(when-let* ((val (and (cdr elem)
(format "%s" (cdr elem))))
(_ (not (string-empty-p val))))
(concat
(propertize (symbol-name (car elem)) 'face 'org-list-dt)
" "
(propertize (cdr elem) 'face 'org-verbatim)
(propertize val 'face 'org-verbatim)
" ")))
hdr-args " ")))))))
@@ -141,40 +143,46 @@
(org-eldoc-get-breadcrumb)
(org-eldoc-get-src-header)
(let ((lang (org-eldoc-get-src-lang)))
(cond ((or
(string= lang "emacs-lisp")
(string= lang "elisp"))
(cond ((and (boundp 'eldoc-documentation-functions) ; Emacs>=28
(fboundp 'elisp-eldoc-var-docstring)
(fboundp 'elisp-eldoc-funcall))
(let ((eldoc-documentation-functions
'(elisp-eldoc-var-docstring elisp-eldoc-funcall)))
(eldoc-print-current-symbol-info)))
((fboundp 'elisp-eldoc-documentation-function)
(elisp-eldoc-documentation-function))
(t ; Emacs<25
(let (eldoc-documentation-function)
(eldoc-print-current-symbol-info)))))
((or
(string= lang "c") ;; https://github.com/nflath/c-eldoc
(string= lang "C")) (when (require 'c-eldoc nil t)
(c-eldoc-print-current-symbol-info)))
;; https://github.com/zenozeng/css-eldoc
((string= lang "css") (when (require 'css-eldoc nil t)
(css-eldoc-function)))
;; https://github.com/zenozeng/php-eldoc
((string= lang "php") (when (require 'php-eldoc nil t)
(php-eldoc-function)))
((or
(string= lang "go")
(string= lang "golang")) (when (require 'go-eldoc nil t)
(go-eldoc--documentation-function)))
(t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
(callback (car args)))
(when (functionp doc-fun)
(if (functionp callback)
(funcall doc-fun callback)
(funcall doc-fun)))))))))
(cond
((string= lang "org") ;Prevent inf-loop for Org src blocks
nil)
((or
(string= lang "emacs-lisp")
(string= lang "elisp"))
(cond ((and (boundp 'eldoc-documentation-functions) ; Emacs>=28
(fboundp 'elisp-eldoc-var-docstring)
(fboundp 'elisp-eldoc-funcall))
(let ((eldoc-documentation-functions
'(elisp-eldoc-var-docstring elisp-eldoc-funcall)))
(eldoc-print-current-symbol-info)))
((fboundp 'elisp-eldoc-documentation-function)
(elisp-eldoc-documentation-function))
(t ; Emacs<25
(let (eldoc-documentation-function)
(eldoc-print-current-symbol-info)))))
((or
(string= lang "c") ;; https://github.com/nflath/c-eldoc
(string= lang "C"))
(when (require 'c-eldoc nil t)
(c-eldoc-print-current-symbol-info)))
;; https://github.com/zenozeng/css-eldoc
((string= lang "css") (when (require 'css-eldoc nil t)
(css-eldoc-function)))
;; https://github.com/zenozeng/php-eldoc
((string= lang "php") (when (require 'php-eldoc nil t)
(php-eldoc-function)))
((or
(string= lang "go")
(string= lang "golang"))
(when (require 'go-eldoc nil t)
(go-eldoc--documentation-function)))
(t
(let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
(callback (car args)))
(when (functionp doc-fun)
(if (functionp callback)
(funcall doc-fun callback)
(funcall doc-fun)))))))))
;;;###autoload
(defun org-eldoc-load ()

View File

@@ -6,7 +6,7 @@
;; Eric Schulte <schulte dot eric at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp, literate programming,
;; reproducible research
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.04
;; This file is not part of GNU Emacs.

View File

@@ -3,7 +3,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.04
;;
;; This file is not part of GNU Emacs.

View File

@@ -282,6 +282,9 @@ The expiry process will run the function defined by
processed expired))))))
;;; Insert created/expiry property:
(defun org-expiry-format-timestamp (timestr inactive)
"Properly format TIMESTR into an org (in)active timestamp"
(format (if inactive "[%s]" "<%s>") timestr))
(defun org-expiry-insert-created (&optional arg)
"Insert or update a property with the creation date.
@@ -299,10 +302,13 @@ update the date."
(setq d-hour (format-time-string "%H:%M" d-time))
(setq timestr
;; two C-u prefixes will call org-read-date
(if (equal arg '(16))
(concat "<" (org-read-date
nil nil nil nil d-time d-hour) ">")
(format-time-string (cdr org-time-stamp-formats))))
(concat "<"
(if (equal arg '(16))
(org-read-date nil nil nil nil d-time d-hour)
(format-time-string
(replace-regexp-in-string "\\(^<\\|>$\\)" ""
(cdr org-time-stamp-formats))))
">"))
;; maybe transform to inactive timestamp
(if org-expiry-inactive-timestamps
(setq timestr (concat "[" (substring timestr 1 -1) "]")))
@@ -320,10 +326,13 @@ and insert today's date."
(setq d-time (if d (org-time-string-to-time d)
(current-time)))
(setq d-hour (format-time-string "%H:%M" d-time))
(setq timestr (if today
(format-time-string (cdr org-time-stamp-formats))
(concat "<" (org-read-date
nil nil nil nil d-time d-hour) ">")))
(setq timestr (concat "<"
(if today
(format-time-string
(replace-regexp-in-string "\\(^<\\|>$\\)" ""
(cdr org-time-stamp-formats)))
(org-read-date nil nil nil nil d-time d-hour))
">"))
;; maybe transform to inactive timestamp
(if org-expiry-inactive-timestamps
(setq timestr (concat "[" (substring timestr 1 -1) "]")))

View File

@@ -4,7 +4,7 @@
;; Author: John Wiegley <johnw at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 6.32trans
;;
;; This file is not part of GNU Emacs.

View File

@@ -4,7 +4,7 @@
;; Author: David Arroyo Menéndez <davidam@es.gnu.org>
;; Keywords: licenses, creative commons
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;;
;; This file is not part of GNU Emacs.
;;

View File

@@ -1,392 +0,0 @@
;;; org-link-edit.el --- Slurp and barf with Org links -*- lexical-binding: t; -*-
;; Copyright (C) 2015-2021 Kyle Meyer <kyle@kyleam.com>
;; Author: Kyle Meyer <kyle@kyleam.com>
;; Homepage: https://git.kyleam.com/org-link-edit/about
;; Keywords: convenience
;; Version: 1.2.1
;; Package-Requires: ((cl-lib "0.5") (org "9.3"))
;; 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Org Link Edit provides Paredit-inspired slurping and barfing
;; commands for Org link descriptions.
;;
;; There are four slurp and barf commands, all which operate when
;; point is on an Org link.
;;
;; - org-link-edit-forward-slurp
;; - org-link-edit-backward-slurp
;; - org-link-edit-forward-barf
;; - org-link-edit-backward-barf
;;
;; Org Link Edit doesn't bind these commands to any keys. Finding
;; good keys for these commands is difficult because, while it's
;; convenient to be able to quickly repeat these commands, they won't
;; be used frequently enough to be worthy of a short, repeat-friendly
;; binding. Using Hydra [1] provides a nice solution to this. After
;; an initial key sequence, any of the commands will be repeatable
;; with a single key. (Plus, you get a nice interface that displays
;; the key for each command.) Below is one example of how you could
;; configure this.
;;
;; (define-key org-mode-map YOUR-KEY
;; (defhydra hydra-org-link-edit ()
;; "Org Link Edit"
;; ("j" org-link-edit-forward-slurp "forward slurp")
;; ("k" org-link-edit-forward-barf "forward barf")
;; ("u" org-link-edit-backward-slurp "backward slurp")
;; ("i" org-link-edit-backward-barf "backward barf")
;; ("q" nil "cancel")))
;;
;; In addition to the slurp and barf commands, the command
;; `org-link-edit-transport-next-link' searches for the next (or
;; previous) link and moves it to point, using the word at point or
;; the selected region as the link's description.
;;
;; [1] https://github.com/abo-abo/hydra
;;; Code:
(require 'org)
(require 'org-element)
(require 'cl-lib)
(defun org-link-edit--on-link-p (&optional element)
(org-element-lineage (or element (org-element-context)) '(link) t))
(defun org-link-edit--link-data ()
"Return list with information about the link at point.
The list includes
- the position at the start of the link
- the position at the end of the link
- the link text
- the link description (nil when on a plain link)"
(let ((el (org-element-context)))
(unless (org-link-edit--on-link-p el)
(user-error "Point is not on a link"))
(save-excursion
(goto-char (org-element-property :begin el))
(cond
;; Use match-{beginning,end} because match-end is consistently
;; positioned after ]], while the :end property is positioned
;; at the next word on the line, if one is present.
((looking-at org-link-bracket-re)
(list (match-beginning 0)
(match-end 0)
(save-match-data
(org-link-unescape (match-string-no-properties 1)))
(or (match-string-no-properties 2) "")))
((looking-at org-link-plain-re)
(list (match-beginning 0)
(match-end 0)
(match-string-no-properties 0)
nil))
(t
(error "What am I looking at?"))))))
(defun org-link-edit--forward-blob (n &optional no-punctuation)
"Move forward N blobs (backward if N is negative).
A block of non-whitespace characters is a blob. If
NO-PUNCTUATION is non-nil, trailing punctuation characters are
not considered part of the blob when going in the forward
direction.
If the edge of the buffer is reached before completing the
movement, return nil. Otherwise, return t."
(let* ((forward-p (> n 0))
(nblobs (abs n))
(skip-func (if forward-p 'skip-syntax-forward 'skip-syntax-backward))
skip-func-retval)
(while (/= nblobs 0)
(funcall skip-func " ")
(setq skip-func-retval (funcall skip-func "^ "))
(setq nblobs (1- nblobs)))
(when (and forward-p no-punctuation)
(let ((punc-tail-offset (save-excursion (skip-syntax-backward "."))))
;; Don't consider trailing punctuation as part of the blob
;; unless the whole blob consists of punctuation.
(unless (= skip-func-retval (- punc-tail-offset))
(goto-char (+ (point) punc-tail-offset)))))
(/= skip-func-retval 0)))
;;;###autoload
(defun org-link-edit-forward-slurp (&optional n)
"Slurp N trailing blobs into link's description.
The \[\[https://orgmode.org/\]\[Org mode\]\] site
|
v
The \[\[https://orgmode.org/\]\[Org mode site\]\]
A blob is a block of non-whitespace characters. When slurping
forward, trailing punctuation characters are not considered part
of a blob.
After slurping, return the slurped text and move point to the
beginning of the link.
If N is negative, slurp leading blobs instead of trailing blobs."
(interactive "p")
(setq n (or n 1))
(cond
((= n 0))
((< n 0)
(org-link-edit-backward-slurp (- n)))
(t
(cl-multiple-value-bind (beg end link desc) (org-link-edit--link-data)
(goto-char (save-excursion
(goto-char end)
(or (org-link-edit--forward-blob n 'no-punctuation)
(user-error "Not enough blobs after the link"))
(point)))
(let ((slurped (buffer-substring-no-properties end (point))))
(setq slurped (replace-regexp-in-string "\n+" " " slurped))
(when (and (= (length desc) 0)
(string-match "^\\s-+\\(.*\\)" slurped))
(setq slurped (match-string 1 slurped)))
(setq desc (concat desc slurped)
end (+ end (length slurped)))
(delete-region beg (point))
(insert (org-link-make-string link desc))
(goto-char beg)
slurped)))))
;;;###autoload
(defun org-link-edit-backward-slurp (&optional n)
"Slurp N leading blobs into link's description.
The \[\[https://orgmode.org/\]\[Org mode\]\] site
|
v
\[\[https://orgmode.org/\]\[The Org mode\]\] site
A blob is a block of non-whitespace characters.
After slurping, return the slurped text and move point to the
beginning of the link.
If N is negative, slurp trailing blobs instead of leading blobs."
(interactive "p")
(setq n (or n 1))
(cond
((= n 0))
((< n 0)
(org-link-edit-forward-slurp (- n)))
(t
(cl-multiple-value-bind (beg end link desc) (org-link-edit--link-data)
(goto-char (save-excursion
(goto-char beg)
(or (org-link-edit--forward-blob (- n))
(user-error "Not enough blobs before the link"))
(point)))
(let ((slurped (buffer-substring-no-properties (point) beg)))
(when (and (= (length desc) 0)
(string-match "\\(.*\\)\\s-+$" slurped))
(setq slurped (match-string 1 slurped)))
(setq slurped (replace-regexp-in-string "\n+" " " slurped))
(setq desc (concat slurped desc)
beg (- beg (length slurped)))
(delete-region (point) end)
(insert (org-link-make-string link desc))
(goto-char beg)
slurped)))))
(defun org-link-edit--split-first-blobs (string n)
"Split STRING into (N first blobs . other) cons cell.
'N first blobs' contains all text from the start of STRING up to
the start of the N+1 blob. 'other' includes the remaining text
of STRING. If the number of blobs in STRING is fewer than N,
'other' is nil."
(when (< n 0) (user-error "N cannot be negative"))
(with-temp-buffer
(insert string)
(goto-char (point-min))
(with-syntax-table org-mode-syntax-table
(let ((within-bound (org-link-edit--forward-blob n)))
(skip-syntax-forward " ")
(cons (buffer-substring 1 (point))
(and within-bound
(buffer-substring (point) (point-max))))))))
(defun org-link-edit--split-last-blobs (string n)
"Split STRING into (other . N last blobs) cons cell.
'N last blobs' contains all text from the end of STRING back to
the end of the N+1 last blob. 'other' includes the remaining
text of STRING. If the number of blobs in STRING is fewer than
N, 'other' is nil."
(when (< n 0) (user-error "N cannot be negative"))
(with-temp-buffer
(insert string)
(goto-char (point-max))
(with-syntax-table org-mode-syntax-table
(let ((within-bound (org-link-edit--forward-blob (- n))))
(skip-syntax-backward " ")
(cons (and within-bound
(buffer-substring 1 (point)))
(buffer-substring (point) (point-max)))))))
;;;###autoload
(defun org-link-edit-forward-barf (&optional n)
"Barf N trailing blobs from link's description.
The \[\[https://orgmode.org/\]\[Org mode\]\] site
|
v
The \[\[https://orgmode.org/\]\[Org\]\] mode site
A blob is a block of non-whitespace characters.
After barfing, return the barfed text and move point to the
beginning of the link.
If N is negative, barf leading blobs instead of trailing blobs."
(interactive "p")
(setq n (or n 1))
(cond
((= n 0))
((< n 0)
(org-link-edit-backward-barf (- n)))
(t
(cl-multiple-value-bind (beg end link desc) (org-link-edit--link-data)
(when (= (length desc) 0)
(user-error "Link has no description"))
(pcase-let ((`(,new-desc . ,barfed) (org-link-edit--split-last-blobs
desc n)))
(unless new-desc (user-error "Not enough blobs in description"))
(goto-char beg)
(delete-region beg end)
(insert (org-link-make-string link new-desc))
(when (string= new-desc "")
(setq barfed (concat " " barfed)))
(insert barfed)
(goto-char beg)
barfed)))))
;;;###autoload
(defun org-link-edit-backward-barf (&optional n)
"Barf N leading blobs from link's description.
The \[\[https://orgmode.org/\]\[Org mode\]\] site
|
v
The Org \[\[https://orgmode.org/\]\[mode\]\] site
A blob is a block of non-whitespace characters.
After barfing, return the barfed text and move point to the
beginning of the link.
If N is negative, barf trailing blobs instead of leading blobs."
(interactive "p")
(setq n (or n 1))
(cond
((= n 0))
((< n 0)
(org-link-edit-forward-barf (- n)))
(t
(cl-multiple-value-bind (beg end link desc) (org-link-edit--link-data)
(when (= (length desc) 0)
(user-error "Link has no description"))
(pcase-let ((`(,barfed . ,new-desc) (org-link-edit--split-first-blobs
desc n)))
(unless new-desc (user-error "Not enough blobs in description"))
(goto-char beg)
(delete-region beg end)
(insert (org-link-make-string link new-desc))
(when (string= new-desc "")
(setq barfed (concat barfed " ")))
(goto-char beg)
(insert barfed)
barfed)))))
(defun org-link-edit--next-link-data (&optional previous)
(save-excursion
(if (funcall (if previous #'re-search-backward #'re-search-forward)
org-link-any-re nil t)
(org-link-edit--link-data)
(user-error "No %s link found" (if previous "previous" "next")))))
;;;###autoload
(defun org-link-edit-transport-next-link (&optional previous beg end overwrite)
"Move the next link to point.
If the region is active, use the selected text as the link's
description. Otherwise, use the word at point.
With prefix argument PREVIOUS, move the previous link instead of
the next link.
Non-interactively, use the text between BEG and END as the
description, moving the next (or previous) link relative to BEG
and END. By default, refuse to overwrite an existing
description. If OVERWRITE is `ask', prompt for confirmation
before overwriting; for any other non-nil value, overwrite
without asking."
(interactive `(,current-prefix-arg
,@(if (use-region-p)
(list (region-beginning) (region-end))
(list nil nil))
ask))
(let ((pt (point))
(desc-bounds (cond
((and beg end)
(cons (progn (goto-char beg)
(point-marker))
(progn (goto-char end)
(point-marker))))
((not (looking-at-p "\\s-"))
(progn (skip-syntax-backward "w")
(let ((beg (point-marker)))
(skip-syntax-forward "w")
(cons beg (point-marker))))))))
(when (or (and desc-bounds
(or (progn (goto-char (car desc-bounds))
(org-link-edit--on-link-p))
(progn (goto-char (cdr desc-bounds))
(org-link-edit--on-link-p))))
(progn (goto-char pt)
(org-link-edit--on-link-p)))
(user-error "Cannot transport next link with point on a link"))
(goto-char (or (car desc-bounds) pt))
(cl-multiple-value-bind (link-beg link-end link orig-desc)
(org-link-edit--next-link-data previous)
(unless (or (not desc-bounds)
(= (length orig-desc) 0)
(if (eq overwrite 'ask)
(y-or-n-p "Overwrite existing description?")
overwrite))
(user-error "Link already has a description"))
(delete-region link-beg link-end)
(insert (org-link-make-string
link
(if desc-bounds
(delete-and-extract-region (car desc-bounds)
(cdr desc-bounds))
orig-desc))))))
(provide 'org-link-edit)
;;; org-link-edit.el ends here

File diff suppressed because it is too large Load Diff

View File

@@ -1,407 +0,0 @@
;;; org-notify.el --- Notifications for Org-mode
;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
;; Author: Peter Münster <pmrb@free.fr>
;; Homepage: https://github.com/p-m/org-notify
;; Keywords: notification, todo-list, alarm, reminder, pop-up
;; 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 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Get notifications, when there is something to do.
;; Sometimes, you need a reminder a few days before a deadline, e.g. to buy a
;; present for a birthday, and then another notification one hour before to
;; have enough time to choose the right clothes.
;; For other events, e.g. rolling the dustbin to the roadside once per week,
;; you probably need another kind of notification strategy.
;; This package tries to satisfy the various needs.
;; In order to activate this package, you must add the following code
;; into your .emacs:
;;
;; (require 'org-notify)
;; (org-notify-start)
;; Example setup:
;;
;; (org-notify-add 'appt
;; '(:time "-1s" :period "20s" :duration 10
;; :actions (-message -ding))
;; '(:time "15m" :period "2m" :duration 100
;; :actions -notify)
;; '(:time "2h" :period "5m" :actions -message)
;; '(:time "3d" :actions -email))
;;
;; This means for todo-items with `notify' property set to `appt': 3 days
;; before deadline, send a reminder-email, 2 hours before deadline, start to
;; send messages every 5 minutes, then 15 minutes before deadline, start to
;; pop up notification windows every 2 minutes. The timeout of the window is
;; set to 100 seconds. Finally, when deadline is overdue, send messages and
;; make noise."
;; Take also a look at the function `org-notify-add'.
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'org-element)
(declare-function appt-delete-window "appt" ())
(declare-function notifications-notify "notifications" (&rest prms))
(declare-function article-lapsed-string "gnus-art" (t &optional ms))
(defgroup org-notify nil
"Options for Org-mode notifications."
:tag "Org Notify"
:group 'org)
(defcustom org-notify-audible t
"Non-nil means beep to indicate notification."
:type 'boolean
:group 'org-notify)
(defcustom org-notify-max-notifications-per-run 3
"Maximum number of notifications per run of `org-notify-process'."
:type 'integer
:group 'org-notify)
(defconst org-notify-actions
'("show" "show" "done" "done" "hour" "one hour later" "day" "one day later"
"week" "one week later")
"Possible actions for call-back functions.")
(defconst org-notify-window-buffer-name "*org-notify-%s*"
"Buffer-name for the `org-notify-action-window' function.")
(defvar org-notify-map nil
"Mapping between names and parameter lists.")
(defvar org-notify-timer nil
"Timer of the notification daemon.")
(defvar org-notify-parse-file nil
"Index of current file, that `org-element-parse-buffer' is parsing.")
(defvar org-notify-on-action-map nil
"Mapping between on-action identifiers and parameter lists.")
(defun org-notify-string->seconds (str)
"Convert time string STR to number of seconds."
(when str
(let* ((conv `(("s" . 1) ("m" . 60) ("h" . ,(* 60 60))
("d" . ,(* 24 60 60)) ("w" . ,(* 7 24 60 60))
("M" . ,(* 30 24 60 60))))
(letters (concat
(mapcar (lambda (x) (string-to-char (car x))) conv)))
(case-fold-search nil))
(string-match (concat "\\(-?\\)\\([0-9]+\\)\\([" letters "]\\)") str)
(* (string-to-number (match-string 2 str))
(cdr (assoc (match-string 3 str) conv))
(if (= (length (match-string 1 str)) 1) -1 1)))))
(defun org-notify-convert-deadline (orig)
"Convert original deadline from `org-element-parse-buffer' to
simple timestamp string."
(if orig
(replace-regexp-in-string "^<\\|>$" ""
(plist-get (plist-get orig 'timestamp)
:raw-value))))
(defun org-notify-make-todo (heading &rest ignored)
"Create one todo item."
(cl-macrolet ((get (k) `(plist-get list ,k))
(pr (k v) `(setq result (plist-put result ,k ,v))))
(let* ((list (nth 1 heading)) (notify (or (get :NOTIFY) "default"))
(deadline (org-notify-convert-deadline (get :deadline)))
(heading (get :raw-value))
result)
(when (and (eq (get :todo-type) 'todo) heading deadline)
(pr :heading heading) (pr :notify (intern notify))
(pr :begin (get :begin))
(pr :file (nth org-notify-parse-file (org-agenda-files 'unrestricted)))
(pr :timestamp deadline) (pr :uid (md5 (concat heading deadline)))
(pr :deadline (- (org-time-string-to-seconds deadline)
(float-time))))
result)))
(defun org-notify-todo-list ()
"Create the todo-list for one org-agenda file."
(let* ((files (org-agenda-files 'unrestricted))
(max (1- (length files))))
(when files
(setq org-notify-parse-file
(if (or (not org-notify-parse-file) (>= org-notify-parse-file max))
0
(1+ org-notify-parse-file)))
(save-excursion
(with-current-buffer (find-file-noselect
(nth org-notify-parse-file files))
(org-element-map (org-element-parse-buffer 'headline)
'headline 'org-notify-make-todo))))))
(defun org-notify-maybe-too-late (diff period heading)
"Print warning message, when notified significantly later than defined by
PERIOD."
(if (> (/ diff period) 1.5)
(message "Warning: notification for \"%s\" behind schedule!" heading))
t)
(cl-defun org-notify-process ()
"Process the todo-list, and possibly notify user about upcoming or
forgotten tasks."
(let ((notification-cnt 0))
(cl-macrolet ((prm (k) `(plist-get prms ,k)) (td (k) `(plist-get todo ,k)))
(dolist (todo (org-notify-todo-list))
(let* ((deadline (td :deadline)) (heading (td :heading))
(uid (td :uid)) (last-run-sym
(intern (concat ":last-run-" uid))))
(cl-dolist (prms (plist-get org-notify-map (td :notify)))
(when (< deadline (org-notify-string->seconds (prm :time)))
(let ((period (org-notify-string->seconds (prm :period)))
(last-run (prm last-run-sym)) (now (float-time))
(actions (prm :actions)) diff plist)
(when (or (not last-run)
(and period (< period (setq diff (- now last-run)))
(org-notify-maybe-too-late diff period heading)))
(setq prms (plist-put prms last-run-sym now)
plist (append todo prms))
(if (if (plist-member prms :audible)
(prm :audible)
org-notify-audible)
(ding))
(unless (listp actions)
(setq actions (list actions)))
(cl-incf notification-cnt)
(dolist (action actions)
(funcall (if (fboundp action) action
(intern (concat "org-notify-action"
(symbol-name action))))
plist))
(when (>= notification-cnt org-notify-max-notifications-per-run)
(cl-return-from org-notify-process)))
(cl-return)))))))))
(defun org-notify-add (name &rest params)
"Add a new notification type.
The NAME can be used in Org-mode property `notify'. If NAME is
`default', the notification type applies for todo items without
the `notify' property. This file predefines such a default
notification type.
Each element of PARAMS is a list with parameters for a given time
distance to the deadline. This distance must increase from one
element to the next.
List of possible parameters:
:time Time distance to deadline, when this type of notification shall
start. It's a string: an integral value (positive or negative)
followed by a unit (s, m, h, d, w, M).
:actions A function or a list of functions to be called to notify the
user. Instead of a function name, you can also supply a suffix
of one of the various predefined `org-notify-action-xxx'
functions.
:period Optional: can be used to repeat the actions periodically.
Same format as :time.
:duration Some actions use this parameter to specify the duration of the
notification. It's an integral number in seconds.
:audible Overwrite the value of `org-notify-audible' for this action.
For the actions, you can use your own functions or some of the predefined
ones, whose names are prefixed with `org-notify-action-'."
(setq org-notify-map (plist-put org-notify-map name params)))
(defun org-notify-start (&optional secs)
"Start the notification daemon.
If SECS is positive, it's the period in seconds for processing
the notifications of one org-agenda file, and if negative,
notifications will be checked only when emacs is idle for -SECS
seconds. The default value for SECS is 20."
(interactive)
(if org-notify-timer
(org-notify-stop))
(setq secs (or secs 20)
org-notify-timer (if (< secs 0)
(run-with-idle-timer (* -1 secs) t
'org-notify-process)
(run-with-timer secs secs 'org-notify-process))))
(defun org-notify-stop ()
"Stop the notification daemon."
(when org-notify-timer
(cancel-timer org-notify-timer)
(setq org-notify-timer nil)))
(defun org-notify-on-action (plist key)
"User wants to see action."
(let ((file (plist-get plist :file))
(begin (plist-get plist :begin)))
(if (string-equal key "show")
(progn
(switch-to-buffer (find-file-noselect file))
(org-with-wide-buffer
(goto-char begin)
(outline-show-entry))
(goto-char begin)
(search-forward "DEADLINE: <")
(search-forward ":")
(if (display-graphic-p)
(x-focus-frame nil)))
(save-excursion
(with-current-buffer (find-file-noselect file)
(org-with-wide-buffer
(goto-char begin)
(search-forward "DEADLINE: <")
(cond
((string-equal key "done") (org-todo))
((string-equal key "hour") (org-timestamp-change 60 'minute))
((string-equal key "day") (org-timestamp-up-day))
((string-equal key "week") (org-timestamp-change 7 'day)))))))))
(defun org-notify-on-action-notify (id key)
"User wants to see action after mouse-click in notify window."
(org-notify-on-action (plist-get org-notify-on-action-map id) key)
(org-notify-on-close id nil))
(defun org-notify-on-action-button (button)
"User wants to see action after button activation."
(cl-macrolet ((get (k) `(button-get button ,k)))
(org-notify-on-action (get 'plist) (get 'key))
(org-notify-delete-window (get 'buffer))
(cancel-timer (get 'timer))))
(defun org-notify-delete-window (buffer)
"Delete the notification window."
(require 'appt)
(let ((appt-buffer-name buffer)
(appt-audible nil))
(appt-delete-window)))
(defun org-notify-on-close (id reason)
"Notification window has been closed."
(setq org-notify-on-action-map (plist-put org-notify-on-action-map id nil)))
(defun org-notify-action-message (plist)
"Print a message."
(message "TODO: \"%s\" at %s!" (plist-get plist :heading)
(plist-get plist :timestamp)))
(defun org-notify-action-ding (plist)
"Make noise."
(let ((timer (run-with-timer 0 1 'ding)))
(run-with-timer (or (plist-get plist :duration) 3) nil
'cancel-timer timer)))
(defun org-notify-body-text (plist)
"Make human readable string for remaining time to deadline."
(require 'gnus-art)
(format "%s\n(%s)"
(replace-regexp-in-string
" in the future" ""
(article-lapsed-string
(time-add (current-time)
(seconds-to-time (plist-get plist :deadline))) 2))
(plist-get plist :timestamp)))
(defun org-notify-action-email (plist)
"Send email to user."
(compose-mail user-mail-address (concat "TODO: " (plist-get plist :heading)))
(insert (org-notify-body-text plist))
(funcall send-mail-function)
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (x) t)))
(kill-buffer)))
(defun org-notify-select-highest-window ()
"Select the highest window on the frame, that is not is not an
org-notify window. Mostly copied from `appt-select-lowest-window'."
(let ((highest-window (selected-window))
(bottom-edge (nth 3 (window-edges)))
next-bottom-edge)
(walk-windows (lambda (w)
(when (and
(not (string-match "^\\*org-notify-.*\\*$"
(buffer-name
(window-buffer w))))
(> bottom-edge (setq next-bottom-edge
(nth 3 (window-edges w)))))
(setq bottom-edge next-bottom-edge
highest-window w))) 'nomini)
(select-window highest-window)))
(defun org-notify-action-window (plist)
"Pop up a window, mostly copied from `appt-disp-window'."
(save-excursion
(cl-macrolet ((get (k) `(plist-get plist ,k)))
(let ((this-window (selected-window))
(buf (get-buffer-create
(format org-notify-window-buffer-name (get :uid)))))
(when (minibufferp)
(other-window 1)
(and (minibufferp) (display-multi-frame-p) (other-frame 1)))
(if (cdr (assq 'unsplittable (frame-parameters)))
(progn (set-buffer buf) (display-buffer buf))
(unless (or (special-display-p (buffer-name buf))
(same-window-p (buffer-name buf)))
(org-notify-select-highest-window)
(when (>= (window-height) (* 2 window-min-height))
(select-window (split-window nil nil 'above))))
(switch-to-buffer buf))
(setq buffer-read-only nil buffer-undo-list t)
(erase-buffer)
(insert (format "TODO: %s, %s.\n" (get :heading)
(org-notify-body-text plist)))
(let ((timer (run-with-timer (or (get :duration) 10) nil
'org-notify-delete-window buf)))
(dotimes (i (/ (length org-notify-actions) 2))
(let ((key (nth (* i 2) org-notify-actions))
(text (nth (1+ (* i 2)) org-notify-actions)))
(insert-button text 'action 'org-notify-on-action-button
'key key 'buffer buf 'plist plist 'timer timer)
(insert " "))))
(shrink-window-if-larger-than-buffer (get-buffer-window buf t))
(set-buffer-modified-p nil) (setq buffer-read-only t)
(raise-frame (selected-frame)) (select-window this-window)))))
(defun org-notify-action-notify (plist)
"Pop up a notification window."
(require 'notifications)
(let* ((duration (plist-get plist :duration))
(id (notifications-notify
:title (plist-get plist :heading)
:body (org-notify-body-text plist)
:timeout (if duration (* duration 1000))
:urgency (plist-get plist :urgency)
:actions org-notify-actions
:on-action 'org-notify-on-action-notify)))
(setq org-notify-on-action-map
(plist-put org-notify-on-action-map id plist))))
(defun org-notify-action-notify/window (plist)
"For a graphics display, pop up a notification window, for a text
terminal an emacs window."
(if (display-graphic-p)
(org-notify-action-notify plist)
(org-notify-action-window plist)))
;;; Provide a minimal default setup.
(org-notify-add 'default '(:time "1h" :actions -notify/window
:period "2m" :duration 60))
(provide 'org-notify)
;;; org-notify.el ends here

View File

@@ -1,385 +0,0 @@
;;; org-passwords.el --- org derived mode for managing passwords
;; Author: Jorge A. Alfaro-Murillo <jorge.alfaro-murillo@yale.edu>
;; Created: December 26, 2012
;; Homepage: https://github.com/alfaromurillo/org-passwords.el
;; Keywords: passwords, password
;; 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 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;; This file contains the code for managing your passwords with
;; Org-mode. It is part of org/contrib (see https://orgmode.org/). If
;; you want to contribute with development, or have a problem, do it
;; here: https://bitbucket.org/alfaromurillo/org-passwords.el
;; A basic setup needs to indicate a passwords file, and a dictionary
;; for the random words:
;; (require 'org-passwords)
;; (setq org-passwords-file "~/documents/passwords.gpg")
;; (setq org-passwords-random-words-dictionary "/etc/dictionaries-common/words")
;; Basic usage:
;; `M-x org-passwords' opens the passwords file in
;; `org-passwords-mode'.
;; `M-x org-passwords-generate-password' generates a random string
;; of numbers, lowercase letters and uppercase letters.
;; `C-u M-x org-passwords-generate-password' generates a random
;; string of numbers, lowercase letters, uppercase letters and
;; symbols.
;; `M-x org-passwords-random-words' concatenates random words from
;; the dictionary defined by `org-passwords-random-words-dictionary'
;; into a string, each word separated by the string defined in
;; `org-passwords-random-words-separator'.
;; `C-u M-x org-passwords-random-words' does the same as above, and
;; also makes substitutions according to
;; `org-passwords-random-words-substitutions'.
;; It is also useful to set up keybindings for the functions
;; `org-passwords-copy-username', `org-passwords-copy-password' and
;; `org-passwords-open-url' in the `org-passwords-mode', to easily
;; make the passwords and usernames available to the facility for
;; pasting text of the window system (clipboard on X and MS-Windows,
;; pasteboard on Nextstep/Mac OS, etc.), without inserting them in the
;; kill-ring. You can set for example:
;; (eval-after-load "org-passwords"
;; '(progn
;; (define-key org-passwords-mode-map
;; (kbd "C-c u")
;; 'org-passwords-copy-username)
;; (define-key org-passwords-mode-map
;; (kbd "C-c p")
;; 'org-passwords-copy-password)
;; (kbd "C-c o")
;; 'org-passwords-open-url)))
;; Finally, to enter new passwords, you can use `org-capture' and a
;; minimal template like:
;; ("p" "password" entry (file "~/documents/passwords.gpg")
;; "* %^{Title}\n %^{URL}p %^{USERNAME}p %^{PASSWORD}p")
;; When asked for the password you can then call either
;; `org-passwords-generate-password' or `org-passwords-random-words'.
;; Be sure to enable recursive minibuffers to call those functions
;; from the minibuffer:
;; (setq enable-recursive-minibuffers t)
;;; Code:
(require 'org)
;;;###autoload
(define-derived-mode org-passwords-mode org-mode
"org-passwords-mode"
"Mode for storing passwords"
nil)
(defgroup org-passwords nil
"Options for password management."
:group 'org)
(defcustom org-passwords-password-property "PASSWORD"
"Name of the property for password entry."
:type 'string
:group 'org-passwords)
(defcustom org-passwords-username-property "USERNAME"
"Name of the property for user name entry."
:type 'string
:group 'org-passwords)
(defcustom org-passwords-url-property "URL"
"Name of the property for URL entry."
:type 'string
:group 'org-passwords)
(defcustom org-passwords-file nil
"Default file name for the file that contains the passwords."
:type 'file
:group 'org-passwords)
(defcustom org-passwords-time-opened "1 min"
"Time that the password file will remain open. It has to be a
string, a number followed by units."
:type 'str
:group 'org-passwords)
(defcustom org-passwords-default-password-size "20"
"Default number of characters to use in
org-passwords-generate-password. It has to be a string."
:type 'str
:group 'org-passwords)
(defcustom org-passwords-random-words-dictionary nil
"Default file name for the file that contains a dictionary of
words for `org-passwords-random-words'. Each non-empty line in
the file is considered a word."
:type 'file
:group 'org-passwords)
(defcustom org-passwords-default-random-words-number "5"
"Default number of words to use in org-passwords-random-words.
It has to be a string."
:type 'str
:group 'org-passwords)
(defvar org-passwords-random-words-separator "-"
"A string to separate words in `org-passwords-random-words'.")
(defvar org-passwords-random-words-substitutions
'(("a" . "@")
("e" . "3")
("o" . "0"))
"A list of substitutions to be made with
`org-passwords-random-words' if it is called with
`universal-argument'. Each element is pair of
strings (SUBSTITUTE-THIS . BY-THIS).")
(defun org-passwords-copy-password ()
"Makes the password available to other programs. Puts the
password of the entry at the location of the cursor in the
facility for pasting text of the window system (clipboard on X
and MS-Windows, pasteboard on Nextstep/Mac OS, etc.), without
putting it in the kill ring."
(interactive)
(funcall interprogram-cut-function
(org-entry-get (point)
org-passwords-password-property)))
(defun org-passwords-copy-username ()
"Makes the password available to other programs. Puts the
username of the entry at the location of the cursor in the
facility for pasting text of the window system (clipboard on X
and MS-Windows, pasteboard on Nextstep/Mac OS, etc.), without
putting it in the kill ring."
(interactive)
(funcall interprogram-cut-function
(org-entry-get (point)
org-passwords-username-property
t)))
(defun org-passwords-open-url ()
"Browse the URL associated with the entry at the location of
the cursor."
(interactive)
(browse-url (org-entry-get (point)
org-passwords-url-property
t)))
;;;###autoload
(defun org-passwords (&optional arg)
"Open the password file. Open the password file defined by the
variable `org-password-file' in read-only mode and kill that
buffer later according to the value of the variable
`org-passwords-time-opened'. It also adds the `org-password-file'
to the auto-mode-alist so that it is opened with its mode being
`org-passwords-mode'.
With prefix arg ARG, the command does not set up a timer to kill the buffer.
With a double prefix arg \\[universal-argument] \\[universal-argument], open the file for editing.
"
(interactive "P")
(if org-passwords-file
(progn
(add-to-list 'auto-mode-alist
(cons
(regexp-quote
(expand-file-name org-passwords-file))
'org-passwords-mode))
(if (equal arg '(4))
(find-file-read-only org-passwords-file)
(if (equal arg '(16))
(find-file org-passwords-file)
(progn
(find-file-read-only org-passwords-file)
(org-passwords-set-up-kill-password-buffer)))))
(minibuffer-message "No default password file defined. Set the variable `org-password-file'.")))
(defun org-passwords-set-up-kill-password-buffer ()
(run-at-time org-passwords-time-opened
nil
'(lambda ()
(if (get-file-buffer org-passwords-file)
(kill-buffer
(get-file-buffer org-passwords-file))))))
;;; Password generator
;; Set random number seed from current time and pid. Otherwise
;; `random' gives the same results every time emacs restarts.
(random t)
(defun org-passwords-generate-password (arg)
"Ask a number of characters and insert a password of that size.
Password has a random string of numbers, lowercase letters, and
uppercase letters. Argument ARG include symbols."
(interactive "P")
(let ((number-of-chars
(read-from-minibuffer
(concat "Number of characters (default "
org-passwords-default-password-size
"): ")
nil
nil
t
nil
org-passwords-default-password-size)))
(if arg
(insert (org-passwords-generate-password-with-symbols "" number-of-chars))
(insert (org-passwords-generate-password-without-symbols "" number-of-chars)))))
(defun org-passwords-generate-password-with-symbols (previous-string nums-of-chars)
"Return a string consisting of PREVIOUS-STRING and
NUMS-OF-CHARS random characters."
(if (eq nums-of-chars 0) previous-string
(org-passwords-generate-password-with-symbols
(concat previous-string
(char-to-string
;; symbols, letters, numbers are from 33 to 126
(+ (random (- 127 33)) 33)))
(1- nums-of-chars))))
(defun org-passwords-generate-password-without-symbols (previous-string nums-of-chars)
"Return string consisting of PREVIOUS-STRING and NUMS-OF-CHARS
random numbers, lowercase letters, and numbers."
(if (eq nums-of-chars 0)
previous-string
; There are 10 numbers, 26 lowercase letters and 26 uppercase
; letters. 10 + 26 + 26 = 62. The number characters go from 48
; to 57, the uppercase letters from 65 to 90, and the lowercase
; from 97 to 122. The following makes each equally likely.
(let ((temp-value (random 62)))
(cond ((< temp-value 10)
; If temp-value<10, then add a number
(org-passwords-generate-password-without-symbols
(concat previous-string
(char-to-string (+ 48 temp-value)))
(1- nums-of-chars)))
((and (> temp-value 9) (< temp-value 36))
; If 9<temp-value<36, then add an uppercase letter
(org-passwords-generate-password-without-symbols
(concat previous-string
(char-to-string (+ 65 (- temp-value 10))))
(1- nums-of-chars)))
((> temp-value 35)
; If temp-value>35, then add a lowecase letter
(org-passwords-generate-password-without-symbols
(concat previous-string
(char-to-string (+ 97 (- temp-value 36))))
(1- nums-of-chars)))))))
;;; Random words
(defun org-passwords-random-words (arg)
"Ask for a number of words and inserts a sequence of that many
random words from the list in the file
`org-passwords-random-words-dictionary' separated by
`org-passwords-random-words-separator'. ARG make substitutions in
the words as defined by
`org-passwords-random-words-substitutions'."
(interactive "P")
(if org-passwords-random-words-dictionary
(let ((number-of-words
(read-from-minibuffer
(concat "Number of words (default "
org-passwords-default-random-words-number
"): ")
nil
nil
t
nil
org-passwords-default-random-words-number))
(list-of-words
(with-temp-buffer
(insert-file-contents
org-passwords-random-words-dictionary)
(split-string (buffer-string) "\n" t))))
(insert
(org-passwords-substitute
(org-passwords-random-words-attach-number-of-words
(nth (random (length list-of-words))
list-of-words)
(1- number-of-words)
list-of-words
org-passwords-random-words-separator)
(if arg
org-passwords-random-words-substitutions
nil))))
(minibuffer-message
"No default dictionary file defined. Set the variable `org-passwords-random-words-dictionary'.")))
(defun org-passwords-random-words-attach-number-of-words
(previous-string number-of-words list-of-words separator)
"Returns a string consisting of PREVIOUS-STRING followed by a
succession of NUMBER-OF-WORDS random words from the list LIST-OF-WORDS
separated SEPARATOR."
(if (eq number-of-words 0)
previous-string
(org-passwords-random-words-attach-number-of-words
(concat previous-string
separator
(nth (random (length list-of-words)) list-of-words))
(1- number-of-words)
list-of-words
separator)))
(defun org-passwords-substitute (string-to-change list-of-substitutions)
"Substitutes each appearance in STRING-TO-CHANGE of the `car' of
each element of LIST-OF-SUBSTITUTIONS by the `cdr' of that
element. For example:
(org-passwords-substitute \"ab\" \'((\"a\" . \"b\") (\"b\" . \"c\")))
=> \"bc\"
Substitutions are made in order of the list, so for example:
(org-passwords-substitute \"ab\" \'((\"ab\" . \"c\") (\"b\" . \"d\")))
=> \"c\""
(if list-of-substitutions
(concat (org-passwords-concat-this-with-string
(cdar list-of-substitutions)
(mapcar (lambda (x)
(org-passwords-substitute
x
(cdr list-of-substitutions)))
(split-string string-to-change
(caar list-of-substitutions)))))
string-to-change))
(defun org-passwords-concat-this-with-string (this list-of-strings)
"Put the string THIS in between every string in LIST-OF-STRINGS. For example:
(org-passwords-concat-this-with-string \"Here\" \'(\"First\" \"Second\" \"Third\"))
=> \"FirstHereSencondHereThird\""
(if (cdr list-of-strings)
(concat (car list-of-strings)
this
(org-passwords-concat-this-with-string
this
(cdr list-of-strings)))
(car list-of-strings)))
(provide 'org-passwords)
;;; org-passwords.el ends here

View File

@@ -4,7 +4,7 @@
;;
;; Author: Max Mikhanosha <max@openchat.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 8.0
;;
;; Released under the GNU General Public License version 3
@@ -182,7 +182,7 @@ times. Returns just the file, without directory part"
(case-fold-search nil))
(while (and (< tries org-screenshot-max-tries)
(not name))
(incf tries)
(cl-incf tries)
(let ((tmp org-screenshot-file-name-format)
(seq-re "%[-0-9.]*d")
(rand-re "%X+"))
@@ -282,7 +282,7 @@ screenshot is done, any more `C-u' after that increases delay by
((integerp delay) delay)
((and (consp delay)
(integerp (car delay))
(plusp (car delay)))
(cl-plusp (car delay)))
(let ((num 1)
(limit (car delay))
(cnt 0))
@@ -307,11 +307,11 @@ screenshot is done, any more `C-u' after that increases delay by
(apply 'start-process
(append
(list "scrot" "*scrot*" "scrot" "-s" path)
(when (plusp delay)
(when (cl-plusp delay)
(list "-d" (format "%d" delay)))))
(error "Unable to start scrot process")))
(when org-screenshot-process
(if (plusp delay)
(if (cl-plusp delay)
(message "Click on a window, or select a rectangle (delay is %d sec)..."
delay)
(message "Click on a window, or select a rectangle..."))
@@ -351,7 +351,7 @@ by most recent first"
(> mtime1 mtime2)))))))
(let ((n -1) (list org-screenshot-file-list))
(while (and list (not (equal (pop list) lastfile)))
(incf n))
(cl-incf n))
(setq org-screenshot-rotation-index n)))
(defun org-screenshot-do-rotate (dir from-continue-rotating)
@@ -396,7 +396,7 @@ other direction"
;; advance one more time
(when (equal oldfile newfile)
(setq org-screenshot-rotation-index
(mod (+ org-screenshot-rotation-index (if (plusp dir) 1 -1))
(mod (+ org-screenshot-rotation-index (if (cl-plusp dir) 1 -1))
(length org-screenshot-file-list))
newfile (nth org-screenshot-rotation-index
org-screenshot-file-list)))

View File

@@ -4,7 +4,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp, games
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 0.01
;;
;; This file is not part of GNU Emacs.

View File

@@ -1,823 +0,0 @@
;;; org-velocity.el --- something like Notational Velocity for Org. -*- lexical-binding: t -*-
;; Copyright (C) 2010-2014, 2021 Paul M. Rodriguez
;; Author: Paul M. Rodriguez <paulmrodriguez@gmail.com>
;; Maintainer: Paul M. Rodriguez <paulmrodriguez@gmail.com>
;; Homepage: https://github.com/ruricolist/org-velocity
;; Created: 2010-05-05
;; Version: 4.1
;; 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 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Org-Velocity.el is an interface for Org inspired by the minimalist
;; notetaking program Notational Velocity. The idea is to let you
;; amass and access brief notes on many subjects with minimal fuss.
;; Each note is an entry in an ordinary Org file.
;; Org-Velocity can be used in two ways: when called outside Org, to
;; store and access notes in a designated bucket file; or, when called
;; inside Org, as a method for navigating any Org file. (Setting the
;; option `org-velocity-always-use-bucket' disables navigation inside
;; Org files by default, although you can still force this behavior by
;; calling `org-velocity-read' with an argument.)
;; Org-Velocity prompts for search terms in the minibuffer. A list of
;; headings of entries whose text matches your search is updated as
;; you type; you can end the search and visit an entry at any time by
;; clicking on its heading.
;; RET displays the results. If there are no matches, Org-Velocity
;; offers to create a new entry with your search string as its
;; heading. If there are matches, it displays a list of results where
;; the heading of each matching entry is hinted with a number or
;; letter; clicking a result, or typing the matching hint, opens the
;; entry for editing in an indirect buffer. 0 forces a new entry; RET
;; reopens the search for editing.
;; You can customize every step in this process, including the search
;; method, completion for search terms, and templates for creating new
;; entries; M-x customize-group RET org-velocity RET to see all the
;; options.
;; Thanks to Richard Riley, Carsten Dominik, Bastien Guerry, and Jeff
;; Horn for their suggestions.
;;; Usage:
;; (require 'org-velocity)
;; (setq org-velocity-bucket (expand-file-name "bucket.org" org-directory))
;; (global-set-key (kbd "C-c v") 'org-velocity)
;;; Code:
(require 'org)
(require 'button)
(require 'electric)
(require 'dabbrev)
(require 'cl-lib)
(defgroup org-velocity nil
"Notational Velocity-style interface for Org."
:tag "Org-Velocity"
:group 'outlines
:group 'hypermedia
:group 'org)
(defcustom org-velocity-bucket ""
"Where is the bucket file?"
:group 'org-velocity
:type 'file)
(defcustom org-velocity-show-previews t
"Show previews of the text of each heading?"
:group 'velocity
:type 'boolean
:safe 'booleanp)
(defcustom org-velocity-exit-on-match nil
"When searching incrementally, exit on a single match?"
:group 'org-velocity
:type 'boolean
:safe 'booleanp)
(defcustom org-velocity-force-new nil
"Should exiting the minibuffer with C-j force a new entry?"
:group 'org-velocity
:type 'boolean
:safe 'booleanp)
(defcustom org-velocity-use-search-ring t
"Push search to `search-ring' when visiting an entry?
This means that C-s C-s will take you directly to the first
instance of the search string."
:group 'org-velocity
:type 'boolean
:safe 'booleanp)
(defcustom org-velocity-always-use-bucket nil
"Use bucket file even when called from an Org buffer?"
:group 'org-velocity
:type 'boolean
:safe 'booleanp)
(defcustom org-velocity-use-completion nil
"Use completion?
Notwithstanding the value of this option, calling
`dabbrev-expand' always completes against the text of the bucket
file."
:group 'org-velocity
:type '(choice
(const :tag "Do not use completion" nil)
(const :tag "Use completion" t))
:safe 'booleanp)
(defcustom org-velocity-search-method 'phrase
"Match on whole phrase, any word, or all words?"
:group 'org-velocity
:type '(choice
(const :tag "Match whole phrase" phrase)
(const :tag "Match any word" any)
(const :tag "Match all words" all)
(const :tag "Match a regular expression" regexp))
:safe (lambda (v) (memq v '(phrase any all regexp))))
(defcustom org-velocity-capture-templates
'(("v"
"Velocity entry"
entry
(file "")
"* %:search\n\n%i%?"))
"Use these template with `org-capture'.
Meanwhile `org-default-notes-file' is bound to `org-velocity-bucket-file'.
The keyword :search inserts the current search.
See the documentation for `org-capture-templates'."
:group 'org-velocity
:type (or (get 'org-capture-templates 'custom-type) 'list))
(defcustom org-velocity-heading-level 1
"Only match headings at this level or higher.
0 means to match headings at any level."
:group 'org-velocity
:type 'integer
:safe (lambda (x)
(and (integerp x)
(>= x 0))))
(defvar crm-separator) ;Ensure dynamic binding.
(defsubst org-velocity-grab-preview ()
"Grab preview of a subtree.
The length of the preview is determined by `window-width'.
Replace all contiguous whitespace with single spaces."
(let* ((start (progn
(forward-line 1)
(if (looking-at org-property-start-re)
(re-search-forward org-property-end-re)
(1- (point)))))
(string+props (buffer-substring
start
(min
(+ start (window-width))
(point-max)))))
;; We want to preserve the text properties so that, for example,
;; we don't end up with the raw text of links in the preview.
(with-temp-buffer
(insert string+props)
(goto-char (point-min))
(save-match-data
(while (re-search-forward split-string-default-separators
(point-max)
t)
(replace-match " ")))
(buffer-string))))
(cl-defstruct org-velocity-heading buffer position name level preview)
(defsubst org-velocity-nearest-heading (position)
"Return last heading at POSITION.
If there is no last heading, return nil."
(save-excursion
(goto-char position)
(re-search-backward (org-velocity-heading-regexp))
(let ((components (org-heading-components)))
(make-org-velocity-heading
:buffer (current-buffer)
:position (point)
:name (nth 4 components)
:level (nth 0 components)
:preview (if org-velocity-show-previews
(org-velocity-grab-preview))))))
(defconst org-velocity-index
(eval-when-compile
(nconc (number-sequence 49 57) ;numbers
(number-sequence 97 122) ;lowercase letters
(number-sequence 65 90))) ;uppercase letters
"List of chars for indexing results.")
(defconst org-velocity-match-buffer-name "*Velocity matches*")
(cl-defun org-velocity-heading-regexp (&optional (level org-velocity-heading-level))
"Regexp to match headings at LEVEL or deeper."
(if (zerop level)
"^\\*+ "
(format "^\\*\\{1,%d\\} " level)))
(defvar org-velocity-search nil
"Variable to bind to current search.")
(defun org-velocity-buffer-file-name (&optional buffer)
"Return the name of the file BUFFER saves to.
Same as function `buffer-file-name' unless BUFFER is an indirect
buffer or a minibuffer. In the former case, return the file name
of the base buffer; in the latter, return the file name of
`minibuffer-selected-window' (or its base buffer)."
(let ((buffer (if (minibufferp buffer)
(window-buffer (minibuffer-selected-window))
buffer)))
(buffer-file-name
(or (buffer-base-buffer buffer)
buffer))))
(defun org-velocity-minibuffer-contents ()
"Return the contents of the minibuffer when it is active."
(when (active-minibuffer-window)
(with-current-buffer (window-buffer (active-minibuffer-window))
(minibuffer-contents))))
(defun org-velocity-nix-minibuffer ()
"Return the contents of the minibuffer and clear it."
(when (active-minibuffer-window)
(with-current-buffer (window-buffer (active-minibuffer-window))
(prog1 (minibuffer-contents)
(delete-minibuffer-contents)))))
(defun org-velocity-bucket-file ()
"Return the proper file for Org-Velocity to search.
If `org-velocity-always-use-bucket' is t, use bucket file;
complain if missing. Otherwise, if an Org file is current, then
use it."
(let ((org-velocity-bucket
(when org-velocity-bucket (expand-file-name org-velocity-bucket)))
(buffer
(let ((buffer-file (org-velocity-buffer-file-name)))
(when buffer-file
;; Use the target in capture buffers.
(org-find-base-buffer-visiting buffer-file)))))
(if org-velocity-always-use-bucket
(or org-velocity-bucket (error "Bucket required but not defined"))
(if (and (eq (buffer-local-value 'major-mode (or buffer (current-buffer)))
'org-mode)
(org-velocity-buffer-file-name))
(org-velocity-buffer-file-name)
(or org-velocity-bucket
(error "No bucket and not an Org file"))))))
(defvar org-velocity-bucket-buffer nil)
(defvar org-velocity-navigating nil)
(defsubst org-velocity-bucket-buffer ()
(or org-velocity-bucket-buffer
(find-file-noselect (org-velocity-bucket-file))))
(defsubst org-velocity-match-buffer ()
"Return the proper buffer for Org-Velocity to display in."
(get-buffer-create org-velocity-match-buffer-name))
(defsubst org-velocity-match-window ()
(get-buffer-window (org-velocity-match-buffer)))
(defun org-velocity-beginning-of-headings ()
"Goto the start of the first heading."
(goto-char (point-min))
;; If we are before the first heading we could still be at the
;; first heading.
(or (looking-at (org-velocity-heading-regexp))
(re-search-forward (org-velocity-heading-regexp))))
(defun org-velocity-make-indirect-buffer (heading)
"Make or switch to an indirect buffer visiting HEADING."
(let* ((bucket (org-velocity-heading-buffer heading))
(name (org-velocity-heading-name heading))
(existing (get-buffer name)))
(if (and existing (buffer-base-buffer existing)
(equal (buffer-base-buffer existing) bucket))
existing
(make-indirect-buffer
bucket
(generate-new-buffer-name (org-velocity-heading-name heading))
t))))
(defun org-velocity-capture ()
"Record a note with `org-capture'."
(let ((org-capture-templates
org-velocity-capture-templates))
(org-capture nil
;; This is no longer automatically selected.
(when (null (cdr org-capture-templates))
(caar org-capture-templates)))
(when org-capture-mode
(rename-buffer org-velocity-search t))))
(defvar org-velocity-saved-winconf nil)
(make-variable-buffer-local 'org-velocity-saved-winconf)
(defun org-velocity-edit-entry (heading)
(if org-velocity-navigating
(org-velocity-edit-entry/inline heading)
(org-velocity-edit-entry/indirect heading)))
(cl-defun org-velocity-goto-entry (heading &key narrow)
(goto-char (org-velocity-heading-position heading))
(save-excursion
(when narrow
(org-narrow-to-subtree))
(outline-show-all)))
(defun org-velocity-edit-entry/inline (heading)
"Edit entry at HEADING in the original buffer."
(let ((buffer (org-velocity-heading-buffer heading)))
(pop-to-buffer buffer)
(with-current-buffer buffer
(org-velocity-goto-entry heading))))
(defun org-velocity-format-header-line (control-string &rest args)
(set (make-local-variable 'header-line-format)
(apply #'format control-string args)))
(defun org-velocity-edit-entry/indirect (heading)
"Edit entry at HEADING in an indirect buffer."
(let ((winconf (current-window-configuration))
(dd default-directory)
(buffer (org-velocity-make-indirect-buffer heading))
(inhibit-point-motion-hooks t)
(inhibit-field-text-motion t))
(with-current-buffer buffer
(setq default-directory dd) ;Inherit default directory.
(setq org-velocity-saved-winconf winconf)
(org-velocity-goto-entry heading :narrow t)
(goto-char (point-max))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-velocity-dismiss nil t))
(pop-to-buffer buffer)
(org-velocity-format-header-line
"%s Use C-c C-c to finish."
(abbreviate-file-name
(buffer-file-name
(org-velocity-heading-buffer heading))))))
(defun org-velocity-dismiss ()
"Save current entry and close indirect buffer."
(let ((winconf org-velocity-saved-winconf))
(prog1 t ;Tell hook we're done.
(save-buffer)
(kill-buffer)
(when (window-configuration-p winconf)
(set-window-configuration winconf)))))
(defun org-velocity-visit-button (button)
(run-hooks 'mouse-leave-buffer-hook)
(when org-velocity-use-search-ring
(add-to-history 'search-ring
(button-get button 'search)
search-ring-max))
(let ((match (button-get button 'match)))
(throw 'org-velocity-done match)))
(define-button-type 'org-velocity-button
'action #'org-velocity-visit-button
'follow-link 'mouse-face)
(defsubst org-velocity-buttonize (heading)
"Insert HEADING as a text button with no hints."
(insert-text-button
(propertize (org-velocity-heading-name heading) 'face 'link)
:type 'org-velocity-button
'match heading
'search org-velocity-search))
(defsubst org-velocity-insert-preview (heading)
(when org-velocity-show-previews
(insert-char ?\ 1)
(insert
(propertize
(org-velocity-heading-preview heading)
'face 'shadow))))
(defvar org-velocity-recursive-headings nil)
(defvar org-velocity-recursive-search nil)
(cl-defun org-velocity-search-with (fun style search
&key (headings org-velocity-recursive-headings))
(if headings
(save-restriction
(dolist (heading headings)
(widen)
(let ((start (org-velocity-heading-position heading)))
(goto-char start)
(let ((end (save-excursion
(org-end-of-subtree)
(point))))
(narrow-to-region start end)
(org-velocity-search-with fun style search
:headings nil)))))
(cl-ecase style
((phrase any regexp)
(cl-block nil
(while (re-search-forward search nil t)
(let ((match (org-velocity-nearest-heading (point))))
(funcall fun match))
;; Skip to the next heading.
(unless (re-search-forward (org-velocity-heading-regexp) nil t)
(cl-return)))))
((all)
(let ((keywords
(cl-loop for word in (split-string search)
collect (concat "\\<" (regexp-quote word) "\\>"))))
(org-map-entries
(lambda ()
;; Only search the subtree once.
(setq org-map-continue-from
(save-excursion
(org-end-of-subtree)
(point)))
(when (cl-loop for word in keywords
always (save-excursion
(re-search-forward word org-map-continue-from t)))
(let ((match (org-velocity-nearest-heading (match-end 0))))
(funcall fun match))))))))))
(defun org-velocity-all-results (style search)
(with-current-buffer (org-velocity-bucket-buffer)
(save-excursion
(goto-char (point-min))
(let (matches)
(org-velocity-search-with (lambda (match)
(push match matches))
style
search)
(nreverse matches)))))
(defsubst org-velocity-present-match (hint match)
(with-current-buffer (org-velocity-match-buffer)
(when hint (insert "#" hint " "))
(org-velocity-buttonize match)
(org-velocity-insert-preview match)
(newline)))
(defun org-velocity-present-search (style search hide-hints)
(let ((hints org-velocity-index) matches)
(cl-block nil
(org-velocity-search-with (lambda (match)
(unless hints
(cl-return))
(let ((hint (if hide-hints
nil
(car hints))))
(org-velocity-present-match hint match))
(pop hints)
(push match matches))
style
search))
(nreverse matches)))
(defun org-velocity-restrict-search ()
(interactive)
(let ((search (org-velocity-nix-minibuffer)))
(when (equal search "")
(error "No search to restrict to"))
(push search org-velocity-recursive-search)
(setq org-velocity-recursive-headings
(org-velocity-all-results
org-velocity-search-method
search))
;; TODO We could extend the current search instead of starting
;; over.
(org-velocity-update-match-header)
(minibuffer-message "Restricting search to %s" search)))
(cl-defun org-velocity-update-match-header (&key (match-buffer (org-velocity-match-buffer))
(bucket-buffer (org-velocity-bucket-buffer))
(search-method org-velocity-search-method))
(let ((navigating? org-velocity-navigating)
(recursive? org-velocity-recursive-search))
(with-current-buffer match-buffer
(org-velocity-format-header-line
"%s search in %s%s (%s mode)"
(capitalize (symbol-name search-method))
(abbreviate-file-name (buffer-file-name bucket-buffer))
(if (not recursive?)
""
(let ((sep " > "))
(concat sep (string-join (reverse recursive?) sep))))
(if navigating? "nav" "notes")))))
(cl-defun org-velocity-present (search &key hide-hints)
"Buttonize matches for SEARCH in `org-velocity-match-buffer'.
If HIDE-HINTS is non-nil, display entries without indices. SEARCH
binds `org-velocity-search'.
Return matches."
(let ((match-buffer (org-velocity-match-buffer))
(bucket-buffer (org-velocity-bucket-buffer))
(search-method org-velocity-search-method))
(if (and (stringp search) (not (string= "" search)))
;; Fold case when the search string is all lowercase.
(let ((case-fold-search (equal search (downcase search)))
(truncate-partial-width-windows t))
(with-current-buffer match-buffer
(erase-buffer)
;; Permanent locals.
(setq cursor-type nil
truncate-lines t)
(org-velocity-update-match-header
:match-buffer match-buffer
:bucket-buffer bucket-buffer
:search-method search-method))
(prog1
(with-current-buffer bucket-buffer
(widen)
(let* ((inhibit-point-motion-hooks t)
(inhibit-field-text-motion t)
(anchored? (string-match-p "^\\s-" search))
(search
(cl-ecase search-method
(all search)
(phrase
(if anchored?
(regexp-quote search)
;; Anchor the search to the start of a word.
(concat "\\<" (regexp-quote search))))
(any
(concat "\\<" (regexp-opt (split-string search))))
(regexp search))))
(save-excursion
(org-velocity-beginning-of-headings)
(condition-case lossage
(org-velocity-present-search search-method search hide-hints)
(invalid-regexp
(minibuffer-message "%s" lossage))))))
(with-current-buffer match-buffer
(goto-char (point-min)))))
(with-current-buffer match-buffer
(erase-buffer)))))
(defun org-velocity-store-link ()
"Function for `org-store-link-functions'."
(if org-velocity-search
(org-store-link-props
:search org-velocity-search)))
(add-hook 'org-store-link-functions 'org-velocity-store-link)
(cl-defun org-velocity-create (search &key ask)
"Create new heading named SEARCH.
If ASK is non-nil, ask first."
(when (or (null ask) (y-or-n-p "No match found, create? "))
(let ((org-velocity-search search)
(org-default-notes-file (org-velocity-bucket-file))
;; save a stored link
org-store-link-plist)
(org-velocity-capture))
search))
(defun org-velocity-engine (search)
"Display a list of headings where SEARCH occurs."
(let ((org-velocity-search search))
(unless (or
(not (stringp search))
(string= "" search)) ;exit on empty string
(cl-case
(if (and org-velocity-force-new (eq last-command-event ?\C-j))
:force
(let* ((org-velocity-index (org-velocity-adjust-index))
(matches (org-velocity-present search)))
(cond ((null matches) :new)
((null (cdr matches)) :follow)
(t :prompt))))
(:prompt (progn
(pop-to-buffer (org-velocity-match-buffer))
(let ((hint (org-velocity-electric-read-hint)))
(when hint (cl-case hint
(:edit (org-velocity-read nil search))
(:force (org-velocity-create search))
(otherwise (org-velocity-activate-button hint)))))))
(:new (unless (org-velocity-create search :ask t)
(org-velocity-read nil search)))
(:force (org-velocity-create search))
(:follow (if (y-or-n-p "One match, follow? ")
(progn
(set-buffer (org-velocity-match-buffer))
(goto-char (point-min))
(button-activate (next-button (point))))
(org-velocity-read nil search)))))))
(defun org-velocity-activate-button (char)
"Go to button on line number associated with CHAR in `org-velocity-index'."
(goto-char (point-min))
(forward-line (cl-position char org-velocity-index))
(goto-char
(button-start
(next-button (point))))
(message "%s" (button-label (button-at (point))))
(button-activate (button-at (point))))
(defun org-velocity-electric-undefined ()
"Complain about an undefined key."
(interactive)
(message "%s"
(substitute-command-keys
"\\[org-velocity-electric-new] for new entry,
\\[org-velocity-electric-edit] to edit search,
\\[scroll-up] to scroll up,
\\[scroll-down] to scroll down,
\\[keyboard-quit] to quit."))
(sit-for 4))
(defun org-velocity-electric-follow (ev)
"Follow a hint indexed by keyboard event EV."
(interactive (list last-command-event))
(if (not (> (cl-position ev org-velocity-index)
(1- (count-lines (point-min) (point-max)))))
(throw 'org-velocity-select ev)
(call-interactively 'org-velocity-electric-undefined)))
(defun org-velocity-electric-edit ()
"Edit the search string."
(interactive)
(throw 'org-velocity-select :edit))
(defun org-velocity-electric-new ()
"Force a new entry."
(interactive)
(throw 'org-velocity-select :force))
(defvar org-velocity-electric-map
(let ((map (make-sparse-keymap)))
(define-key map [t] 'org-velocity-electric-undefined)
(dolist (c org-velocity-index)
(define-key map (char-to-string c)
'org-velocity-electric-follow))
(define-key map "0" 'org-velocity-electric-new)
(define-key map "\C-v" 'scroll-up)
(define-key map "\M-v" 'scroll-down)
(define-key map (kbd "RET") 'org-velocity-electric-edit)
(define-key map [mouse-1] nil)
(define-key map [mouse-2] nil)
(define-key map [escape] 'keyboard-quit)
(define-key map "\C-h" 'help-command)
map))
(defun org-velocity-electric-read-hint ()
"Read index of button electrically."
(with-current-buffer (org-velocity-match-buffer)
(when (featurep 'evil)
;; NB Idempotent.
(evil-make-overriding-map org-velocity-electric-map))
(use-local-map org-velocity-electric-map)
(catch 'org-velocity-select
(Electric-command-loop 'org-velocity-select "Follow: "))))
(defvar org-velocity-incremental-keymap
(let ((map (make-sparse-keymap)))
(define-key map "\C-v" 'scroll-up)
(define-key map "\M-v" 'scroll-down)
map))
(defun org-velocity-displaying-completions-p ()
"Is there a *Completions* buffer showing?"
(get-window-with-predicate
(lambda (w)
(eq (buffer-local-value 'major-mode (window-buffer w))
'completion-list-mode))))
(defun org-velocity-update ()
"Display results of search without hinting."
(unless (org-velocity-displaying-completions-p)
(let* ((search (org-velocity-minibuffer-contents))
(matches (org-velocity-present search :hide-hints t)))
(cond ((null matches)
(select-window (active-minibuffer-window))
(unless (or (null search) (= (length search) 0))
(minibuffer-message "No match; RET to create")))
((and (null (cdr matches))
org-velocity-exit-on-match)
(throw 'click search))
(t
(with-current-buffer (org-velocity-match-buffer)
(use-local-map org-velocity-incremental-keymap)))))))
(defvar dabbrev--last-abbreviation)
(defun org-velocity-dabbrev-completion-list (abbrev)
"Return all dabbrev completions for ABBREV."
;; This is based on `dabbrev-completion'.
(dabbrev--reset-global-variables)
(setq dabbrev--last-abbreviation abbrev)
(dabbrev--find-all-expansions abbrev case-fold-search))
(defvar org-velocity-local-completion-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-completion-map)
(define-key map " " 'self-insert-command)
(define-key map "?" 'self-insert-command)
(define-key map [remap minibuffer-complete] 'minibuffer-complete-word)
(define-key map [(control ?@)] 'org-velocity-restrict-search)
(define-key map [(control ?\s)] 'org-velocity-restrict-search)
map)
"Keymap for completion with `completing-read'.")
(defun org-velocity-read-with-completion (prompt)
"Completing read with PROMPT."
(let ((minibuffer-local-completion-map
org-velocity-local-completion-map)
(completion-no-auto-exit t)
(crm-separator " "))
(completing-read prompt
(completion-table-dynamic
'org-velocity-dabbrev-completion-list))))
(cl-defun org-velocity-adjust-index
(&optional (match-window (org-velocity-match-window)))
"Truncate or extend `org-velocity-index' to the lines in
MATCH-WINDOW."
(with-selected-window match-window
(let ((lines (window-height))
(hints (length org-velocity-index)))
(cond ((= lines hints)
org-velocity-index)
;; Truncate the index to the size of
;; the buffer to be displayed.
((< lines hints)
(cl-subseq org-velocity-index 0 lines))
;; If the window is so tall we run out of indices, at
;; least make the additional results clickable.
((> lines hints)
(append org-velocity-index
(make-list (- lines hints) nil)))))))
(defun org-velocity-incremental-read (prompt)
"Read string with PROMPT and display results incrementally.
Stop searching once there are more matches than can be
displayed."
(let ((res
(unwind-protect
(let* ((match-window (display-buffer (org-velocity-match-buffer)))
(org-velocity-index (org-velocity-adjust-index match-window)))
(catch 'click
(add-hook 'post-command-hook 'org-velocity-update)
(cond ((eq org-velocity-search-method 'regexp)
(read-regexp prompt))
(org-velocity-use-completion
(org-velocity-read-with-completion prompt))
(t (read-string prompt)))))
(remove-hook 'post-command-hook 'org-velocity-update))))
(if (bufferp res) (org-pop-to-buffer-same-window res) res)))
(defun org-velocity (arg &optional search)
"Read a search string SEARCH for Org-Velocity interface.
This means that a buffer will display all headings where SEARCH
occurs, where one can be selected by a mouse click or by typing
its index. If SEARCH does not occur, then a new heading may be
created named SEARCH.
If `org-velocity-bucket' is defined and
`org-velocity-always-use-bucket' is non-nil, then the bucket file
will be used; otherwise, this will work when called in any Org
file.
Calling with ARG reverses which file the current file or the
bucket file to use. If the bucket file would have been used,
then the current file is used instead, and vice versa."
(interactive "P")
(let ((org-velocity-always-use-bucket
(if org-velocity-always-use-bucket
(not arg)
arg)))
;; complain if inappropriate
(cl-assert (org-velocity-bucket-file))
(let* ((starting-buffer (current-buffer))
(org-velocity-bucket-buffer
(find-file-noselect (org-velocity-bucket-file)))
(org-velocity-navigating
(eq starting-buffer org-velocity-bucket-buffer))
(org-velocity-recursive-headings '())
(org-velocity-recursive-search '())
(org-velocity-heading-level
(if org-velocity-navigating
0
org-velocity-heading-level))
(dabbrev-search-these-buffers-only
(list org-velocity-bucket-buffer)))
(unwind-protect
(let ((match
(catch 'org-velocity-done
(org-velocity-engine
(or search
(org-velocity-incremental-read "Velocity search: ")))
nil)))
(when (org-velocity-heading-p match)
(org-velocity-edit-entry match)))
(kill-buffer (org-velocity-match-buffer))))))
(defalias 'org-velocity-read 'org-velocity)
(provide 'org-velocity)
;;; org-velocity.el ends here

View File

@@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Homepage: https://git.sr.ht/~bzg/org-contrib
;; Version: 7.01trans
;;
;; This file is not part of GNU Emacs.

View File

@@ -647,16 +647,16 @@ See `org-groff-text-markup-alist' for details."
;; If FROM then get data from FROM
(if from-data
(if from-data
(setq from-data
(replace-regexp-in-string "\\.P\n" "" from-data))
(setq from-data ""))
(if to-data
(if to-data
(setq to-data
(replace-regexp-in-string "\\.P\n" "" to-data))
(setq from-data ""))
(concat
(cond
(from-data
@@ -1879,6 +1879,12 @@ Return PDF file's name."
async subtreep visible-only body-only ext-plist
(lambda (file) (org-groff-compile file)))))
;; Port to Emacs 26 and earlier.
(defun org-groff--time-sec (time)
(if (fboundp 'time-convert)
(time-convert time 'integer)
(cl-subseq (or time (current-time)) 0 2)))
(defun org-groff-compile (file)
"Compile a Groff file.
@@ -1888,8 +1894,8 @@ through the command specified in `org-groff-pdf-process'.
Return PDF file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
(full-name (file-truename file))
(out-dir (file-name-directory file))
(time (current-time))
(out-dir (file-name-directory full-name))
(time (org-groff--time-sec nil))
;; Properly set working directory for compilation.
(default-directory (if (file-name-absolute-p file)
(file-name-directory full-name)
@@ -1928,8 +1934,9 @@ Return PDF file name or an error if it couldn't be produced."
;; Only compare times up to whole seconds as some
;; filesystems (e.g. HFS+) do not retain any finer
;; granularity.
(time-less-p (cl-subseq (nth 5 (file-attributes pdffile)) 0 2)
(cl-subseq time 0 2)))
(time-less-p (org-groff--time-sec
(nth 5 (file-attributes pdffile)))
time))
(error (concat (format "PDF file %s wasn't produced" pdffile)
(when errors (concat ": " errors))))
;; Else remove log files, when specified, and signal end of

View File

@@ -1,421 +0,0 @@
;;; ox-rss.el --- RSS 2.0 Back-End for Org Export Engine
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;; Author: Bastien Guerry <bzg@gnu.org>
;; Maintainer: Bastien Guerry <bzg@gnu.org>
;; Keywords: org, wp, blog, feed, rss
;; Homepage: https://gitlab.com/nsavage/ox-rss
;; 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 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This library implements an RSS 2.0 back-end for Org exporter, based
;; on the `html' back-end.
;;
;; It requires Emacs 24.1 at least.
;;
;; It provides two commands for export, depending on the desired output:
;; `org-rss-export-as-rss' (temporary buffer) and `org-rss-export-to-rss'
;; (as a ".xml" file).
;;
;; This backend understands three new option keywords:
;;
;; #+RSS_EXTENSION: xml
;; #+RSS_IMAGE_URL: https://myblog.org/mypicture.jpg
;; #+RSS_FEED_URL: https://myblog.org/feeds/blog.xml
;;
;; It uses #+HTML_LINK_HOME: to set the base url of the feed.
;;
;; Exporting an Org file to RSS modifies each top-level entry by adding a
;; PUBDATE property. If `org-rss-use-entry-url-as-guid', it will also add
;; an ID property, later used as the guid for the feed's item.
;;
;; The top-level headline is used as the title of each RSS item unless
;; an RSS_TITLE property is set on the headline.
;;
;; You typically want to use it within a publishing project like this:
;;
;; (add-to-list
;; 'org-publish-project-alist
;; '("homepage_rss"
;; :base-directory "~/myhomepage/"
;; :base-extension "org"
;; :rss-image-url "http://lumiere.ens.fr/~guerry/images/faces/15.png"
;; :html-link-home "http://lumiere.ens.fr/~guerry/"
;; :html-link-use-abs-url t
;; :rss-extension "xml"
;; :publishing-directory "/home/guerry/public_html/"
;; :publishing-function (org-rss-publish-to-rss)
;; :section-numbers nil
;; :exclude ".*" ;; To exclude all files...
;; :include ("index.org") ;; ... except index.org.
;; :table-of-contents nil))
;;
;; ... then rsync /home/guerry/public_html/ with your server.
;;
;; By default, the permalink for a blog entry points to the headline.
;; You can specify a different one by using the :RSS_PERMALINK:
;; property within an entry.
;;; Code:
(require 'ox-html)
(declare-function url-encode-url "url-util" (url))
;;; Variables and options
(defgroup org-export-rss nil
"Options specific to RSS export back-end."
:tag "Org RSS"
:group 'org-export
:version "24.4"
:package-version '(Org . "8.0"))
(defcustom org-rss-image-url "https://orgmode.org/img/org-mode-unicorn-logo.png"
"The URL of the image for the RSS feed."
:group 'org-export-rss
:type 'string)
(defcustom org-rss-extension "xml"
"File extension for the RSS 2.0 feed."
:group 'org-export-rss
:type 'string)
(defcustom org-rss-categories 'from-tags
"Where to extract items category information from.
The default is to extract categories from the tags of the
headlines. When set to another value, extract the category
from the :CATEGORY: property of the entry."
:group 'org-export-rss
:type '(choice
(const :tag "From tags" from-tags)
(const :tag "From the category property" from-category)))
(defcustom org-rss-use-entry-url-as-guid t
"Use the URL for the <guid> metatag?
When nil, Org will create ids using `org-icalendar-create-uid'."
:group 'org-export-rss
:type 'boolean)
;;; Define backend
(org-export-define-derived-backend 'rss 'html
:menu-entry
'(?r "Export to RSS"
((?R "As RSS buffer"
(lambda (a s v b) (org-rss-export-as-rss a s v)))
(?r "As RSS file" (lambda (a s v b) (org-rss-export-to-rss a s v)))
(?o "As RSS file and open"
(lambda (a s v b)
(if a (org-rss-export-to-rss t s v)
(org-open-file (org-rss-export-to-rss nil s v)))))))
:options-alist
'((:description "DESCRIPTION" nil nil newline)
(:keywords "KEYWORDS" nil nil space)
(:with-toc nil nil nil) ;; Never include HTML's toc
(:rss-extension "RSS_EXTENSION" nil org-rss-extension)
(:rss-image-url "RSS_IMAGE_URL" nil org-rss-image-url)
(:rss-feed-url "RSS_FEED_URL" nil nil t)
(:rss-categories nil nil org-rss-categories))
:filters-alist '((:filter-final-output . org-rss-final-function))
:translate-alist '((headline . org-rss-headline)
(comment . (lambda (&rest args) ""))
(comment-block . (lambda (&rest args) ""))
(timestamp . (lambda (&rest args) ""))
(plain-text . org-rss-plain-text)
(section . org-rss-section)
(template . org-rss-template)))
;;; Export functions
;;;###autoload
(defun org-rss-export-as-rss (&optional async subtreep visible-only)
"Export current buffer to an RSS buffer.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
A non-nil optional argument ASYNC means the process should happen
asynchronously. The resulting buffer should be accessible
through the `org-export-stack' interface.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
Export is done in a buffer named \"*Org RSS Export*\", which will
be displayed when `org-export-show-temporary-export-buffer' is
non-nil."
(interactive)
(let ((file (buffer-file-name (buffer-base-buffer))))
(org-icalendar-create-uid file 'warn-user)
(org-rss-add-pubdate-property))
(org-export-to-buffer 'rss "*Org RSS Export*"
async subtreep visible-only nil nil (lambda () (text-mode))))
;;;###autoload
(defun org-rss-export-to-rss (&optional async subtreep visible-only)
"Export current buffer to an RSS file.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
A non-nil optional argument ASYNC means the process should happen
asynchronously. The resulting file should be accessible through
the `org-export-stack' interface.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
Return output file's name."
(interactive)
(let ((file (buffer-file-name (buffer-base-buffer))))
(org-icalendar-create-uid file 'warn-user)
(org-rss-add-pubdate-property))
(let ((outfile (org-export-output-file-name
(concat "." org-rss-extension) subtreep)))
(org-export-to-file 'rss outfile async subtreep visible-only)))
;;;###autoload
(defun org-rss-publish-to-rss (plist filename pub-dir)
"Publish an org file to RSS.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(let ((bf (get-file-buffer filename)))
(if bf
(with-current-buffer bf
(org-icalendar-create-uid filename 'warn-user)
(org-rss-add-pubdate-property)
(write-file filename))
(find-file filename)
(org-icalendar-create-uid filename 'warn-user)
(org-rss-add-pubdate-property)
(write-file filename) (kill-buffer)))
(org-publish-org-to
'rss filename (concat "." org-rss-extension) plist pub-dir))
;;; Main transcoding functions
(defun org-rss-headline (headline contents info)
"Transcode HEADLINE element into RSS format.
CONTENTS is the headline contents. INFO is a plist used as a
communication channel."
(if (> (org-export-get-relative-level headline info) 1)
(org-export-data-with-backend headline 'html info)
(unless (org-element-property :footnote-section-p headline)
(let* ((email (org-export-data (plist-get info :email) info))
(author (and (plist-get info :with-author)
(let ((auth (plist-get info :author)))
(and auth (org-export-data auth info)))))
(htmlext (plist-get info :html-extension))
(hl-number (org-export-get-headline-number headline info))
(hl-home (file-name-as-directory (plist-get info :html-link-home)))
(hl-pdir (plist-get info :publishing-directory))
(hl-perm (org-element-property :RSS_PERMALINK headline))
(anchor (org-export-get-reference headline info))
(category (org-rss-plain-text
(or (org-element-property :CATEGORY headline) "") info))
(pubdate0 (org-element-property :PUBDATE headline))
(pubdate (let ((system-time-locale "C"))
(if (and pubdate0 (not (string-empty-p pubdate0)))
(format-time-string
"%a, %d %b %Y %H:%M:%S %z"
(org-time-string-to-time pubdate0)))))
(title (org-rss-plain-text
(or (org-element-property :RSS_TITLE headline)
(replace-regexp-in-string
org-bracket-link-regexp
(lambda (m) (or (match-string 3 m)
(match-string 1 m)))
(org-element-property :raw-value headline))) info))
(publink
(or (and hl-perm (concat (or hl-home hl-pdir) hl-perm))
(concat
(or hl-home hl-pdir)
(file-name-nondirectory
(file-name-sans-extension
(plist-get info :input-file))) "." htmlext "#" anchor)))
(guid (if org-rss-use-entry-url-as-guid
publink
(org-rss-plain-text
(or (org-element-property :ID headline)
(org-element-property :CUSTOM_ID headline)
publink)
info))))
(if (not pubdate) "" ;; Skip entries with no PUBDATE prop
(format
(concat
"<item>\n"
"<title>%s</title>\n"
"<link>%s</link>\n"
"<author>%s (%s)</author>\n"
"<guid isPermaLink=\"false\">%s</guid>\n"
"<pubDate>%s</pubDate>\n"
(org-rss-build-categories headline info) "\n"
"<description><![CDATA[%s]]></description>\n"
"</item>\n")
title publink email author guid pubdate contents))))))
(defun org-rss-build-categories (headline info)
"Build categories for the RSS item."
(if (eq (plist-get info :rss-categories) 'from-tags)
(mapconcat
(lambda (c) (format "<category><![CDATA[%s]]></category>" c))
(org-element-property :tags headline)
"\n")
(let ((c (org-element-property :CATEGORY headline)))
(format "<category><![CDATA[%s]]></category>" c))))
(defun org-rss-template (contents info)
"Return complete document string after RSS conversion.
CONTENTS is the transcoded contents string. INFO is a plist used
as a communication channel."
(concat
(format "<?xml version=\"1.0\" encoding=\"%s\"?>"
(symbol-name org-html-coding-system))
"\n<rss version=\"2.0\"
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
xmlns:atom=\"http://www.w3.org/2005/Atom\"
xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"
xmlns:georss=\"http://www.georss.org/georss\"
xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"
xmlns:media=\"http://search.yahoo.com/mrss/\">"
"<channel>"
(org-rss-build-channel-info info) "\n"
contents
"</channel>\n"
"</rss>"))
(defun org-rss-build-channel-info (info)
"Build the RSS channel information."
(let* ((system-time-locale "C")
(title (org-export-data (plist-get info :title) info))
(email (org-export-data (plist-get info :email) info))
(author (and (plist-get info :with-author)
(let ((auth (plist-get info :author)))
(and auth (org-export-data auth info)))))
(date (format-time-string "%a, %d %b %Y %H:%M:%S %z")) ;; RFC 882
(description (org-export-data (plist-get info :description) info))
(lang (plist-get info :language))
(keywords (plist-get info :keywords))
(rssext (plist-get info :rss-extension))
(blogurl (or (plist-get info :html-link-home)
(plist-get info :publishing-directory)))
(image (url-encode-url (plist-get info :rss-image-url)))
(ifile (plist-get info :input-file))
(publink
(or (plist-get info :rss-feed-url)
(concat (file-name-as-directory blogurl)
(file-name-nondirectory
(file-name-sans-extension ifile))
"." rssext))))
(format
"\n<title>%s</title>
<atom:link href=\"%s\" rel=\"self\" type=\"application/rss+xml\" />
<link>%s</link>
<description><![CDATA[%s]]></description>
<language>%s</language>
<pubDate>%s</pubDate>
<lastBuildDate>%s</lastBuildDate>
<generator>%s</generator>
<webMaster>%s (%s)</webMaster>
<image>
<url>%s</url>
<title>%s</title>
<link>%s</link>
</image>
"
title publink blogurl description lang date date
(concat (format "Emacs %d.%d"
emacs-major-version
emacs-minor-version)
" Org-mode " (org-version))
email author image title blogurl)))
(defun org-rss-section (section contents info)
"Transcode SECTION element into RSS format.
CONTENTS is the section contents. INFO is a plist used as
a communication channel."
contents)
(defun org-rss-timestamp (timestamp contents info)
"Transcode a TIMESTAMP object from Org to RSS.
CONTENTS is nil. INFO is a plist holding contextual
information."
(org-html-encode-plain-text
(org-timestamp-translate timestamp)))
(defun org-rss-plain-text (contents info)
"Convert plain text into RSS encoded text."
(let (output)
(setq output (org-html-encode-plain-text contents)
output (org-export-activate-smart-quotes
output :html info))))
;;; Filters
(defun org-rss-final-function (contents backend info)
"Prettify the RSS output."
(with-temp-buffer
(xml-mode)
(insert contents)
(indent-region (point-min) (point-max))
(buffer-substring-no-properties (point-min) (point-max))))
;;; Miscellaneous
(defun org-rss-add-pubdate-property ()
"Set the PUBDATE property for top-level headlines."
(let (msg)
(org-map-entries
(lambda ()
(let* ((entry (org-element-at-point))
(level (org-element-property :level entry)))
(when (= level 1)
(unless (org-entry-get (point) "PUBDATE")
(setq msg t)
(org-set-property
"PUBDATE" (format-time-string
(cdr org-time-stamp-formats)))))))
nil nil 'comment 'archive)
(when msg
(message "Property PUBDATE added to top-level entries in %s"
(buffer-file-name))
(sit-for 2))))
(provide 'ox-rss)
;;; ox-rss.el ends here

View File

@@ -608,8 +608,8 @@ doesn't include leading \"depends\"."
;; Compute number of exclamation marks by looking for the
;; common ancestor between TASK and DEP.
(while (not (org-element-map parent 'headline
(lambda (hl) (eq hl dep))))
(incf exclamations)
(lambda (hl) (eq hl dep))))
(cl-incf exclamations)
(setq parent (org-export-get-parent parent)))
;; Build path from DEP to PARENT.
(while (not (eq parent dep))