Repository: rnkn/binder
Branch: master
Commit: 5c668cba1dc7
Files: 8
Total size: 106.4 KB
Directory structure:
gitextract_gpx4e2f8/
├── .gitignore
├── LICENSE
├── Makefile
├── NEWS
├── README.md
├── binder-tutorial.el
├── binder.el
└── contrib/
└── binder-theme.el
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.elc
*-autoloads.el
*-pkg.el
.dir-locals.el
dir
tutorial/
================================================
FILE: LICENSE
================================================
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/licenses/why-not-lgpl.html>.
================================================
FILE: Makefile
================================================
.POSIX:
PROG = binder
LISP_FILE = ${PROG}.el
DEPS = seq package-lint
NEWS_FILE = NEWS
VERS = ${shell grep -oE -m1 'Version:[ 0-9.]+' ${LISP_FILE} | tr -d :}
TAG = ${shell echo ${VERS} | sed -E 's/Version:? ([0-9.]+)/v\1/'}
INIT = (progn \
(require (quote package)) \
(push (cons "melpa" "https://melpa.org/packages/") package-archives) \
(package-initialize) \
(mapc (lambda (pkg) \
(unless (package-installed-p pkg) \
(unless (assoc pkg package-archive-contents) \
(package-refresh-contents)) \
(package-install pkg))) \
(quote (${DEPS}))))
help:
@echo check
@echo compile
@echo all: clean check compile
@echo tag-release: check compile
@echo clean
all: clean check compile
check:
emacs -Q --eval '${INIT}' --batch -f package-lint-batch-and-exit ${LISP_FILE}
compile:
emacs -Q --eval '${INIT}' -L . --batch -f batch-byte-compile ${LISP_FILE}
tag-release: check compile
sed -i~ '1 s/.*/* ${VERS}/' ${NEWS_FILE}
git commit -m 'Add ${VERS} to ${NEWS_FILE}' ${NEWS_FILE}
awk '/^* Version/ { v ++1 } v == 1' ${NEWS_FILE} | sed 's/^* //' | git tag -F - ${TAG}
clean:
rm -f ${PROG}.elc
================================================
FILE: NEWS
================================================
* current
- Use buttons in sidebar, allowing mouse interaction
- Remove "include" and "concat" feature, this is better served with tags
and other tools
- Change Binder-Format-Version to 3, providing automatic upgrade to
convert "(include . t)" properties to #include tags
- Add binder-sidebar-copy-filepath command on c key
- Do not force bold header-line-format
- Print existing filepath when calling binder-sidebar-relocate
- Ensure indent-tabs-mode is nil in sidebar, preventing misalignment of
tags
- Append faces in sidebar to allow multiple faces, e.g. button +
binder-sidebar-highlight
* Version 0.4.4
- Add binder-sidebar-clear-filters (|) and remove clear-filters arg from
binder-sidebar-refresh
- Set project file to use lisp-data-mode
- Revert change of sidebar selection face
- Use a single-line prompt when switching project directory
- Remove unnecessary autoloads
- History is now tracked in a fancy NEWS file
- Update email, URL
* Version 0.4.3
- Use file-relative-name for binder-file-relative-to-root -- this will
set a fileid outside of the project directory as a relative path
instead of absolute
- Add faces binder-sidebar and binder-notes with face remap to default
- Quit and kill binder side windows in all frames on quit
- Remove call to hack-local-variables from binder-sidebar-refresh, as
this can cause a segfault
- Make safer use of set-transient-map
- Add hints for clearing sidebar tag filters (g key)
- Add binder-theme.el to contrib/
- Small imporvements to tutorial
- Track known issues with FIXME comments in source
- Stipulate acknowledgement of Scrivener in redistribution terms
- Update email, and upstream URL to https://git.skeletons.cc/binder
- Update repository for portability (add a screenshot, no more relying
on GitHub stuff)
* Version 0.4.2
- Give notes window same display alist as sidebar window
- Fix byte-compile issue with lisp-mnt (just don't use it)
* Version 0.4.1
- Correct spelling of option binder-default-file-extension
* Version 0.4.0
- Implement binder-tutorial as separate library
- Don't call binder-mode from binder-reveal-in-sidebar
* Version 0.3.1
This release marks Binder as no longer in alpha status.
- Ensure notes window keeps track of fileid
- No longer set pop-up-windows as buffer-local in sidebar, set it
lexically.
- binder-get-buffer-fileid returns binder--notes-fileid when in
notes window.
- binder-show-notes now takes FILEID and SELECT to make tracking
notes fileid easier, no longer needing to find it from sidebar.
- Hack local variables when refreshing sidebar
- Implement item shifting when filtered by tag
- Prefer elt to nth
* Version 0.3.0
Changes
- Change project file format to version 2 (adds binder-upgrade subr)
- Implement binder-init-project command
- Implement binder-sidebar-toggle-hide-tags command
- Add binder-filter function
- Rename binder-concat-find-original-file -> binder-concat-find-original
- Change binder-concat-find-original key binding to C-c RET
- Revert key binding for binder-sidebar-change-directory (P -> C)
- Save project and clear cache on quit
- Always write project data to file on delete item
- Lower Emacs version requirement to 24.4
- Prefer "project" to "binder" in var names and docs
- Update tutorial
Fixes
- Rewrite binder-read
- Fix binder-concat-mode-map var name
- Clear tags filter on binder-cd
- Remove binder-sidebar-set-status command (use binder-sidebar-add-tag)
- Call binder-cd when initializing a project
- Only find project file within binder-project-directory
- Fix for calling binder-next when in sidebar
- Set pop-up-windows as buffer-local in binder-sidebar-mode
- Fix binder-sidebar-find-file pop window with ARG
* Version 0.2.0
- Rewrite to use global dynamic variable binder-project-file
- Replace status with tags
Instead of setting a single status per item, now you can set multple
tags. Items displayed in the sidebar can be filtered interactively with
binder-narrow-by-tag and binder-exclude-by-tag comamnds.
- binder-get-tags now takes arg CURRENT
CURRENT will get structure accounting for binder-narrow-tags and
binder-exclude-tags
- Improve aesthetics when tags overwrite item display name
- Add tutorial project
- Ensure binder-root returns directory or nil
- Add binder-get-buffer-fileid for buffers
- Add/rename binder-sidebar|notes-persistent-window options
- Make binder-sidebar-select-window default nil
- Change binder-staple-* -> binder-concat-*
* Version 0.1.0
First public release
================================================
FILE: README.md
================================================
## Binder has moved to https://codeberg.org/divyaranjan/binder/
Binder
======
[][1]
[][2]

Binder is global minor mode to facilitate working on a writing project
in multiple files. It is heavily inspired by the binder feature in the
[macOS writing app Scrivener][3].
The rationale behind working this way is to split a large writing
project into smaller pieces.
Features
--------
Primarily, Binder provides a global minor mode `binder-mode`. This
allows working with files in the current `binder-project-directory`.
Data concerning these files is saved in a `.binder.el` file in the
project directory.
A project can be thought of an ordered list of files with associated
notes and tags.
Navigation
----------
At the most basic level, you can navigate back and forth through the
files in a project:
- `binder-next (C-c ])` visits the next file in the project
- `binder-previous (C-c [)` visits the previous
Calling these commands activates a transient map so that each command
can be repeated without the prefix key.
Sidebar
-------
You'll mostly interact with the project structure via the sidebar.
- `binder-toggle-sidebar (C-c ')` toggles the visibility of the binder
sidebar
- `binder-reveal-in-sidebar (C-c ;)` finds the current file in the
sidebar
Each project item is a file reference relative to the project directory.
Project items are displayed in a linear ordered list. Calling
`binder-sidebar-find-file (RET)` or `binder-sidebar-find-file-other-window (o)`
will visit the corresponding file.
Each item in the sidebar displays the following information:
1. `*` denotes that this item has some notes (see **Notes** below),
or...
2. `?` denotes that the item's corresponding file cannot be found
3. either the file relative to the project directory, or an arbitrary
display name
4. `#tag1 #tag2 ...` arbitrary item tags (see **Tags** below)
An item's display name can be changed with `binder-sidebar-rename (r)`.
If a file cannot be found, relocate with `binder-sidebar-relocate (R)`.
Calling `binder-sidebar-find-file (RET)` will visit the corresponding
file.
To add an existing file, call `binder-sidebar-add-file (a)` or add all
files in directory with `binder-sidebar-add-all-files (A)`.
Add a new file with `binder-sidebar-new-file (M-RET)`. This prompts for a
file-name and adds this (possibly non-existent) file to the project
after the current file's index. If no file-name extension is provided,
use `binder-default-file-extension`.
> Hint: you can use an alternate default file extension for different
> projects by setting a directory local variable.
Files can also be added to a project from outside the sidebar with
`binder-add-file (C-c :)`.
Items can be reordered with `binder-sidebar-shift-up (M-p | M-up)` and
`binder-sidebar-shift-down (M-n | M-down)`.
Remove items with `binder-sidebar-remove (d)` -- this *does not delete
the files*, only removes them from the project, but it *does* delete the
corresponding notes and tags.
Hide item file extensions by setting the `binder-sidebar-hide-file-extensions`
option. This can be toggled with `binder-sidebar-toggle-file-extensions (E)`.
The sidebar can be resized with `binder-sidebar-shrink-window ({)` and
`binder-sidebar-enlarge-window (})`. The window size is changed by the
number of columns specified in option `binder-sidebar-resize-window-step`.
You can customize how the sidebar window is displayed by setting
`binder-sidebar-display-alist` option.
Notes
-----
To open the notes buffer from the sidebar, call either
`binder-sidebar-open-notes (z)` to open and select the notes window, or
`binder-sidebar-toggle-notes (i)` to toggle the window.
To open a project file's notes from outside the sidebar, call
`binder-toggle-notes (C-c ")`.
You need to call either `binder-notes-save (C-x C-s)` or
`binder-notes-save-and-quit-window (C-c C-c)` to save notes to the
project file.
Calling `quit-window (C-c C-q | C-c C-k)` or `binder-toggle-sidebar`
does not save notes.
You can embiggen the notes window, to pop it out from the sidebar and
edit like a regular buffer window, with `binder-notes-expand-window (C-c
C-l)`.
You can customize how the notes window is displayed by setting
`binder-notes-display-alist` option.
Tags
----
Tags can help organize a project. An item can have any number of tags.
Add a tag to an item with `binder-sidebar-add-tag (t)`. Remove a tag
from an item with `binder-sidebar-remove-tag (T)`. You can tag/untag
multiple items at once by using marks (see **Marking** below).
Items in the sidebar can be narrowed to only show items with a certain
tag with `binder-sidebar-narrow-by-tag (/)` and/or only show items
without a certain tag with `binder-sidebar-exclude-by-tag (\)`. Each of
these commands can be called multiple times with additional tags.
Clear the sidebar filters with `binder-sidebar-clear-filters (|)`.
Marking
-------
Multiple items can be marked to add tags, toggle include state or
delete. Call `binder-sidebar-mark (m)` to mark an item or
`binder-sidebar-unmark (u)` to unmark an item.
To unmark all sidebar items, call `binder-sidebar-unmark-all (U)`.
Requirements
------------
- Emacs 24.4
- seq 2.20 (part of Emacs 25 and later)
Installation
------------
The latest stable release of Binder is available via [MELPA-stable][1].
First, add MELPA-stable to your package archives:
M-x customize-option RET package-archives RET
Insert an entry named `melpa-stable` with URL:
https://stable.melpa.org/packages/
You can then find the latest stable version of `binder` in the list
returned by:
M-x list-packages RET
If you prefer the latest but perhaps unstable version, do the above
using [MELPA][2].
Advanced Installation
---------------------
Download the latest tagged release, move this file into your `load-path`
and add to your `init.el` file:
(require 'binder)
(require 'binder-tutorial) ;; optional
If you wish to contribute to or alter Binder's code, clone the
repository into your load-path and require as above:
git clone https://github.com/rnkn/binder.git
Bugs and Feature Requests
-------------------------
Send me an email (address in the package header). For bugs, please
ensure you can reproduce with:
$ emacs -Q -l binder.el
Known issues are tracked with `FIXME` comments in the source.
Tutorial
--------
Binder comes with a tutorial. Calling `M-x binder-tutorial` will prompt
for an empty directory in which to generate the tutorial files.
[1]: https://stable.melpa.org/#/binder
[2]: https://melpa.org/#/binder
[3]: https://www.literatureandlatte.com/scrivener/
================================================
FILE: binder-tutorial.el
================================================
;;; binder-tutorial.el --- Tutorial for Binder projects -*- lexical-binding: t; -*-
;; Copyright (c) 2020-2024 Paul W. Rankin
;; Author: Paul W. Rankin <rnkn@rnkn.xyz>
;; Keywords: help, wp, convenience
;; 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:
;; This file contains code to generate a Binder project tutorial. It is
;; loaded upon calling `binder-tutorial'.
;;; Code:
(require 'binder)
(defconst binder-tutorial-items
(list
(cons ".binder.el"
(concat binder-file-header "\
((\"projects.txt\"
(tags \"start-here\"))
(\"sidebar.txt\"
(tags \"foo\" \"bar\"))
(\"navigation.txt\")
(\"marks.txt\")
(\"notes.txt\"
(notes . \"Some notes about notes.\n\nNullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio.\"))
(\"tags.txt\"
(tags \"foo\"))
(\"errors.txt\"))"))
(cons "projects.txt" "\
A project in Binder is a linear list of files in with associated
information (i.e. their order, notes, and tags). This information
is stored in a .binder.el file in the top-level directory of the
project.
You can only work on one project at a time in one Emacs session.
When locating the current project file, Binder looks in the current
directory then each parent directory, with the first found taking
precedence. Consider the following file layout:
├── .binder.el <-- project A
├── foo.txt
├── dir1
│ └── bar.txt
└── dir2
├── .binder.el <-- project B
└── baz.txt
Here project A could reference files foo.txt, bar.txt and baz.txt.
However when visiting file baz.txt, project B would take precedence.
Most management of a project will happen via the sidebar. Type C-c ] to
go to sidebar.txt.")
(cons "sidebar.txt" "\
By default items in the sidebar will show:
* name #tag1 #tag2
These things mean:
* the item has project notes
name either the item file name, or a custom item display name
#tag arbitrary item tag/s
You can move about in the sidebar by typing n and p, < and > and visit a
file by simply typing RET. Jump to the current item with j. You can
quickly resize the sidebar with { and }.
You can rearrange items with M-n and M-p. You can toggle file extensions
with E.
Type C-c ' to toggle the sidebar on/off. When visiting a project file,
type C-c ; to reveal it in the sidebar.
Try changing this item's display name with r. You can revert this by
doing the same and entering nothing.
Binder will automatically write its current project file after a certain
number of changes, but you can manually save a project by typing s.
Type C-c ] to go to the next file.")
(cons "navigation.txt" "\
You can navigate through project items forward and backward with C-c ]
and C-c [, which means Emacs will visit each file in the project list in
succession.
Try typing C-c [ to go back to a previous file. You don't need to prefix
C-c each time, so you can type e.g. C-c [ [ ] ] ] to repeatedly navigate
backward/forward.
The highlight in the sidebar lets you know where you are so you don't
get lost.
Type C-c ] to go to the next file.")
(cons "marks.txt" "\
You can mark multiple project items in the sidebar by typing m. Unmark
an item with u or unmark all items with U.
Marking items allows you to perform actions on multiple items at once.
Type C-c ] to go to the next file.")
(cons "notes.txt" "\
Each item can have notes, which are stored in the project file. In the
sidebar, type z to open this item's notes.
Add or change the notes and type C-c C-c (save notes and close window)
or C-x C-s (save notes without closing window). To quit the notes window
without saving the notes, type either C-c C-q or C-c C-k.
You can toggle the notes window without selecting it by typing i.
To really mix things up, open the notes window and, with it selected,
type C-c C-l. This pops the window out to be a regular window (instead
of a side-window). This command works as a toggle.
A file's notes can be edited without opening the sidebar with C-c \".
Type C-c ] to go to the next file.")
(cons "tags.txt" "\
Each project item can have any number of arbitrary tags, which are
prefixed with # by default.
To add a tag to an item, type t and enter the tag. To remove a tag, type
T and enter the tag. These commands work either with the item at point,
or all marked items.
Some tags are already added to play with. Type / then \"foo\" to narrow
the sidebar to only items tagged \"foo\". Now type \\ then \"bar\" to exclude
sidebar items tagged \"bar\".
You should have a sidebar with only this item showing.
Filtering the sidebar using tags allows a lot of flexibility with which
project files you want to work with in the sidebar.
When the sidebar items are filtered, navigating backward/forward only
considers those items.
Type | to clear the sidebar filters, then C-c ] to go to the next file.")
(cons "errors.txt" "\
Binder caches project information to avoid contious reading and writing
to disk. However this means errors may occur if a project is moved on
disk while project information is cached. If you plan on moving a
projects on disk it's best to deactivate binder-mode first.")))
;;;###autoload
(defun binder-tutorial (directory)
"Generate the Binder tutorial project in empty DIRECTORY."
(interactive "DGenerate tutorial project in directory: ")
(let ((default-directory directory))
(mapc (lambda (item)
(let ((old-buffer (get-buffer (car item))))
(when (buffer-live-p old-buffer) (kill-buffer old-buffer)))
(with-temp-buffer
(let ((require-final-newline t))
(insert (cdr item))
(write-file (car item)))))
binder-tutorial-items)
(binder-mode 1)
(binder-sidebar-create-window)
(select-window (get-buffer-window binder-sidebar-buffer))))
(provide 'binder-tutorial)
;;; binder-tutorial.el ends here
;; Local Variables:
;; coding: utf-8
;; fill-column: 80
;; indent-tabs-mode: nil
;; require-final-newline: t
;; sentence-end-double-space: nil
;; End:
================================================
FILE: binder.el
================================================
;;; binder.el --- Global minor mode to facilitate multi-file writing projects -*- lexical-binding: t; -*-
;; Copyright (c) 2020-2024 Paul W. Rankin
;; 2024 Divya Ranjan
;; Maintainer: Divya Ranjan <divya@subvertising.org>
;; Author: Paul W. Rankin <rnkn@rnkn.xyz>
;; Keywords: files, outlines, wp, text
;; Version: 0.5.0
;; Package-Requires: ((emacs "24.4") (seq "2.20"))
;; URL: https://codeberg.org/divyaranjan/binder/
;; 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/>.
;; In addition to conditions of the GNU General Public License, this program may
;; not be redistributed without the following acknowledgement:
;; This program takes influence from the macOS writing application Scrivener,
;; created by Literature and Latte <https://www.literatureandlatte.com/scrivener/>.
;;; Commentary:
;; Binder
;; ======
;; Binder is global minor mode to facilitate working on a writing project
;; in multiple files. It is heavily inspired by the binder feature in the
;; [macOS writing app Scrivener][3].
;; The rationale behind working this way is to split a large writing
;; project into smaller pieces.
;; Features
;; --------
;; Primarily, Binder provides a global minor mode binder-mode. This
;; allows working with files in the current binder-project-directory.
;; Data concerning these files is saved in a .binder.el file in the
;; project directory.
;; A project can be thought of an ordered list of files with associated
;; notes and tags.
;; Navigation
;; ----------
;; At the most basic level, you can navigate back and forth through the
;; files in a project:
;; - binder-next (C-c ]) visits the next file in the project
;; - binder-previous (C-c [) visits the previous
;; Calling these commands activates a transient map so that each command
;; can be repeated without the prefix key.
;; Sidebar
;; -------
;; You'll mostly interact with the project structure via the sidebar.
;; - binder-toggle-sidebar (C-c ') toggles the visibility of the binder
;; sidebar
;; - binder-reveal-in-sidebar (C-c ;) finds the current file in the
;; sidebar
;; Each project item is a file reference relative to the project directory.
;; Project items are displayed in a linear ordered list. Calling
;; binder-sidebar-find-file (RET) or binder-sidebar-find-file-other-window (o)
;; will visit the corresponding file.
;; Each item in the sidebar displays the following information:
;; 1. * denotes that this item has some notes (see **Notes** below),
;; or...
;; 2. ? denotes that the item's corresponding file cannot be found
;; 3. either the file relative to the project directory, or an arbitrary
;; display name
;; 4. #tag1 #tag2 ... arbitrary item tags (see **Tags** below)
;; An item's display name can be changed with binder-sidebar-rename (r).
;; If a file cannot be found, relocate with binder-sidebar-relocate (R).
;; Calling binder-sidebar-find-file (RET) will visit the corresponding
;; file.
;; To add an existing file, call binder-sidebar-add-file (a) or add all
;; files in directory with binder-sidebar-add-all-files (A).
;; Add a new file with binder-sidebar-new-file (M-RET). This prompts for a
;; file-name and adds this (possibly non-existent) file to the project
;; after the current file's index. If no file-name extension is provided,
;; use binder-default-file-extension.
;; > Hint: you can use an alternate default file extension for different
;; > projects by setting a directory local variable.
;; Files can also be added to a project from outside the sidebar with
;; binder-add-file (C-c :).
;; Items can be reordered with binder-sidebar-shift-up (M-p | M-up) and
;; binder-sidebar-shift-down (M-n | M-down).
;; Remove items with binder-sidebar-remove (d) -- this *does not delete
;; the files*, only removes them from the project, but it *does* delete the
;; corresponding notes and tags.
;; Hide item file extensions by setting the binder-sidebar-hide-file-extensions
;; option. This can be toggled with binder-sidebar-toggle-file-extensions (E).
;; The sidebar can be resized with binder-sidebar-shrink-window ({) and
;; binder-sidebar-enlarge-window (}). The window size is changed by the
;; number of columns specified in option binder-sidebar-resize-window-step.
;; You can customize how the sidebar window is displayed by setting
;; binder-sidebar-display-alist option.
;; Notes
;; -----
;; To open the notes buffer from the sidebar, call either
;; binder-sidebar-open-notes (z) to open and select the notes window, or
;; binder-sidebar-toggle-notes (i) to toggle the window.
;; To open a project file's notes from outside the sidebar, call
;; binder-toggle-notes (C-c ").
;; You need to call either binder-notes-save (C-x C-s) or
;; binder-notes-save-and-quit-window (C-c C-c) to save notes to the
;; project file.
;; Calling quit-window (C-c C-q | C-c C-k) or binder-toggle-sidebar
;; does not save notes.
;; You can embiggen the notes window, to pop it out from the sidebar and
;; edit like a regular buffer window, with binder-notes-expand-window (C-c
;; C-l).
;; You can customize how the notes window is displayed by setting
;; binder-notes-display-alist option.
;; Tags
;; ----
;; Tags can help organize a project. An item can have any number of tags.
;; Add a tag to an item with binder-sidebar-add-tag (t). Remove a tag
;; from an item with binder-sidebar-remove-tag (T). You can tag/untag
;; multiple items at once by using marks (see **Marking** below).
;; Items in the sidebar can be narrowed to only show items with a certain
;; tag with binder-sidebar-narrow-by-tag (/) and/or only show items
;; without a certain tag with binder-sidebar-exclude-by-tag (\). Each of
;; these commands can be called multiple times with additional tags.
;; Clear the sidebar filters with binder-sidebar-clear-filters (|).
;; Marking
;; -------
;; Multiple items can be marked to add tags, toggle include state or
;; delete. Call binder-sidebar-mark (m) to mark an item or
;; binder-sidebar-unmark (u) to unmark an item.
;; To unmark all sidebar items, call binder-sidebar-unmark-all (U).
;; Requirements
;; ------------
;; - Emacs 24.4
;; - seq 2.20 (part of Emacs 25 and later)
;; Installation
;; ------------
;; The latest stable release of Binder is available via [MELPA-stable][1].
;; First, add MELPA-stable to your package archives:
;; M-x customize-option RET package-archives RET
;; Insert an entry named melpa-stable with URL:
;; https://stable.melpa.org/packages/
;; You can then find the latest stable version of binder in the list
;; returned by:
;; M-x list-packages RET
;; If you prefer the latest but perhaps unstable version, do the above
;; using [MELPA][2].
;; Advanced Installation
;; ---------------------
;; Download the latest tagged release, move this file into your load-path
;; and add to your init.el file:
;; (require 'binder)
;; (require 'binder-tutorial) ;; optional
;; If you wish to contribute to or alter Binder's code, clone the
;; repository into your load-path and require as above:
;; git clone https://github.com/rnkn/binder.git
;; Bugs and Feature Requests
;; -------------------------
;; Send me an email (address in the package header). For bugs, please
;; ensure you can reproduce with:
;; $ emacs -Q -l binder.el
;; Known issues are tracked with FIXME comments in the source.
;; Tutorial
;; --------
;; Binder comes with a tutorial. Calling M-x binder-tutorial will prompt
;; for an empty directory in which to generate the tutorial files.
;; [1]: https://stable.melpa.org/#/binder
;; [2]: https://melpa.org/#/binder
;; [3]: https://www.literatureandlatte.com/scrivener/
;;; Code:
(eval-when-compile (require 'cl-lib))
(eval-when-compile (require 'subr-x))
(require 'lisp-mnt)
(require 'seq)
(defgroup binder ()
"Work with a structured project of files."
:group 'files)
;;; Core Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar binder-format-version 3)
(defvar binder-file-header
(format "\
;; -*- mode: lisp-data; coding: utf-8 -*-
;; Binder-Format-Version: %s
;; This is a Binder project file. It is meant to be human-readable, but you
;; probably shouldn't edit it.\n\n" binder-format-version)
"Header information for project file.")
(defvar binder--cache nil)
(defvar binder--modification-time nil)
(defvar binder--modification-count 0)
(defvar binder--current-fileid nil)
(defvar binder--sidebar-marked nil)
(defvar binder--notes-fileid nil)
(defvar binder--notes-display nil)
(defvar binder-narrow-tags nil)
(defvar binder-exclude-tags nil)
(defvar binder-status-filter-in nil)
(defvar binder-status-filter-out nil)
;;; Options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom binder-mode-lighter
" B/"
"Mode-line indicator for `binder-mode'."
:type '(choice (const :tag "No lighter" "") string)
:safe 'stringp
:group 'binder)
(defcustom binder-default-file
".binder.el"
"Default file in which to store Binder project data."
:type 'string
:safe 'stringp
:group 'binder)
(defcustom binder-project-directory
nil
"Directory containing current `binder-default-file' or nil.
The value set here will be used as default, but may be changed at
any time with `binder-change-directory'."
:type '(choice (const nil) directory)
:safe 'stringp
:group 'binder)
(defcustom binder-default-file-extension
"txt"
"Default extension for new binder files."
:type 'string
:safe 'stringp
:group 'binder)
(defcustom binder-save-threshold
20
"Integer of changes before binder file is automatically saved."
:type 'integer
:safe 'integerp
:group 'binder)
;;; Faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup binder-sidebar-faces ()
"Default faces for `binder-sidebar-mode'."
:group 'binder-sidebar)
(defface binder-sidebar-marked
'((t (:inherit (warning))))
"Default face marked items."
:group 'binder-sidebar-faces)
(defface binder-sidebar-highlight
'((t (:extend t :inherit (secondary-selection))))
"Default face for highlighted items."
:group 'binder-sidebar-faces)
(defface binder-sidebar-missing
'((t (:inherit (trailing-whitespace))))
"Default face for missing items."
:group 'binder-sidebar-faces)
(defface binder-sidebar-tags
'((t (:inherit (font-lock-variable-name-face))))
"Default face for tags."
:group 'binder-sidebar-faces)
;;; Core Non-interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun binder-root ()
"Return the root directory with a project file, or nil."
(locate-dominating-file default-directory binder-default-file))
(defun binder-set-modified ()
"Set the project data as modified."
(cl-incf binder--modification-count)
(setq binder--modification-time (current-time)))
(defun binder-set-unmodified ()
"Set the project data as unmodified."
(setq binder--modification-count 0
binder--modification-time (current-time)))
(defun binder-cd (directory)
"Set `binder-project-directory' to DIRECTORY and erase cache."
(customize-set-variable 'binder-project-directory directory)
(setq binder-narrow-tags nil
binder-exclude-tags nil
binder--notes-fileid nil
binder--cache nil)
(binder-set-unmodified))
(defun binder-init ()
"Initialize an empty project file in `binder-project-directory'."
(with-temp-buffer
(insert binder-file-header
(pp-to-string nil))
(write-file (expand-file-name binder-default-file binder-project-directory))))
(defun binder-locate-project-file ()
"Find or initialize current project file."
(let ((binder-file
(expand-file-name binder-default-file binder-project-directory)))
(unless (file-exists-p binder-file) (binder-init))
binder-file))
(defun binder-write ()
"Write project data to file."
(let ((binder-file (binder-locate-project-file)))
(with-temp-buffer
(insert binder-file-header
(pp-to-string binder--cache))
(write-file binder-file)))
(binder-set-unmodified))
(defun binder-write-maybe ()
"Call `binder-write' if modified threshold has been reached.
Otherwise call `binder-set-modified'."
(if (<= binder-save-threshold binder--modification-count)
(binder-write)
(binder-set-modified)))
(defun binder-filter (data)
"Filter project DATA by tags.
Included `binder-narrow-tags' and excluded `binder-exclude-tags'."
(seq-filter
(lambda (item)
(and (seq-every-p
(lambda (tag)
(member tag (cdr (assq 'tags item))))
binder-narrow-tags)
(seq-every-p
(lambda (tag)
(not (member tag (cdr (assq 'tags item)))))
binder-exclude-tags)))
data))
(defun binder-upgrade (data version)
"Upgrade project DATA in VERSION to `binder-format-version'."
(cond ((not (stringp version))
(binder-upgrade (cdr (assq 'structure data)) "2"))
((= (string-to-number version) 2)
(mapcar
(lambda (item)
(when (cdr (assq 'include item))
(let ((tags (assq 'tags item)))
(if tags
(cl-pushnew "include" (cdr tags))
(push (list 'tags "include") (cdr item)))))
(assq-delete-all 'include item))
data))
(t data)))
(defun binder-read (&optional filter)
"Read current project data.
Reads from `binder--cache' if valid, or from project file if not.
With optional argument FILTER, call `binder-filter' on data."
(let ((binder-file (binder-locate-project-file))
version)
(when binder--cache
(cond
;; If there's no project file found, signal an error.
((null binder-file)
(user-error "No binder file found"))
;; If the cache doesn't refer to the project directory, set the cache to
;; nil.
((and (binder-root)
(not (file-equal-p binder-project-directory (binder-root))))
(setq binder--cache nil))
;; If the project file is newer than the cache, offer to revert from disk
;; (and write binder data), regardless, set the cache to nil.
((time-less-p binder--modification-time
(elt (file-attributes binder-file) 5))
(unless (y-or-n-p "Project file changed on disk; revert from disk? ")
(binder-write))
(setq binder--cache nil))))
;; If the cache survived all that, it's valid, otherwise, read from the
;; project file.
(unless binder--cache
(with-temp-buffer
(insert-file-contents binder-file)
;; Read Binder-Format-Version header
(setq version (lm-header "binder-format-version"))
(goto-char (point-min))
(setq binder--cache
(binder-upgrade (read (current-buffer)) version)))
(binder-set-unmodified)))
;; Finally, return the cache.
(if filter (binder-filter binder--cache) binder--cache))
(defun binder-ensure-in-project ()
"Ensure the current file or directory is in the project."
(let ((root (binder-root)))
(cond
;; The project directory matches root, we're all good.
((and (stringp binder-project-directory)
(stringp root)
(file-equal-p binder-project-directory root))
t)
;; The project directory does not match project root; offer to change it to
;; current project root.
((and (stringp binder-project-directory)
(stringp root))
(when (y-or-n-p (format "Change project directory to %s? "
root))
(binder-cd root)))
;; The project directory is set but we're not in a project; this is fine.
((stringp binder-project-directory)
t)
;; The project directory is not set, but we're in a project; offer to set
;; it to current project root.
((stringp root)
(binder-cd root)
(message "Set binder directory to %s" root))
;; A fresh project; offer to set project directory to default-directory.
(t
(when (y-or-n-p (format "Set binder directory to %s? "
(abbreviate-file-name default-directory)))
(binder-cd default-directory)
(binder-init))))))
(defun binder-file-relative-to-root (filepath)
"Return FILEPATH relative to `binder-project-directory'."
(file-relative-name (or filepath default-directory)
binder-project-directory))
(defun binder-get-item (fileid)
"Return project item association list for FILEID."
(assoc-string fileid (binder-read t)))
(defun binder-get-item-prop (fileid prop)
"Return value of PROP for project item with FILEID."
(cdr (assq prop (cdr (binder-get-item fileid)))))
(defun binder-set-item-prop (fileid prop value)
"Set VALUE of PROP for project item with FILEID."
(let ((item (binder-get-item fileid)))
(if (or (null value) (and (stringp value) (string-empty-p value)))
(setf item (assq-delete-all prop item))
(let ((prop-elt (assq prop item)))
(if prop-elt
(setcdr prop-elt value)
(push (cons prop value) (cdr item)))))))
(defun binder-add-to-item-prop (fileid prop value)
"Add VALUE to PROP for project item with FILEID."
(let ((prop-elt (binder-get-item-prop fileid prop)))
(unless (member value prop-elt)
(binder-set-item-prop fileid prop (push value prop-elt)))))
(defun binder-remove-from-item-prop (fileid prop value)
"Remove VALUE from PROP for project item with FILEID."
(let ((prop-elt (binder-get-item-prop fileid prop)))
(when (member value (binder-get-item-prop fileid 'tags))
(binder-set-item-prop fileid prop (remove value prop-elt)))))
(defun binder-get-item-index (fileid &optional filter)
"Return index position for project item for FILEID.
With option argument FILTER, return index when items are
filtered."
(seq-position (binder-read filter) (binder-get-item fileid)))
(defun binder-insert-item (item index)
"Insert project ITEM at position INDEX."
(unless (listp item) (setq item (list item)))
(setq binder--cache
(let ((structure (binder-read)))
(append (seq-take structure index)
(cons item (seq-drop structure index))))))
(defun binder-delete-item (fileid)
"Delete project item with FILEID."
(setq binder--cache
(remove (binder-get-item fileid) (binder-read))))
(defun binder-get-prop-list (prop)
"Return list of values for PROP."
(delq nil
(mapcar
(lambda (item)
(let ((value (cdr (assq prop item))))
(when (and (stringp value) (< 0 (string-width value)))
value)))
(binder-read))))
(defun binder-get-tags (&optional filter)
"Return current project tags.
Optionally pass FILTER to `binder-read'."
(let (tags)
(mapc
(lambda (item)
(mapc
(lambda (tag)
(push tag tags))
(cdr (assq 'tags item))))
(binder-read filter))
(seq-uniq tags 'string-equal)))
(defun binder-get-buffer-fileid ()
"Return buffer binder fileid."
(cl-case major-mode
(binder-sidebar-mode binder--current-fileid)
(binder-notes-mode binder--notes-fileid)
(t (binder-file-relative-to-root (buffer-file-name)))))
;;; Global Minor Mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun binder-init-project (directory)
"Initialize empty project in DIRECTORY."
(interactive "DInitialize empty project in directory: ")
(binder-cd directory)
(binder-init))
(defun binder-save (&optional prompt)
"Save project data (with prompt when PROMPT is non-nil)."
(interactive)
(cond ((= 0 binder--modification-count)
(message "(No changes need to be saved)"))
((and prompt
(y-or-n-p (format "Save binder project %s? "
(abbreviate-file-name binder-project-directory))))
(binder-write))
(t
(binder-write))))
(defun binder-exit-hook ()
"Ensure project data is saved on exit."
(when binder-mode (binder-save 'prompt)))
(defun binder-change-directory (directory)
"Change to binder project directory DIRECTORY."
(interactive "DDirectory: ")
(binder-save 'prompt)
(binder-cd directory)
(binder-sidebar-refresh-window)
(binder-notes-refresh-window))
(defun binder-next (&optional n)
"Visit Nth next file in binder.
Or visit Nth previous file if N is negative."
(interactive "p")
(when (binder-ensure-in-project)
;; Find the current file/directory fileid, if one.
(let ((this-fileid (binder-get-buffer-fileid))
(structure (binder-read t))
index next-index)
;; If current file has an INDEX, get the NEXT-INDEX.
(setq index (or (binder-get-item-index this-fileid t) 0)
next-index (+ index n))
;; If NEXT-INDEX is within the filtered structure length, find the
;; Nth next/previous file.
(if (not (<= 0 next-index (1- (length structure))))
(message "End of binder")
(find-file-existing
(expand-file-name (car (elt structure next-index))
binder-project-directory))
(binder-sidebar-refresh-window))
;; Setup the overriding keymap.
(unless overriding-terminal-local-map
(let ((prefix-keys (substring (this-single-command-keys) 0 -1))
(map (cdr binder-navigation-map)))
(when (< 0 (length prefix-keys))
(mapc (lambda (k) (setq map (assq k map))) prefix-keys)
(setq map (cdr-safe map))
(when (keymapp map) (set-transient-map map t))))))))
(defun binder-previous (&optional n)
"Visit Nth previous file in binder.
Or visit Nth next file if N is negative."
(interactive "p")
(binder-next (- n)))
(defun binder-add-file (fileid &optional index string)
"Add a (possibly non-existent) FILEID at INDEX containing STRING.
If the current file is in the project, add at index after that
one, otherwise insert at end."
(interactive "FAdd file (extension optional): ")
(binder-ensure-in-project)
(setq fileid (binder-file-relative-to-root fileid))
(unless (< 0 (string-width fileid))
(user-error "No file name supplied"))
;; If FILEID is not a directory and no file extension was provided,
;; add the binder's default file extensions.
(unless (or (file-directory-p fileid)
(and (string-match "\\.[^.]+\\'" fileid)
(not (= 0 (match-beginning 0)))))
(setq fileid
(concat fileid "." binder-default-file-extension)))
;; If the file/directory does not exist, create it.
(let ((filepath (expand-file-name fileid binder-project-directory)))
(unless (file-exists-p filepath)
(if (file-directory-p filepath)
(make-directory filepath t)
(with-current-buffer (find-file-noselect filepath)
(when (stringp string) (insert string))
(write-file filepath))))
;; Insert FILEID into binder at INDEX, or after current file.
(unless (binder-get-item fileid)
(unless index
(let ((this-file-index
(binder-get-item-index (binder-get-buffer-fileid) t)))
(setq index (if this-file-index
(1+ this-file-index)
(length (binder-read))))))
(binder-insert-item fileid index))
(binder-write-maybe)
;; When binder sidebar is active, refresh it.
(binder-sidebar-refresh-window)
;; Finally, visit the file FILEPATH.
(let ((pop-up-windows binder-sidebar-pop-up-windows))
(find-file filepath))))
(defun binder-extract-region-to-new-file (beg end fileid)
"Extract region between BEG and END into new project file FILEID."
(interactive "r\nFNew file name (extension optional): ")
(binder-ensure-in-project)
(let ((string (delete-and-extract-region beg end)))
(binder-add-file fileid nil string)))
(defvar binder-navigation-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c ]") #'binder-next)
(define-key map (kbd "C-c [") #'binder-previous)
map)
"Navigational mode map for `binder-mode'.")
(defvar binder-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c ;") #'binder-reveal-in-sidebar)
(define-key map (kbd "C-c '") #'binder-toggle-sidebar)
(define-key map (kbd "C-c \"") #'binder-toggle-notes)
(define-key map (kbd "C-c :") #'binder-add-file)
map)
"Main mode map for `binder-mode'.")
(set-keymap-parent binder-mode-map binder-navigation-map)
;;;###autoload
(define-minor-mode binder-mode
"Globally interact with `binder'."
:init-value nil
:lighter binder-mode-lighter
:global t
(if binder-mode
(unless noninteractive
(add-hook 'kill-emacs-hook #'binder-exit-hook)
(add-hook 'window-configuration-change-hook #'binder-highlight-in-sidebar))
(binder-save 'prompt)
(remove-hook 'window-configuration-change-hook #'binder-highlight-in-sidebar)
(when (window-live-p (get-buffer-window binder-sidebar-buffer t))
(with-selected-window (get-buffer-window binder-sidebar-buffer t)
(quit-window t)))
(when (window-live-p (get-buffer-window binder-notes-buffer t))
(with-selected-window (get-buffer-window binder-notes-buffer t)
(quit-window t)))
(setq binder--cache nil)))
;;; Sidebar Major Mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup binder-sidebar ()
"Options for `binder-sidebar-mode'."
:group 'binder)
(defface binder-sidebar
'((t nil))
"Default base-level face for `binder-sidebar-mode' buffers.")
(defcustom binder-sidebar-buffer "*Binder Sidebar*"
"Default buffer name for binder sidebar."
:type 'string
:safe 'stringp
:group 'binder-sidebar)
(defcustom binder-sidebar-display-alist
'((side . left)
(window-width . 40)
(slot . -1))
"Association list used to display binder sidebar buffer.
See `display-buffer-in-side-window' for example options."
:type 'alist
:safe (lambda (value)
(and (listp value)
(seq-every-p 'consp value)))
:group 'binder-sidebar)
(defcustom binder-sidebar-hide-file-extensions
nil
"When non-nil, list items without file extension."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-sidebar-hide-tags
nil
"When non-nil, list items without tags."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-sidebar-pop-up-windows
nil
"Non-nil means displaying a new buffer should make a new window."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-sidebar-tags-column
25
"Integer for column to align tags."
:type 'integer
:safe 'integerp
:group 'binder-sidebar)
(defcustom binder-sidebar-include-char
?x
"Character to display on items including in joining."
:type 'character
:safe 'characterp
:group 'binder-sidebar)
(defcustom binder-sidebar-notes-char
?*
"Character to display on items with notes."
:type 'character
:safe 'characterp
:group 'binder-sidebar)
(defcustom binder-sidebar-tags-char
?#
"Character to prefix to item tags."
:type 'character
:safe 'characterp
:group 'binder-sidebar)
(defcustom binder-sidebar-missing-char
??
"Character to display on items with missing files."
:type 'character
:safe 'characterp
:group 'binder-sidebar)
(defcustom binder-sidebar-select-window
nil
"If non-nil, switch to sidebar upon displaying it."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-sidebar-persistent-window
t
"When non-nil, sidebar will persist when calling `delete-other-windows'.
This marks `no-delete-other-windows' window parameter as non-nil.
Use `binder-toggle-sidebar' or `quit-window' to close the sidebar."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-sidebar-resize-window-step
4
"Integer of columns by which to resize window.
Used by `binder-sidebar-shrink-window' and `binder-sidebar-enlarge-window'."
:type 'integer
:safe 'integerp
:group 'binder-sidebar)
(defun binder-sidebar-refresh ()
"Redraw binder sidebar, reading from cache."
(interactive)
(with-silent-modifications
(setq default-directory binder-project-directory)
(setq header-line-format (abbreviate-file-name binder-project-directory))
(let ((x (point)))
(erase-buffer)
(mapc
(lambda (item)
(let ((fileid (car item))
(display (cdr (assq 'display item)))
(notes (cdr (assq 'notes item)))
(tags (cdr (assq 'tags item)))
marked missing tags-overwrite)
;; Set whether FILEID is MARKED and MISSING.
(when (member fileid binder--sidebar-marked) (setq marked t))
(when (not (file-exists-p fileid)) (setq missing t))
;; Insert the item line elements.
(insert (if marked ">" " ")
(cond (missing binder-sidebar-missing-char)
((and notes (not (string-empty-p notes)))
binder-sidebar-notes-char)
(t " "))
" ")
;; Use either DISPLAY, or if directory ensure a trailing slash, and
;; finally if we're hiding file extensions, do that, otherwise just
;; the FILEID is fine.
(insert-text-button
(or display (if (file-directory-p fileid)
(replace-regexp-in-string "/*$" "/" fileid)
(if binder-sidebar-hide-file-extensions
(replace-regexp-in-string ".+\\(\\..+\\)" ""
fileid nil nil 1)
fileid)))
'binder-fileid fileid
'face 'button
'action #'binder-sidebar-button-action
'help-echo "mouse-1, RET: visit this file"
'follow-link t)
;; Add the face properties. Make them front-sticky since we
;; were previously editing the buffer text (but not anymore).
(put-text-property (line-beginning-position) (line-end-position)
'binder-fileid fileid)
(put-text-property (line-beginning-position) (line-end-position)
'front-sticky '(binder-fileid))
(when missing
(add-face-text-property (line-beginning-position) (line-end-position)
'binder-sidebar-missing))
(when marked
(add-face-text-property (line-beginning-position) (line-end-position)
'binder-sidebar-marked))
;; Add the item TAGS with a hashtag, because hashtags are cool, right?
(when (and (not binder-sidebar-hide-tags) tags)
(move-to-column (1- binder-sidebar-tags-column))
(unless (eolp) (setq tags-overwrite t))
(move-to-column binder-sidebar-tags-column)
(indent-to-column binder-sidebar-tags-column)
(let ((tags-col (point))
(tags-char (char-to-string binder-sidebar-tags-char)))
(delete-region (1- tags-col) (line-end-position))
(insert (if tags-overwrite "~" " ")
tags-char
(string-join tags (concat " " tags-char)))
(add-face-text-property tags-col (line-end-position)
'binder-sidebar-tags)))
(insert "\n")
(when (string= fileid binder--current-fileid)
(add-face-text-property (line-beginning-position 0)
(line-beginning-position)
'binder-sidebar-highlight))))
(binder-read t))
(goto-char x))))
(defun binder-sidebar-button-ensure ()
"Ensure point is at button."
(or (button-at (point))
(and (eolp) (forward-button -1 nil nil t))
(forward-button 1 nil nil t)))
(defun binder-sidebar-button-action (button &optional pop-up-window)
(interactive)
(let ((pop-up-windows (or pop-up-window binder-sidebar-pop-up-windows))
(fileid (button-get button 'binder-fileid))
filepath)
(setq filepath (expand-file-name fileid))
(when (file-exists-p filepath)
(setq binder--current-fileid fileid)
(binder-sidebar-refresh)
(find-file filepath))))
(defun binder-sidebar-refresh-window ()
"Call `binder-sidebar-refresh' if sidebar window is live."
(when (window-live-p (get-buffer-window binder-sidebar-buffer))
(with-current-buffer binder-sidebar-buffer
(binder-sidebar-refresh))))
(defalias 'binder-sidebar-change-directory #'binder-change-directory)
(defun binder-sidebar-create-buffer ()
"Return binder sidebar buffer for DIRECTORY."
(binder-ensure-in-project)
(with-current-buffer (get-buffer-create binder-sidebar-buffer)
(binder-sidebar-mode)
(binder-sidebar-refresh)
(current-buffer)))
(defun binder-sidebar-create-window ()
"Return binder sidebar window for DIRECTORY.
Defaults to current directory."
(let ((display-buffer-mark-dedicated t))
(display-buffer-in-side-window
(binder-sidebar-create-buffer)
(append binder-sidebar-display-alist
(when binder-sidebar-persistent-window
(list '(window-parameters (no-delete-other-windows . t))))))))
(defun binder-sidebar-get-fileid ()
"Return fileid for item at point."
(save-excursion
(if (eobp) (forward-line -1) (beginning-of-line))
(get-text-property (point) 'binder-fileid)))
(defun binder-sidebar-goto-item (fileid)
"Move point to project item with FILEID."
(goto-char (point-min))
;; It would be nice to use find-next-text-property but that isn't
;; available until Emacs 27.
(let (found)
(while (not (or (eobp) found))
(if (string= (binder-sidebar-get-fileid) fileid)
(setq found t)
(forward-line 1)))))
(defun binder-sidebar-find-file (arg)
"Visit project file at point.
When ARG is non-nil, visit in new window."
(interactive "P")
(when (binder-sidebar-button-ensure)
(binder-sidebar-button-action (button-at (point)) arg)))
(defun binder-sidebar-find-file-other-window ()
"Visit project file at point in other window."
(interactive)
(binder-sidebar-find-file t))
;; FIXME: FEATURE - `binder-sidebar-search' to search for strings within
;; project. Could be implemented simply as a dynamic command passed to `lgrep'.
(defalias 'binder-sidebar-save #'binder-save)
(defun binder-sidebar-get-index ()
"Return binder index position at point."
(if (eobp)
(1- (length (binder-read)))
(binder-get-item-index (binder-sidebar-get-fileid) t)))
(defun binder-sidebar-mark ()
"Mark the project item at point."
(interactive)
(cl-pushnew (binder-sidebar-get-fileid) binder--sidebar-marked)
(forward-line 1)
(binder-sidebar-refresh))
(defun binder-sidebar-unmark ()
"Unmark the project item at point."
(interactive)
(setq binder--sidebar-marked
(remove (binder-sidebar-get-fileid) binder--sidebar-marked))
(forward-line 1)
(binder-sidebar-refresh))
(defun binder-sidebar-unmark-all ()
"Unmark all project items."
(interactive)
(setq binder--sidebar-marked nil)
(binder-sidebar-refresh))
(defun binder-sidebar-add-file (fileid)
"Add (possibly non-existent) file to binder as FILEID."
(interactive "FAdd file: ")
(setq fileid (binder-file-relative-to-root fileid))
(unless (binder-get-item fileid)
(binder-insert-item fileid (1+ (binder-sidebar-get-index))))
(binder-write-maybe)
(binder-sidebar-refresh)
(binder-sidebar-goto-item fileid))
(defun binder-sidebar-add-all-files ()
"Add all files in current directory to binder."
(interactive)
(when (y-or-n-p (format "Add all files in %s? "
(abbreviate-file-name default-directory)))
(dolist (file (directory-files default-directory nil "^[^.]"))
(binder-sidebar-add-file file))))
(defun binder-sidebar-new-file (fileid)
"Add a new file to binder as FILEID and visit it."
(interactive "FAdd file (extension optional): ")
(unless (eq major-mode 'binder-sidebar-mode)
(user-error "Not in %S" 'binder-sidebar-mode))
(binder-add-file fileid (1+ (binder-sidebar-get-index)))
(binder-sidebar-goto-item fileid))
(defun binder-sidebar-remove (arg)
"Remove marked items or item at point.
When ARG is non-nil, do not prompt for confirmation."
(interactive "P")
(let ((fileid-list (or binder--sidebar-marked
(list (binder-sidebar-get-fileid)))))
(when (or arg (y-or-n-p (format "Really remove %s? "
(string-join fileid-list ", "))))
(mapc #'binder-delete-item fileid-list)
(setq binder--sidebar-marked nil)))
(binder-write)
(binder-sidebar-refresh))
(defun binder-sidebar-rename ()
"Change display name of project item at point."
(interactive)
(let ((fileid (binder-sidebar-get-fileid))
name)
(setq name
(read-string "New name: "
(or (binder-get-item-prop fileid 'display) fileid)))
(binder-set-item-prop fileid 'display name)
(binder-write-maybe)
(binder-sidebar-refresh)))
(defun binder-sidebar-relocate (filepath)
"Change file path of project item at point to FILEPATH."
(interactive
(list (read-file-name
(format "New file path [%s]: " (binder-sidebar-get-fileid))
nil nil t)))
(setq filepath (binder-file-relative-to-root filepath))
(setcar (binder-get-item (binder-sidebar-get-fileid)) filepath)
(binder-write-maybe)
(binder-sidebar-refresh))
(defun binder-sidebar-add-tag (tag)
"Add TAG to marked items or item at point."
(interactive
(list (completing-read
"Add tag: " (binder-get-tags))))
(mapc
(lambda (fileid)
(binder-add-to-item-prop fileid 'tags tag))
(or binder--sidebar-marked
(list (binder-sidebar-get-fileid))))
(setq binder--sidebar-marked nil)
(binder-write-maybe)
(binder-sidebar-refresh))
(defun binder-sidebar-remove-tag (tag)
"Remove TAG to marked items or item at point."
(interactive
(list (completing-read
"Remove tag: "
(binder-get-item-prop (binder-sidebar-get-fileid) 'tags))))
(mapc
(lambda (fileid)
(binder-remove-from-item-prop fileid 'tags tag))
(or binder--sidebar-marked
(list (binder-sidebar-get-fileid))))
(setq binder--sidebar-marked nil)
(binder-write-maybe)
(binder-sidebar-refresh))
(defun binder-sidebar-toggle-file-extensions ()
"Toggle visibility of item file extensions."
(interactive)
(customize-set-variable 'binder-sidebar-hide-file-extensions
(not binder-sidebar-hide-file-extensions))
(let ((fileid (binder-sidebar-get-fileid)))
(binder-sidebar-refresh)
(binder-sidebar-goto-item fileid))
(message "%s file extensions"
(capitalize
(if binder-sidebar-hide-file-extensions
"hiding" "showing"))))
(defun binder-sidebar-toggle-tags ()
"Toggle visibility of tags."
(interactive)
(customize-set-variable 'binder-sidebar-hide-tags
(not binder-sidebar-hide-tags))
(let ((fileid (binder-sidebar-get-fileid)))
(binder-sidebar-refresh)
(binder-sidebar-goto-item fileid))
(message "%s tags"
(capitalize
(if binder-sidebar-hide-tags
"hiding" "showing"))))
(defun binder-sidebar-shift-down (&optional n)
"Shift index position of item at point down N places in list."
(interactive "p")
(let ((p (if (<= n 0) -1 1))
(fileid (binder-sidebar-get-fileid))
item fake-index next-index)
(setq item (binder-get-item fileid)
fake-index (binder-get-item-index fileid t)
next-index (seq-position (binder-read)
(elt (binder-read t) (+ fake-index p))))
(when (<= 0 (+ fake-index p)
(1- (length (binder-read t))))
(binder-delete-item fileid)
(binder-insert-item item next-index)
(binder-write-maybe)
(binder-sidebar-refresh)
(binder-sidebar-goto-item fileid))))
(defun binder-sidebar-shift-up (&optional n)
"Shift index position of item at point up N places in list."
(interactive "p")
(binder-sidebar-shift-down (- n)))
(defun binder-sidebar-jump-to-current ()
"Jump to current file in sidebar."
(interactive)
(binder-sidebar-goto-item binder--current-fileid))
(defun binder-sidebar-narrow-by-tag (tag)
"\\<binder-sidebar-mode-map>Filter sidebar items to include items with TAG.
To reset filtering call `binder-sidebar-refresh' (\\[binder-sidebar-refresh])."
(interactive
(list (completing-read
"Narrow items by tag: " (binder-get-tags)
nil t)))
(unless (or (string-empty-p tag) (member tag binder-narrow-tags))
(push tag binder-narrow-tags)
(binder-sidebar-refresh)))
(defun binder-sidebar-exclude-by-tag (tag)
"\\<binder-sidebar-mode-map>Filter sidebar items to exclude items with TAG.
To reset filtering call `binder-sidebar-refresh' (\\[binder-sidebar-refresh])."
(interactive
(list (completing-read
"Exclude items by tag: " (binder-get-tags)
nil t)))
(unless (or (string-empty-p tag) (member tag binder-exclude-tags))
(push tag binder-exclude-tags)
(binder-sidebar-refresh)))
(defun binder-sidebar-clear-filters ()
"Clear all sidebar tag filters."
(interactive)
(setq binder-narrow-tags nil
binder-exclude-tags nil)
(binder-sidebar-refresh)
(message "Sidebar filters cleared"))
(defun binder-sidebar-copy-filepath ()
"Put the current item filepath into the kill ring."
(interactive)
(let ((fileid (binder-sidebar-get-fileid)))
(kill-new fileid)
(message "%S" fileid)))
(defun binder-highlight-in-sidebar ()
"Highlight the current file in sidebar.
Added to `window-configuration-change-hook'."
(unless (or (minibuffer-window-active-p (selected-window))
(eq major-mode 'binder-sidebar-mode))
(setq binder--current-fileid (binder-get-buffer-fileid))
(binder-sidebar-refresh-window)))
(defun binder-sidebar-shrink-window ()
"Shrink the sidebar window horizontally.
Calls `shrink-window-horizontally' with `binder-sidebar-resize-window-step'."
(interactive)
(shrink-window-horizontally binder-sidebar-resize-window-step))
(defun binder-sidebar-enlarge-window ()
"Enlarge the sidebar window horizontally.
Calls `enlarge-window-horizontally' with `binder-sidebar-resize-window-step'."
(interactive)
(enlarge-window-horizontally binder-sidebar-resize-window-step))
(defun binder-sidebar-help (char)
"Provide interactive help prompt by CHAR."
(declare (interactive-only t))
(interactive
(list (read-char-choice "\
? = describe-mode, \
g = refresh, \
| = clear filters, \
q = quit-window, \
C-g = cancel: " '(?? ?g ?| ?q))))
(cl-case char
(?q (quit-window))
(?g (binder-sidebar-refresh))
(?| (binder-sidebar-clear-filters))
(?? (describe-mode))))
(defun binder-reveal-in-sidebar ()
"Reveal current file in binder sidebar."
(interactive)
(let ((filepath (or (buffer-file-name) default-directory)))
(select-window (binder-sidebar-create-window))
(if (file-equal-p filepath (binder-root))
(binder-sidebar-refresh)
(let ((fileid (binder-file-relative-to-root filepath)))
(setq binder--current-fileid fileid)
(unless (binder-get-item fileid)
(when (y-or-n-p (format "Add %s to binder? " fileid))
(binder-sidebar-add-file fileid)))
(binder-sidebar-refresh)
(binder-sidebar-goto-item fileid)))))
;;;###autoload
(defun binder-toggle-sidebar ()
"Toggle visibility of project sidebar window.
Unconditionally activates `binder-mode'."
(interactive)
(binder-mode)
(if (window-live-p (get-buffer-window binder-sidebar-buffer))
(delete-window (get-buffer-window binder-sidebar-buffer))
(binder-sidebar-create-window)
(when binder-sidebar-select-window
(select-window (get-buffer-window binder-sidebar-buffer)))))
(defvar binder-sidebar-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "?") #'binder-sidebar-help)
(define-key map (kbd "TAB") #'forward-button)
(define-key map (kbd "<backtab>") #'backward-button)
(define-key map (kbd "{") #'binder-sidebar-shrink-window)
(define-key map (kbd "}") #'binder-sidebar-enlarge-window)
(define-key map (kbd "g") #'binder-sidebar-refresh)
(define-key map (kbd "|") #'binder-sidebar-clear-filters)
(define-key map (kbd "j") #'binder-sidebar-jump-to-current)
(define-key map (kbd "C") #'binder-sidebar-change-directory)
(define-key map (kbd "n") #'next-line)
(define-key map (kbd "p") #'previous-line)
(define-key map (kbd "RET") #'binder-sidebar-find-file)
(define-key map (kbd "o") #'binder-sidebar-find-file-other-window)
(define-key map (kbd "s") #'binder-sidebar-save)
(define-key map [remap save-buffer] #'binder-sidebar-save)
(define-key map (kbd "m") #'binder-sidebar-mark)
(define-key map (kbd "u") #'binder-sidebar-unmark)
(define-key map (kbd "t") #'binder-sidebar-add-tag)
(define-key map (kbd "T") #'binder-sidebar-remove-tag)
(define-key map (kbd "#") #'binder-sidebar-toggle-tags)
(define-key map (kbd "U") #'binder-sidebar-unmark-all)
(define-key map (kbd "i") #'binder-sidebar-toggle-notes)
(define-key map (kbd "z") #'binder-sidebar-open-notes)
(define-key map (kbd "c") #'binder-sidebar-copy-filepath)
(define-key map (kbd "M-n") #'binder-sidebar-shift-down)
(define-key map (kbd "<M-down>") #'binder-sidebar-shift-down)
(define-key map (kbd "M-p") #'binder-sidebar-shift-up)
(define-key map (kbd "<M-up>") #'binder-sidebar-shift-up)
(define-key map (kbd "a") #'binder-sidebar-add-file)
(define-key map (kbd "A") #'binder-sidebar-add-all-files)
(define-key map (kbd "d") #'binder-sidebar-remove)
(define-key map (kbd "r") #'binder-sidebar-rename)
(define-key map (kbd "R") #'binder-sidebar-relocate)
(define-key map (kbd "E") #'binder-sidebar-toggle-file-extensions)
(define-key map (kbd "/") #'binder-sidebar-narrow-by-tag)
(define-key map (kbd "\\") #'binder-sidebar-exclude-by-tag)
(define-key map (kbd "M-RET") #'binder-sidebar-new-file)
map))
(define-derived-mode binder-sidebar-mode
special-mode "Binder Sidebar"
"Major mode for working with `binder' projects."
(setq indent-tabs-mode nil)
(face-remap-add-relative 'default 'binder-sidebar)
(add-hook 'post-command-hook #'binder-sidebar-sync-notes t t))
;;; Notes Major Mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defface binder-notes
'((t nil))
"Default base-level face for `binder-notes-mode' buffers.")
(defcustom binder-notes-buffer
"*Binder Notes*"
"Buffer name for Binder notes."
:type 'string
:safe 'stringp
:group 'binder-sidebar)
(defcustom binder-notes-display-alist
'((side . left)
(window-width . 40)
(slot . 1))
"Association list used to display binder notes buffer.
See `display-buffer-in-side-window' for example options."
:type 'alist
:group 'binder-sidebar)
(defcustom binder-notes-persistent-window
t
"When non-nil, notes will persist when calling `delete-other-windows'.
This marks `no-delete-other-windows' window parameter as non-nil.
Use `binder-toggle-notes' or `quit-window' to close notes."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-notes-keep-in-sync
nil
"If non-nil, moving point in binder sidebar updates notes.
Enabling this can be disconcerting, because notes are not
automatically saved."
:type 'boolean
:safe 'booleanp
:group 'binder-sidebar)
(defcustom binder-notes-mode-hook
'(visual-line-mode)
"Hook run after entering Binder Notes Mode."
:type 'hook
:options '(visual-line-mode))
(defun binder-notes-refresh ()
"Redraw the notes buffer."
(setq default-directory binder-project-directory)
(with-silent-modifications
(erase-buffer)
(insert (or (binder-get-item-prop binder--notes-fileid 'notes)
""))
(setq binder--notes-display
(binder-get-item-prop binder--notes-fileid 'display))
(setq header-line-format
(if binder--notes-fileid
(list (list :propertize (or binder--notes-display binder--notes-fileid)
'face 'bold)
" C-c C-c to commit; C-c C-q to quit")
"Nothing selected; C-c C-q to quit"))))
(defun binder-notes-refresh-window ()
"Call `binder-notes-refresh' if notes window is live."
(when (window-live-p (get-buffer-window binder-notes-buffer))
(with-current-buffer binder-notes-buffer
(binder-notes-refresh))))
(defun binder-notes-create-buffer ()
"Create the notes buffer."
(binder-ensure-in-project)
(with-current-buffer (get-buffer-create binder-notes-buffer)
(binder-notes-mode)
(binder-notes-refresh)
(current-buffer)))
(defun binder-notes-create-window ()
"Create the notes window."
(let ((display-buffer-mark-dedicated t))
(display-buffer-in-side-window
(binder-notes-create-buffer)
(append binder-notes-display-alist
(when binder-sidebar-persistent-window
(list '(window-parameters (no-delete-other-windows . t))))))))
(defun binder-show-notes (&optional fileid select)
"Show the notes for FILEID of the appropriate project item.
If argument SELECT is non-nil, select the notes window."
(binder-ensure-in-project)
(if fileid
(setq binder--notes-fileid fileid)
(let ((filepath (or (buffer-file-name) default-directory)))
(unless (file-equal-p filepath (binder-root))
(setq binder--notes-fileid (binder-file-relative-to-root filepath)))))
(if (window-live-p (get-buffer-window binder-notes-buffer))
(binder-notes-refresh-window)
(binder-notes-create-window))
(when select (select-window (get-buffer-window binder-notes-buffer))))
(defun binder-sidebar-open-notes ()
"Open notes for item at point and select the notes window."
(interactive)
(binder-show-notes (binder-sidebar-get-fileid) t))
(defun binder-toggle-notes ()
"Toggle visibility of binder notes window."
(interactive)
(if (window-live-p (get-buffer-window binder-notes-buffer))
(delete-window (get-buffer-window binder-notes-buffer))
(binder-show-notes)))
(defun binder-sidebar-toggle-notes ()
"Toggle visibility of binder notes window for item at point."
(interactive)
(if (window-live-p (get-buffer-window binder-notes-buffer))
(delete-window (get-buffer-window binder-notes-buffer))
(binder-show-notes (binder-sidebar-get-fileid))))
(defun binder-notes-save ()
"Save notes buffer content to project.
This command writes project data to disk."
(interactive)
(unless (derived-mode-p 'binder-notes-mode)
(user-error "Not in %S" 'binder-notes-mode))
(if (not (buffer-modified-p))
(message "(No changes need to be added to binder)")
(binder-set-item-prop binder--notes-fileid 'notes
(string-trim (buffer-substring-no-properties
(point-min) (point-max))))
(set-buffer-modified-p nil)
(binder-write)
(binder-sidebar-refresh-window)
(message "Saved notes for %s to binder"
(or binder--notes-display binder--notes-fileid))))
(defun binder-notes-save-and-quit-window ()
"Call `binder-notes-save' and quit the notes window."
(declare (interactive-only t))
(interactive)
(binder-notes-save)
(quit-window))
(defun binder-notes-expand-window ()
"Toggle the notes window from a side window to full window."
(declare (interactive-only t))
(interactive)
(unless (derived-mode-p 'binder-notes-mode)
(user-error "Not in %S" 'binder-notes-mode))
(if (window-parameter (selected-window) 'window-side)
(progn
(quit-window)
(pop-to-buffer (get-buffer-create binder-notes-buffer)))
(quit-window)
(binder-show-notes binder--notes-fileid t)))
(defun binder-sidebar-sync-notes ()
"Set the current notes to sidebar item at point."
(while-no-input
(redisplay)
(when binder-notes-keep-in-sync
(setq binder--notes-fileid (binder-sidebar-get-fileid))
(binder-notes-refresh-window))))
(defvar binder-notes-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") #'binder-notes-save-and-quit-window)
(define-key map [remap save-buffer] #'binder-notes-save)
(define-key map (kbd "C-c C-l") #'binder-notes-expand-window)
(define-key map (kbd "C-c C-q") #'quit-window)
(define-key map (kbd "C-c C-k") #'quit-window)
map)
"Mode map for `binder-notes-mode'.")
(define-derived-mode binder-notes-mode
text-mode "Binder Notes Mode"
"Major mode for editing `binder' notes."
(face-remap-add-relative 'default 'binder-notes)
(binder-notes-refresh))
(provide 'binder)
;;; binder.el ends here
;; Local Variables:
;; coding: utf-8
;; fill-column: 80
;; indent-tabs-mode: nil
;; require-final-newline: t
;; sentence-end-double-space: nil
;; End:
================================================
FILE: contrib/binder-theme.el
================================================
;; To install this theme, copy or symlink it to your `user-emacs-directory'.
(deftheme binder
"Binder theme, inspired by Scrivener.")
(custom-theme-set-faces
'binder
'(binder-sidebar
((default (:height 0.9))
(((background light)) (:background "#f1f0f6"))
(((background dark)) (:background "#33323f"))))
'(binder-notes
((default (:height 0.9))
(((background light)) (:background "#fefbe8"))
(((background dark)) (:background "#302c2c")))))
(provide-theme 'binder)
gitextract_gpx4e2f8/
├── .gitignore
├── LICENSE
├── Makefile
├── NEWS
├── README.md
├── binder-tutorial.el
├── binder.el
└── contrib/
└── binder-theme.el
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (113K chars).
[
{
"path": ".gitignore",
"chars": 59,
"preview": "*.elc\n*-autoloads.el\n*-pkg.el\n.dir-locals.el\ndir\ntutorial/\n"
},
{
"path": "LICENSE",
"chars": 35149,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "Makefile",
"chars": 1166,
"preview": ".POSIX:\nPROG\t\t= binder\nLISP_FILE\t= ${PROG}.el\nDEPS\t\t= seq package-lint\nNEWS_FILE\t= NEWS\nVERS\t\t= ${shell grep -oE -m1 'Ve"
},
{
"path": "NEWS",
"chars": 4542,
"preview": "* current\n\n- Use buttons in sidebar, allowing mouse interaction\n- Remove \"include\" and \"concat\" feature, this is better "
},
{
"path": "README.md",
"chars": 6785,
"preview": "## Binder has moved to https://codeberg.org/divyaranjan/binder/\n\nBinder\n======\n\n[ 2020-2024 Paul W"
},
{
"path": "binder.el",
"chars": 53824,
"preview": ";;; binder.el --- Global minor mode to facilitate multi-file writing projects -*- lexical-binding: t; -*-\n\n;; Copyright"
},
{
"path": "contrib/binder-theme.el",
"chars": 493,
"preview": ";; To install this theme, copy or symlink it to your `user-emacs-directory'.\n\n(deftheme binder\n \"Binder theme, inspired"
}
]
About this extraction
This page contains the full source code of the rnkn/binder GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (106.4 KB), approximately 25.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.