ido-completing-read-plus-4.13/ 0000755 0001750 0001750 00000000000 13514204422 016074 5 ustar dogsleg dogsleg ido-completing-read-plus-4.13/LICENSE 0000644 0001750 0001750 00000104513 13514204422 017105 0 ustar dogsleg dogsleg GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
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.
Copyright (C)
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 .
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:
Copyright (C)
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
.
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
.
ido-completing-read-plus-4.13/README.md 0000644 0001750 0001750 00000030101 13514204422 017346 0 ustar dogsleg dogsleg # ido-completing-read+ (formerly ido-ubiquitous) #
[](https://stable.melpa.org/#/ido-completing-read%2B)
[](https://gitter.im/DarwinAwardWinner/ido-ubiquitous?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://travis-ci.org/DarwinAwardWinner/ido-completing-read-plus)
[](https://coveralls.io/github/DarwinAwardWinner/ido-completing-read-plus?branch=master)
This package replaces stock emacs completion with ido completion
wherever it is possible to do so without breaking things (i.e. what
you were probably hoping for when you set `ido-everywhere` to `t`).
Get it from MELPA: https://stable.melpa.org/#/ido-completing-read+
## Version 4.0 changes ##
Long-time users should know that ido-completing-read+ version 4.0 is a
major update. The previously separate ido-ubiquitous package has been
merged into ido-completing-read+, which now provides all the features
of both packages. The distinction between "new" and "old" default
selection styles has been eliminated and replaced by a new variable
`ido-cr+-nil-def-alternate-behavior-list` (see [FAQ][1] for details),
and the override system has been accordingly simplified into just a
blacklist and a whitelist. If you have previously customized any
ido-ubiquitous options, be sure to check out
`M-x customize-group ido-completing-read+`
after updating to 4.0 and make sure the new settings are to your
liking.
The short-lived ido-describe-fns package has likewise been subsumed
into this one.
[1]: #why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection
# How to enable ido in as many places as possible #
If you are using this package, you probably want to enable ido
everywhere that it is possible to do so. Here are all the places to
enable ido that I'm aware of. (Note that most of these variables/modes
can also be set/enabled via `M-x customize-variable` if you prefer
that.)
## Ido itself ##
First, enable `ido-mode` and `ido-everywhere`.
```elisp
(ido-mode 1)
(ido-everywhere 1)
```
## ido-completing-read+ (this package) ##
Install this package [from MELPA](http://melpa.org/#/ido-completing-read+)
and then turn on `ido-ubiquitous-mode`:
```elisp
(require 'ido-completing-read+)
(ido-ubiquitous-mode 1)
```
## Smex ##
Smex allows you to use ido for completion of commands in M-x, with
enhancements like putting your most-used commands at the front of the
list. First install the [smex](https://github.com/nonsequitur/smex)
package, then follow the directions to load it and replace your normal
M-x key-binding with smex:
```elisp
(require 'smex) ; Not needed if you use package.el
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay
; when Smex is auto-initialized on its first run.
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
```
(These directions are the same ones given in the smex README file.)
## ido-yes-or-no ##
If you want to use ido for yes-or-no questions, even though it's
massive overkill, install my [ido-yes-or-no package from MELPA](http://melpa.org/#/ido-yes-or-no), and then enable the mode:
```elisp
(require 'ido-yes-or-no)
(ido-yes-or-no-mode 1)
```
## ido for `describe-face` and certain other commands ##
Some commands, such as `describe-face`, use `completing-read-multiple`
instead of `completing-read`. You can get ido completion for these
commands with `crm-custom-mode`, which replaces
`completing-read-multiple` with repeated calls to `completing-read`,
which would then use ido thanks to ido-ubiquitous-mode. First, install
the [crm-custom](https://github.com/DarwinAwardWinner/crm-custom)
package [from MELPA](http://melpa.org/#/crm-custom), then enable the
mode:
```elisp
(require 'crm-custom)
(crm-custom-mode 1)
```
Make sure to read and understand the FAQ entry below about the empty
entry at the beginning of the completion list before using this mode,
or using it will likely be very confusing.
## Packages with built-in ido support ##
Lastly, some packages already provide their own interfaces to ido, so
ido-completing-read+ specifically avoids interfering with these. If
you use any of the following packages, you need to enable ido for each
of them separately.
* [Magit](https://magit.vc/): `(setq magit-completing-read-function 'magit-ido-completing-read)`
* [Gnus](http://www.gnus.org/): `(setq gnus-completing-read-function 'gnus-ido-completing-read)`
* [ESS](https://ess.r-project.org/): `(setq ess-use-ido t)`
## icomplete-mode ##
For any case where ido cannot be used, there is another older mode
called `icomplete-mode` that integrates with standard emacs completion
and adds some ido-like behavior. It is built in to emacs, so no
installation is necessary. Just load the file and enable the mode:
```elisp
(require 'icomplete)
(icomplete-mode 1)
```
# Frequently asked questions #
## How does ido-ubiquitous-mode decide when to replace `completing-read`?
Why don't some commands use ido completion? ##
Emacs' `completing-read` is a complex function with many complex
features. Not all of these features are supported by ido, so it is
impossible to always replace `completing-read` with ido completion.
Trying to use ido when these features are requested can cause
confusing and unexpected behavior or even completely break the
completion system. So, ido-completing-read+ tries to get out of the
way whenever it detects that these features might be used by a given
call to `completing-read`. Furthermore, it's not always possible to
detect based on the arguments to `completing-read` whether such
ido-incompatible features are being used or not, so
ido-completing-read+ also comes with a blacklist of functions that are
known not to work with ido. You can inspect this blacklist using
`M-x describe-variable ido-cr+-function-blacklist`
If you want to know why a certain command isn't getting ido
completion, you can enable `ido-cr+-debug-mode` and then run the
command. There should then be a line in the `*Messages*` buffer that
explains the reason for disabling ido completion.
## Why does RET sometimes not select the first completion on the list?
Why is there an empty entry at the beginning of the completion list?
What happened to old-style default selection? ##
The simplest way to think about this is that if the command that
called `completing-read` didn't specify a default, then the default is
the empty string. In other words, `""` is the default default.
Previous versions of ido-ubiquitous-mode gave special consideration to
cases where a default value was not provided to `completing-read` and
the user pressed RET without entering any text. The expected behavior
is that `completing-read` should return the empty string in this case,
which indicates to the calling function that the user did not select
any completion. This conflicts with the standard ido behavior of
selecting the first available completion when pressing RET, and this
conflict was previously resolved by having two different modes that
differed in their handling of RET on an empty input. Now there is only
one mode, and the no-default case is handled by acting as if the empty
string was specified as the default, which more closely matches the
behavior of standard emacs completion. Since you, the user, have no
way of knowing how `completing-read` was called, you can tell when
this is occurring by watching for the appearance of an empty
completion at the front of the list. Compare:
If the command specifies apple as the default when calling
`completing-read`, the prompt will look like this, and pressing RET
will select "apple":
Pick a fruit: {apple | banana | cherry | date}
However, if the command does not specify any default, an extra empty
option is displayed before the first option, and pressing RET will
select this empty option and return "":
Pick a fruit: { | apple | banana | cherry | date}
To select "apple" instead, you must first press the right arrow key
once, or type an "a", before pressing RET.
However, some commands don't take this quirk of `completing-read` into
account and don't expect it to ever return an empty string when
`require-match` is non-nil. You can accommodate these functions by
adding them to `ido-cr+-nil-def-alternate-behavior-list`.
## How can I troubleshoot when ido-completing-read+ isn't doing what I want? ##
First, invoke the `ido-cr+-debug-mode` command. Then, run the command
or code that you are having trouble with, and when the completion
prompt appears, make a selection to complete the process. Then,
examine the Messages buffer, where ido-completing-read+ will explain
which mode of operation it selected and why. Based on this, you can
add an entry to `ido-cr+-function-blacklist`, or take some other
appropriate action.
Updates to ido-completing-read+ may include new blacklist entries, but
Emacs will not edit your override variables if you have already
customized them. So, if you have recently upgraded
ido-completing-read+, remember to invoke `ido-cr+-update-blacklist` to
add in any new overrides. By default, ido-completing-read+ will remind
you to do this whenever a new version adds to the blacklist. For more
information, see:
M-x describe-variable ido-cr+-auto-update-blacklist
## Where can I report bugs? ##
If you end up adding any blacklist entries, please report them at
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues so I can
incorporate them into the defaults for future versions. You can also
report any bugs you find in ido-completing-read+.
## I'm getting some weird warnings from ido-completing-read+ when Emacs starts. ##
I've gotten numerous reports about nonsensical warnings produced by
this package, such as "free variable" warnings about variables that
are most definitely properly declared, or warnings that only appear
when ido-completing-read+ is loaded after another unrelated package.
For many of these warnings, I've never been able to discover the cause
or consistently reproduce the warnings myself, and I've given up
trying to figure it out. Please don't report any new bugs about
variable warnings *unless* you can tell me how to consistently
reproduce them starting from `emacs -Q`. If you are an Emacs expert
who knows how to fix these warnings, please let me know.
You can see the bug reports about weird warnings
[here](https://github.com/DarwinAwardWinner/ido-ubiquitous/issues?utf8=%E2%9C%93&q=label%3Abizarre-unexplainable-scoping-issues+).
## What is the "bleeding-edge" branch? ##
All users should just use the master branch, or better yet, install
from MELPA. The bleeding-edge branch is where I test experimental and
unfinished features. Because ido-completing-read+ hooks deeply into
the bowels of Emacs, a bug in ido-completing-read+ could easily freeze
or crash Emacs entirely. Additionally, some bug only show up when
ido-completing-read+ is installed and compiled as a package. So I test
every new feature myself for some time on this branch before pushing
to the master branch. If you report a bug, I might develop a fix for
it on the bleeding edge branch and ask then you to try this branch.
Otherwise, normal users don't need to think about this branch.
## Running the tests
This package comes with a test suite. If you want to run it yourself,
first install the [cask](http://cask.readthedocs.io/en/latest/)
dependency manager. Then, from the package directory, run `cask
install` to install all the development dependencies, in
particular
[buttercup](https://github.com/jorgenschaefer/emacs-buttercup).
Finally, to run the tests, execute `cask exec buttercup -L .`. Please
run this test suite before submitting any pull requests, and note in
the pull request whether any of the tests fail.
ido-completing-read-plus-4.13/.travis.yml 0000644 0001750 0001750 00000002573 13514204422 020214 0 ustar dogsleg dogsleg language: generic
dist: trusty
sudo: false
env:
matrix:
- EMACS_VERSION=emacs-24.4
- EMACS_VERSION=emacs-24.5
- EMACS_VERSION=emacs-25.1
- EMACS_VERSION=emacs-25.2
- EMACS_VERSION=emacs-25.3
- EMACS_VERSION=emacs-26.1
- EMACS_VERSION=emacs-git-snapshot
- EMACS_VERSION=remacs-git-snapshot
matrix:
allow_failures:
- env: EMACS_VERSION=remacs-git-snapshot
- env: EMACS_VERSION=emacs-git-snapshot
before_script:
# Install evm
- git clone https://github.com/rejeep/evm.git ~/.evm
- export PATH="$HOME/.evm/bin:$PATH"
- evm config path /tmp
- evm list
# use this version of emacs for tests
- evm install "${EMACS_VERSION}-travis" --use --skip
- evm list
- emacs --version
# Install cask
- curl -fsSkL https://raw.github.com/cask/cask/master/go | python
- export PATH="$HOME/.cask/bin:$PATH"
# Fix cask (See https://github.com/cask/cask/issues/399#issuecomment-331640427)
- perl -ibak -lape 's{#!/usr/bin/env python}{#!/usr/bin/python}' "$(which cask)"
# Check that cask is finding the right emacs
- cask emacs --version
# Install elisp dependencies
- cask install
script:
- make compile
# Don't send redundant coverage info
- UNDERCOVER_CONFIG='((:send-report nil))' make test
# For some reason emacs-git-snapshot hangs forever on this step
- if [ "$EMACS_VERSION" != emacs-git-snapshot ]; then make test-with-flx; fi
ido-completing-read-plus-4.13/ChangeLog 0000644 0001750 0001750 00000026442 13514204422 017656 0 ustar dogsleg dogsleg 2019-07-18 Ryan C. Thompson
* ido-completing-read+.el (ido-completing-read+): Disable
workaround for Emacs bug #27807 in Emacs 27.1 and higher
2018-06-27 Ryan C. Thompson
* ido-completing-read+.el (ido-cr+-function-blacklist): Disable
ido completion in org-set-tags.
2018-04-24 Ryan C. Thompson
* ido-completing-read+.el (ido-cr+-update-dynamic-collection):
Prevent unintended re-sorting of the completion list after dynamic
updates.
2018-04-21 Ryan C. Thompson
* ido-completing-read+.el (ido-cr+-update-dynamic-collection): Fix
accidental creation of circular lists, which could lead to errors
or indefinite hangs (#151)
2018-02-16 Ryan C. Thompson
* ido-completing-read+.el: Add a temporary fix for a conflict with
flx-ido in Emacs 26.
2017-08-19 Ryan C. Thompson
* ido-completing-read+.el (ido-cr+-maybe-update-blacklist): Fix a
bug in blacklist update functionality
2017-08-13 Ryan C. Thompson
* ido-completing-read+.el (ido-cr+-apply-restrictions): Make
"ido-restrict-to-matches" work with dynamic completion tables.
(ido-cr+-update-dynamic-collection): Make behavior on dynamic
completion tables more deterministic. The set of offered
completions now only depends on the current input, not the precise
sequence of insertions and deletions the user used to end up
there. ido-completing-read+ now depends on the memoize package.
2017-08-07 Ryan C. Thompson
* ido-completing-read+.el: Declare missing dependency on "s"
pacakge.
(ido-completing-read+): Allow DEF to be a string (or list of
strings).
(ido-cr+-nil-def-alternate-behavior-list): Support commands that
behave badly when "require-match" is non-nil and "def" is nil.
(ido-select-text@ido-cr+-fix-require-match): If the collection is
dynamic, use "try-completion" as an alternative way to check for a
match.
2017-07-24 Ryan C. Thompson
* ido-completing-read+.el: Further improvements to handling of
dynamic completion tables. Among other things, flex matching is
now supported for dynamic tables, and idle timers are used to
avoid recalculating the list of completions between every
keystroke.
2017-07-08 Ryan C. Thompson
* ido-completing-read+.el: Internal change: switch to the new
"nadvice" system for all function advice.
2017-07-05 Ryan C. Thompson
* ido-completing-read+.el (ido-completing-read+): Massive
refactor. The "overrides" system has been completely reworked.
There is no longer a distinction between "old" and "new" default
styles; commands and functions are no longer treated differently;
and ido-cr+ is now enabled for dynamic completion tables. Users
should read the FAQ, which explains the minor user-visible
changes.
* ido-ubiquitous.el: Refactor entire package into ido-cr+. The
current ido-ubiquitous.el is just a stub that loads ido-cr+ and
displays a deprecation warning.
2017-06-01 Ryan C. Thompson
* ido-completing-read+.el (ido-completing-read+): Don't use ido if
the collection is empty, since doing so would be pointless.
* ido-ubiquitous.el (ido-ubiquitous-default-command-overrides):
Update some overrides
* ido-describe-fns.el (ido-descfns-maybe-load-prefixes): Add
support for the auto-loading feature of describe-variable and
similar commands.
2017-03-13 Ryan C. Thompson
* ido-ubiquitous.el (ido-cr+--explain-fallback): Fix
ido-ubiquitous-debug-mode messages.
2016-06-23 Ryan C. Thompson
* ido-ubiquitous.el (ido-ubiquitous-default-command-overrides):
Remove the recently-added overrides for "describe-function" and
"describe-variable". Ido completion interferes with a new feature
of the completion for these functions, so it should be disabled
unless ido can be made compatible with this feature.
2016-06-18 Ryan C. Thompson
* ido-ubiquitous.el (completing-read-ido-ubiquitous): Fix an edge
case where COLLECTION is a function and PREDICATE is non-nil. This
edge case caused errors in "describe-function" and
"describe-variable" in Emacs 25.1.
(completing-read-ido-ubiquitous): Make error handling more robust.
In addition to falling back to normal completion on a specific set
of expected errors, ido-ubiquitous now falls back on *any* error
encountered in the body of "completing-read-ido-ubiquitous".
(ido-ubiquitous-default-command-overrides): Add override for
"describe-function" and "describe-variable", which now require
them in Emacs 25.1.
2016-02-20 Ryan C. Thompson
* ido-completing-read+.el (ido-select-text): Eliminate another
compiler warning
2016-02-17 Ryan C. Thompson
* test/ido-ubiquitous-test.el: Significant refactoring of awkward
testing code. Tests should now be more robust.
* ido-completing-read+.el (ido-select-text): Fix an edge case in
ido-select-text: when require-match and default are both non-nil,
it should be impossible to return an empty string.
(ido-cr+-fallback-function): Don't allow ido-ubiquitous to be a
fallback for ido-cr+.
2016-01-29 Ryan C. Thompson
* ido-ubiquitous.el (ido-ubiquitous--maybe-update-overrides):
Change default auto-update setting to notify. If the user has
customized overrides and new ones are added upstream, it will nag
them until they choose to explicitly enable or disable
auto-updating.
2016-01-16 Rasmus
* ido-ubiquitous.el (ido-ubiquitous-update-overrides): Remove
dependency on s.el.
2015-11-22 Ryan C. Thompson
* ido-ubiquitous.el (ido-ubiquitous--maybe-update-overrides):
Allow ido-ubiquitous to automatically add new overrides.
2015-11-21 Ryan C. Thompson
* ido-ubiquitous.el: Fix up dependency declarations and require
statements (including a pull request by Steve Purcell)
* ido-completing-read+.el (ido-select-text): Fix C-j behavior when
require-match is enabled
2015-10-04 Ryan C. Thompson
* ido-ubiquitous.el: Add override for etags-select
2015-06-19 Ryan C. Thompson
* ido-ubiquitous.el: Fix some byte-compile warnings in autoloads
by also autoloading the associated variable declarations
2015-06-18 Ryan C. Thompson
* ido-ubiquitous.el: Ignore and warn about invalid overrides
instead of crashing
* ido-completing-read+.el: Fix some variable declaration warnings
* ido-ubiquitous.el (ido-ubiquitous-default-command-overrides):
Add override for "where-is" command
2015-05-28 Ryan C. Thompson
* ido-ubiquitous.el (ido-ubiquitous-version): Fix a typo in the previous version
2015-04-23 Ryan C. Thompson
* ido-completing-read+.el: Fix obsolete reference to "choices"
instead of "collection"
2015-04-08 Ryan C. Thompson
* ido-ubiquitous.el: Major refactor. Split into two packages:
ido-completing-read+.el and ido-ubiquitous.el that depends on it.
Additionally, some of the customization variables for
ido-ubiquitous have been changed for increased flexibility in
configuration, and the internals have been rearchitected
significantly.
2015-01-25 Ryan C. Thompson
* ido-ubiquitous: Fix indentation issues
(https://github.com/DarwinAwardWinner/ido-ubiquitous/pull/62)
2014-09-04 Ryan C. Thompson
* ido-ubiquitous: Enable fallbacks to non-ido-completion using C-f
and C-b
2014-05-26 Ryan C. Thompson
* ido-ubiquitous: Disable in tmm when called as a function as well
as a command
2014-03-27 Ryan C. Thompson
* ido-ubiquitous: Add override for "*-theme" functions
2014-03-24 Ryan C. Thompson
* ido-ubiquitous: Fix a bug related to
"ido-ubiquitous-allow-on-functional-collection"
(#46)
2014-02-25 Ryan C. Thompson
* ido-ubiquitous: Disable in tmm-menubar
2013-11-19 Ryan C. Thompson
* ido-ubiquitous: Add new custom variable
"ido-ubiquitous-allow-on-functional-collection"
2013-10-02 Ryan C. Thompson
* ido-ubiquitous: Enable in "read-char-by-name"
2013-09-27 Ryan C. Thompson
* ido-ubiquitous: Disable in org and magit since they already
support ido
2013-09-26 Ryan C. Thompson
* ido-ubiquitous: Make ido-ubiquitous work with Emacs trunk
(pre-24.4)
* ido-ubiquitous: Fix a few minor and unlikely-to-ever-occur bugs
* ido-ubiquitous: Replace collection function whitelist with
overrides (overrides can now force ido completion when collection
is a function)
2013-09-23 Ryan C. Thompson
* ido-ubiquitous: Implement collection function whitelist
* ido-ubiquitous: Implement collection size limit for ido
completion
2013-09-17 Ryan C. Thompson
* ido-ubiquitous: Eliminate use of "macroexp--backtrace", which
doesn't exist in Emacs 24.2.
2013-09-11 Ryan C. Thompson
* ido-ubiquitous: Fix handling of collection being a function
(issues #23 and #25).
2013-09-10 Ryan C. Thompson
* ido-ubiquitous: Fix the issue where `called-interactively-p'
always returns false
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/24
2013-09-05 Ryan C. Thompson
* ido-ubiquitous: Ido-ubiquitous now works better with interactive
commands. Specifically, it now works when the completion happens
inside the "interactive" form of the command instead of the
function body.
* ido-ubiquitous: Functions and commands that need non-standard
behavior are now controlled through the variables
"ido-ubiquitous-command-overrides" and
"ido-ubiquitous-function-overrides".
* ido-ubiquitous: Major rewrite of a significant portions of
ido-ubiquitous.
2013-05-31 Ryan C. Thompson
* ido-ubiquitous: Officially drop support for Emacs 23 and lower.
ido-ubiquitous now uses the `completing-read-function' variable
instead of advising `completing-read'.
* ido-ubiquitous: Make ido-ubiquitous work more reliably in
interactive commands.
* ido-ubiquitous: Avoid spurious warning when loaded before ido.
* ido-ubiquitous: Disable ido when completion-extra-properties is
non-nil
* ido-ubiquitous: The interface for setting old-style completion
compatibility has changed. If you have customized these settings,
you should review them after upgrading.
2012-09-07 Ryan C. Thompson
* ido-ubiquitous: Restore compatibility with Emacs 23 and earlier
* ido-ubiquitous: Work around an ido bug where providing both an
initial input and a default would break things
* ido-ubiquitous: Most modifications to ido behavior are now
activated only when ido is acting as a completing-read
replacement, and not when it is used directly. This shoud prevent
ido-ubiquitous from interfering with normal usage of ido.
* ido-ubiquitous: Add Custom interface for compatibility
exceptions.
2012-09-03 Ryan C. Thompson
* ido-ubiquitous: New implementation: Switch from defining advice
on "completing-read" to setting "completing-read-function"
ido-completing-read-plus-4.13/ido-ubiquitous.el 0000644 0001750 0001750 00000007670 13514204422 021412 0 ustar dogsleg dogsleg ;;; ido-ubiquitous.el --- Use ido (nearly) everywhere. -*- lexical-binding: t -*-
;; Copyright (C) 2011-2017 Ryan C. Thompson
;; Author: Ryan C. Thompson
;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
;; Version: 4.13
;; Created: 2011-09-01
;; Keywords: convenience, completion, ido
;; EmacsWiki: InteractivelyDoThings
;; Package-Requires: ((ido-completing-read+ "4.13") (cl-lib "0.5"))
;; Filename: ido-ubiquitous.el
;; This file is NOT part of GNU Emacs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;; Previously a separate package, ido-ubiquitous has now been subsumed
;; into ido-completing-read+. You should update your config to install that instead.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see .
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(defconst ido-ubiquitous-version "4.13"
"Currently running version of ido-ubiquitous.
Note that when you update ido-ubiquitous, this variable may not
be updated until you restart Emacs.")
(require 'ido-completing-read+)
(display-warning 'ido-ubiquitous "The ido-ubiquitous package is now redundant. All functionality, including ido-ubiquitous-mode, has been merged into the ido-completing-read+ package. You should replace ido-ubiquitous with ido-completing-read+ in your Emacs config. For more information, see:
https://github.com/DarwinAwardWinner/ido-ubiquitous#version-40-changes")
(define-obsolete-function-alias 'completing-read-ido-ubiquitous 'ido-completing-read+
"ido-completing-read+ 4.0")
(define-obsolete-function-alias 'ido-ubiquitous-update-overrides 'ido-cr+-update-blacklist
"ido-completing-read+ 4.0")
(define-obsolete-function-alias 'ido-ubiquitous--maybe-update-overrides 'ido-cr+-maybe-update-blacklist
"ido-completing-read+ 4.0")
(define-obsolete-variable-alias 'ido-ubiquitous-auto-update-overrides 'ido-cr+-auto-update-blacklist
"ido-completing-read+ 4.0")
(make-obsolete-variable
'ido-ubiquitous-default-state
"For the new variables to control which commands have ido completion, see `ido-cr+-function-blacklist' and `ido-cr+-function-whitelist'. For information on what happened to \"old-style\" default selection, See the FAQ."
"ido-completing-read+ 4.0")
(make-obsolete-variable
'ido-ubiquitous-command-overrides
"For the new variables to control which commands have ido completion, see `ido-cr+-function-blacklist' and `ido-cr+-function-whitelist'. For information on what happened to \"old-style\" default selection, See the FAQ."
"ido-completing-read+ 4.0")
(make-obsolete-variable
'ido-ubiquitous-function-overrides
"For the new variables to control which commands have ido completion, see `ido-cr+-function-blacklist' and `ido-cr+-function-whitelist'. For information on what happened to \"old-style\" default selection, See the FAQ."
"ido-completing-read+ 4.0")
(make-obsolete-variable
'ido-ubiquitous-allow-on-functional-collection
"Ido-cr+ now works with most dynamic completion tables (i.e. \"functional collections\"), so this variable is no longer necessary. If a specific command uses a dynamic completion table that conflicts with ido-cr+, add it to `ido-cr+-function-blacklist' instead."
"ido-completing-read+ 4.0")
(provide 'ido-ubiquitous)
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
;;; ido-ubiquitous.el ends here
ido-completing-read-plus-4.13/tests/ 0000755 0001750 0001750 00000000000 13514204422 017236 5 ustar dogsleg dogsleg ido-completing-read-plus-4.13/tests/setup-undercover.el 0000644 0001750 0001750 00000000115 13514204422 023067 0 ustar dogsleg dogsleg (require 'undercover)
(undercover "*.el"
(:exclude "test-*.el"))
ido-completing-read-plus-4.13/tests/test-ido-completing-read+.el 0000644 0001750 0001750 00000114535 13514204422 024444 0 ustar dogsleg dogsleg ;;; -*- lexical-binding: t -*-
(require 'ido)
(require 'minibuf-eldef)
(require 'ido-completing-read+)
(require 'buttercup)
(require 'cl-lib)
(require 'with-simulated-input)
;; Note: Currently unused, but potentially useful in the future
(defun ido-cr+-maybe-chop (items elem)
"Like `ido-chop', but a no-op if ELEM is not in ITEMS.
Normal `ido-chop' hangs infinitely in this case."
(cl-loop
with new-tail = ()
for remaining on items
for next = (car remaining)
if (equal next elem)
return (nconc remaining new-tail)
else collect next into new-tail
finally return items))
(defun collection-as-function (collection)
"Return a function equivalent to COLLECTION.
The returned function will work equivalently to COLLECTION when
passed to `all-completions' and `try-completion'."
(completion-table-dynamic (lambda (string) (all-completions string collection))))
(defun shadow-var (var &optional temp-value)
"Shadow the value of VAR.
This will push the current value of VAR to VAR's
`shadowed-values' property, and then set it to TEMP-VALUE. To
reverse this process, call `unshadow-var' on VAR. Vars can
be shadowed recursively, and must be unshadowed once for each
shadowing in order to restore the original value. You can think
of shadowing as dynamic binding with `let', but with manual
control over when bindings start and end.
If VAR is a Custom variable (see `custom-variable-p'), it will be
set using `customize-set-variable', and if TEMP-VALUE is nil it
will be replaces with VAR's standard value.
Other variables will be set with `set-default', and a TEMP-VALUE
of nil will not be treated specially.
`shadow-var' only works on variables declared as special (i.e.
using `defvar' or similar). It will not work on lexically bound
variables."
(unless (special-variable-p var)
(error "Cannot shadow lexical var `%s'" var))
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(temp-value (or temp-value
(and use-custom
(eval (car (get var 'standard-value)))))))
;; Push the current value on the stack
(push (symbol-value var) (get var 'shadowed-values))
(funcall setter var temp-value)))
(defun var-shadowed-p (var)
"Return non-nil if VAR is shadowed by `shadow-var'."
;; We don't actually want to return that list if it's non-nil.
(and (get var 'shadowed-values) t))
(defun unshadow-var (var)
"Reverse the last call to `shadow-var' on VAR."
(if (var-shadowed-p var)
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(value (pop (get var 'shadowed-values))))
(funcall setter var value))
(error "Var is not shadowed: %s" var)))
(defun fully-unshadow-var (var)
"Reverse *all* calls to `shadow-var' on VAR."
(when (var-shadowed-p var)
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(value (car (last (get var 'shadowed-values)))))
(put var 'shadowed-values nil)
(funcall setter var value))))
(defun fully-unshadow-all-vars (&optional vars)
"Reverse *all* calls to `shadow-var' on VARS.
If VARS is nil, unshadow *all* variables."
(if vars
(mapc #'fully-unshadow-var vars)
(mapatoms #'fully-unshadow-var))
nil)
(defmacro shadow-vars (varlist)
"Shadow a list of vars with new values.
VARLIST describes the variables to be shadowed with the same
syntax as `let'.
See `shadow-var'."
(declare (indent 0))
(cl-loop
with var = nil
with value = nil
for binding in varlist
if (symbolp binding)
do (setq var binding
value nil)
else
do (setq var (car binding)
value (cadr binding))
collect `(shadow-var ',var ,value) into exprs
finally return `(progn ,@exprs)))
(defmacro unshadow-vars (vars)
"Un-shadow a list of VARS.
This is a macro for consistency with `shadow-vars', but it will
also accept a quoted list for the sake of convenience."
(declare (indent 0))
(when (eq (car vars) 'quote)
(setq vars (eval vars)))
`(mapc #'unshadow-var ',vars))
(defmacro with-temp-info-buffer (&rest body)
"Create a temporary info buffer and exeluate BODY forms there."
(declare (indent 0))
`(let ((temp-bufname (generate-new-buffer-name " *temp-info*")))
(unwind-protect
(save-excursion
(info nil (generate-new-buffer-name " *temp-info*"))
,@body)
(when (get-buffer temp-bufname)
(kill-buffer temp-bufname)))))
(describe "Within the `ido-completing-read+' package"
;; Reset all of these variables to their standard values before each
;; test, saving the previous values for later restoration.
(before-each
(shadow-vars
((ido-mode t)
(ido-ubiquitous-mode t)
(ido-cr+-debug-mode t)
ido-cr+-auto-update-blacklist
ido-cr+-fallback-function
ido-cr+-max-items
ido-cr+-function-blacklist
ido-cr+-function-whitelist
ido-cr+-nil-def-alternate-behavior-list
ido-cr+-replace-completely
ido-confirm-unique-completion
ido-enable-flex-matching
ido-enable-dot-prefix
(minibuffer-electric-default-mode t)))
;; Suppress all messages during tests
(spy-on 'message))
;; Restore the saved values after each test
(after-each
(fully-unshadow-all-vars))
(describe "the `ido-completing-read+' function"
(it "should complete with a matching item on RET"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "green"))
(it "should complete with the first match when multiple matches are available"
(expect
(with-simulated-input "b RET"
(ido-completing-read+ "Prompt: " '("brown" "blue" "yellow" "green")))
:to-equal "brown"))
(it "should allow and to cycle completions, with wrap-around"
(expect
(with-simulated-input "b RET"
(ido-completing-read+ "Prompt: " '("brown" "blue" "yellow" "green")))
:to-equal
"blue"))
(it "should return \"\" when RET or C-j is pressed on an empty input even when REQUIRE-MATCH is non-nil"
;; No REQUIRE-MATCH
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "blue")
(expect
(with-simulated-input "C-j"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "")
;; Again, with REQUIRE-MATCH
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t))
:to-equal "")
(expect
(with-simulated-input "C-j"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t))
:to-equal ""))
(it "should work with `minibuffer-electric-default-mode'"
(let ((eldef-was-showing nil))
;; No REQUIRE-MATCH, so electric default should not show
(with-simulated-input
'("blu DEL DEL DEL"
(setq eldef-was-showing minibuf-eldef-showing-default-in-prompt)
"RET")
(ido-completing-read+ "Prompt (default green): " '("blue" "yellow" "green")))
(expect eldef-was-showing :not :to-be-truthy)
;; With REQUIRE-MATCH, so electric default should show
(with-simulated-input
'("blu DEL DEL DEL"
(setq eldef-was-showing minibuf-eldef-showing-default-in-prompt)
"RET")
(ido-completing-read+ "Prompt (default green): " '("blue" "yellow" "green") nil t))
(expect eldef-was-showing :to-be-truthy)))
(it "should accept all the same forms of DEF as `completing-read-default'"
;; DEF in COLLECTION
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil nil nil "green"))
:to-equal "green")
;; Same, with REQUIRE-MATCH
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t nil nil "green"))
:to-equal "green")
;; DEF not in COLLECTION
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil nil nil "brown"))
:to-equal "brown")
;; Same, with REQUIRE-MATCH
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t nil nil "brown"))
:to-equal "brown")
;; List DEF, partially in COLLECTION
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t nil nil '("brown" "green")))
:to-equal "brown"))
(it "should work with INITIAL-INPUT"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr"))
:to-equal "green"))
(it "should properly handle a cons INITIAL-INPUT"
(expect
(with-simulated-input "ee RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil (cons "gr" 2)))
:to-equal "green"))
(it "should properly handle both INITIAL-INPUT and DEF at the same time"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr" nil "blue"))
:to-equal "green")
(expect
(with-simulated-input "DEL DEL RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr" nil "blue"))
:to-equal "blue"))
(it "should work when COLLECTION is a function"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " (collection-as-function '("blue" "yellow" "green"))))
:to-equal "green"))
(it "should fall back when COLLECTION is empty"
(spy-on 'ido-completing-read :and-call-through)
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " nil))
:to-equal "g")
(expect 'ido-completing-read :not :to-have-been-called))
(it "should replace `ido-completing-read' when `ido-cr+-replace-completely' is non-nil"
(customize-set-variable 'ido-cr+-replace-completely t)
(spy-on 'ido-completing-read+ :and-call-through)
(expect
(with-simulated-input "g RET"
(ido-completing-read "Prompt: " '("blue" "yellow" "green")))
:to-equal "green")
(expect 'ido-completing-read+ :to-have-been-called))
(describe "when `ido-cr+-max-items' is set"
(it "should not trigger a fallback for small collections"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "green"))
(it "should trigger a fallback for large collections"
(expect
;; With max-items negative, all collections are considered "too
;; large"
(let ((ido-cr+-max-items -1))
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green"))))
:to-equal "g")))
(describe "when REQUIRE-MATCH is non-nil"
(it "should still allow exiting with an empty string if DEF is nil"
(expect
(with-simulated-input "C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-equal ""))
;; "C-j" should NOT be allowed to return an empty string if
;; require-match and default are both non-nil.
(it "should not alow exiting with an empty string if DEF is non-nil"
(expect
(with-simulated-input "C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow"))
:to-throw))
(it "shouldn't allow C-j to select an ambiguous match"
(expect
(with-simulated-input "b C-j C-j C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-throw)
;; First press of C-j should complete to "blue" after the
;; first b, but then get stuck on the choice for the second b.
(expect
(with-simulated-input "b C-j b C-j C-j C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow" "green") nil t))
:to-throw))
(it "should allow exiting with an unambiguous match"
(expect
(with-simulated-input "b C-j b C-j e C-j C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow" "green") nil t))
:to-equal "blueberry")
;; The "C-j" should complete to "bluegrass" and return, because
;; `ido-confirm-unique-completion is nil.
(expect
(with-simulated-input "b l u e g C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-equal "bluegrass"))
(it "should require an extra C-j to exit when `ido-confirm-unique-completion' is non-nil"
(setq ido-confirm-unique-completion t)
;; Now the first "C-j" should complete to "bluegrass" but should
;; not return.
(expect
(with-simulated-input "b l u e g C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-throw)
;; The first "C-j" should complete to "bluegrass", and the second
;; should return.
(expect
(with-simulated-input "b l u e g C-j C-j"
(ido-completing-read+
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-equal "bluegrass"))
;; Finally, a test for the expected wrong behavior without
;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
;; to fail as a signal that the workaround can be phased out.
(it "should return a non-match when ordinary `ido-completing-read' is used"
(expect
(with-simulated-input "b C-j"
(ido-completing-read
"Prompt: "
'("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
:to-equal "b")))
(describe "when INHERIT-INPUT-METHOD is non-nil"
(before-each
(spy-on 'ido-completing-read :and-call-through))
(it "should not fall back if `current-input-method' is nil"
(expect
(let ((current-input-method nil))
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil nil nil nil t))
:to-equal "green"))
(expect 'ido-completing-read :to-have-been-called))
(it "should fall back if `current-input-method' is non-nil"
(expect
(let ((current-input-method 'ucs))
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil nil nil nil t))
:to-equal "green"))
(expect 'ido-completing-read :not :to-have-been-called)))
(describe "with manual fallback shortcuts"
(it "should not fall back when C-b or C-f is used in the middle of the input"
(expect
;; C-b/f not at beginning/end of input should not fall back
(with-simulated-input "g C-b C-f RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "green"))
(it "should fall back on C-f at end of input"
(expect
;; C-f at end of input should fall back
(with-simulated-input "g C-f RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "g"))
(it "should not fall back from repeated C-b that hits the start of input"
(expect
;; Repeated C-b should not fall back
(with-simulated-input "g C-b C-b C-b C-b RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "green"))
(it "should fall back on C-b at beginning of input (if previous action was not C-b)"
(expect
;; C-b at beginning of line should fall back (if previous action
;; was not also C-b)
(with-simulated-input "g C-b x DEL C-b RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
:to-equal "g")))
(describe "with a workaround for an bug with non-nil `ido-enable-dot-prefix'"
;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26997
;; for more information on this bug.
(before-each
(setq ido-enable-dot-prefix t))
(it "should not throw an error when \"\" is in the collection"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Pick: " '("" "aaa" "aab" "aac")))
:to-equal "")
(expect
(with-simulated-input "a a b RET"
(ido-completing-read+ "Pick: " '("" "aaa" "aab" "aac")))
:to-equal "aab")))
(describe "with dynamic collections"
(before-all
(setq my-dynamic-collection
(completion-table-dynamic
(lambda (text)
(cond
;; Sub-completions for "hello"
((s-prefix-p "hello" text)
'("hello" "hello-world" "hello-everyone" "hello-universe"))
;; Sub-completions for "goodbye"
((s-prefix-p "goodbye" text)
'("goodbye" "goodbye-world" "goodbye-everyone" "goodbye-universe"))
;; General completions
(t
'("hello" "goodbye" "helicopter" "helium" "goodness" "goodwill")))))))
(after-all
(setq my-dynamic-collection nil))
(before-each
(setq ido-enable-flex-matching t
ido-confirm-unique-completion nil)
(spy-on 'ido-cr+-update-dynamic-collection
:and-call-through))
(it "should allow selection of dynamically-added completions"
(expect
(with-simulated-input "hello- RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal "hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should allow ido flex-matching of dynamically-added completions"
(expect
(with-simulated-input "hello-ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when pressing TAB"
(expect
(with-simulated-input "h TAB -ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when idle"
(expect
(with-simulated-input
'("h"
(wsi-simulate-idle-time (1+ ido-cr+-dynamic-update-idle-time))
"-ld RET")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when there is only one match remaining"
(expect
(with-simulated-input "hell-ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should not exit with a unique match if new matches are dynamically added"
(expect
(with-simulated-input '("hell TAB -ld RET")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should exit with a match that is still unique after dynamic updating"
(expect
(with-simulated-input '("helic TAB")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"helicopter")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should suppress errors raised by dynamic completion updates"
(let ((collection
(completion-table-dynamic
(lambda (text)
(cond
((equal text "")
'("hello" "goodbye" "helicopter" "helium" "goodness" "goodwill"))
(t (error "This collection throws an error on a nonempty prefix"))))))
;; The test framework uses the debugger to catch error
;; stack traces, but we want to run this code as if it
;; was not being debugged.
(debug-on-error nil))
(expect
(with-simulated-input '("hell TAB RET")
(ido-completing-read+ "Say something: " collection))
:to-equal
"hello")))
(it "should respect `ido-restrict-to-matches' when doing dynamic updates"
(assume (version<= "25" emacs-version))
(let ((collection
(list "aaa-ddd-ggg" "aaa-eee-ggg" "aaa-fff-ggg"
"bbb-ddd-ggg" "bbb-eee-ggg" "bbb-fff-ggg"
"ccc-ddd-ggg" "ccc-eee-ggg" "ccc-fff-ggg"
"aaa-ddd-hhh" "aaa-eee-hhh" "aaa-fff-hhh"
"bbb-ddd-hhh" "bbb-eee-hhh" "bbb-fff-hhh"
"ccc-ddd-hhh" "ccc-eee-hhh" "ccc-fff-hhh"
"aaa-ddd-iii" "aaa-eee-iii" "aaa-fff-iii"
"bbb-ddd-iii" "bbb-eee-iii" "bbb-fff-iii"
"ccc-ddd-iii" "ccc-eee-iii" "ccc-fff-iii")))
;; Test the internal function
(expect
(ido-cr+-apply-restrictions
collection
(list (cons nil "bbb")
(cons nil "eee")))
:to-equal '("bbb-eee-ggg" "bbb-eee-hhh" "bbb-eee-iii"))
;; First verify it without a dynamic collection
(expect
(with-simulated-input "eee C-SPC bbb C-SPC ggg RET"
(ido-completing-read+
"Pick: " collection nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg")
(expect
(with-simulated-input "eee C-SPC aaa C-u C-SPC ccc C-u C-SPC ggg RET"
(ido-completing-read+
"Pick: " collection nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg")
;; Now test the same with a dynamic collection
(expect
(with-simulated-input "eee C-SPC bbb C-SPC ggg RET"
(ido-completing-read+
"Pick: " (collection-as-function collection) nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg")
(expect
(with-simulated-input "eee C-SPC aaa C-u C-SPC ccc C-u C-SPC ggg RET"
(ido-completing-read+
"Pick: " (collection-as-function collection) nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg"))))
(describe "with unusual inputs"
(it "should accept a COLLECTION of symbols"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '(blue yellow green)))
:to-equal "green"))
(it "should accept a mix of strings and symbols in COLLECTION"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " '(blue "yellow" green)))
:to-equal "green"))
(it "should accept symbols in DEF"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " '("blue" "yellow" "brown") nil t nil nil '(brown "green")))
:to-equal "brown"))
(it "should accept an alist COLLECTION"
(expect
(with-simulated-input "RET"
(ido-completing-read+
"Prompt: "
'(("blue" . blue-value)
("yellow" . yellow-value)
(green . green-value))
nil nil nil nil "green"))
:to-equal "green"))
(it "should accept a hash table COLLECTION"
(expect
(with-simulated-input "RET"
(let ((collection (make-hash-table)))
(puthash "blue" 'blue-value collection)
(puthash "yellow" 'yellow-value collection)
(puthash 'green 'green-value collection)
(ido-completing-read+ "Prompt: " collection nil nil nil nil "green")))
:to-equal "green"))
(it "should accept an obarray COLLECTION"
(expect
(with-simulated-input "forward-char RET"
(ido-completing-read+ "Prompt: " obarray #'commandp
t nil nil "backward-char"))
:to-equal "forward-char"))))
(describe "ido-ubiquitous-mode"
;; Set up a test command that calls `completing-read'
(before-all
(setf (symbol-function 'test-command)
(lambda ()
(interactive)
(completing-read "Prompt: " '("blue" "yellow" "green")))))
;; Delete the test command
(after-all
(setf (symbol-function 'test-command) nil))
;; Verify that the mode can be activated
(it "should enable itself properly"
(expect
(progn
(ido-ubiquitous-mode 1)
(with-simulated-input "g RET"
(command-execute 'test-command)))
:to-equal "green"))
(it "should disable itself properly"
(expect
(progn
(ido-ubiquitous-mode 0)
(with-simulated-input "g RET"
(command-execute 'test-command)))
:to-equal "g"))
(describe "with `ido-cr+-function-blacklist'"
(before-all
(setf (symbol-function 'blacklisted-command)
(lambda (arg)
(interactive (list (completing-read "Prompt: " '("blue" "yellow" "green"))))
arg)
(symbol-function 'blacklisted-function)
(lambda ()
(completing-read "Prompt: " '("blue" "yellow" "green")))
(symbol-function 'cmd-that-calls-blacklisted-function)
(lambda ()
(interactive)
(funcall 'blacklisted-function))
(symbol-function 'blacklisted-collection)
(collection-as-function '("blue" "yellow" "green"))))
(after-all
(setf (symbol-function 'blacklisted-command) nil
(symbol-function 'blacklisted-function) nil
(symbol-function 'cmd-that-calls-blacklisted-function) nil
(symbol-function 'blacklisted-collection) nil))
;; First verify that they work normally before blacklisting them
(describe "when the specified functions are not blacklisted"
(it "should not affect a non-blacklisted command"
(expect
(with-simulated-input "g RET"
(call-interactively 'blacklisted-command))
:to-equal "green"))
(it "should not affect a non-blacklisted function"
(expect
(with-simulated-input "g RET"
(call-interactively 'cmd-that-calls-blacklisted-function))
:to-equal "green"))
(it "should not affect a non-blacklisted collection"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " 'blacklisted-collection))
:to-equal "green")))
(describe "when the specified functions are blacklisted"
(before-each
(setq ido-cr+-function-blacklist
(append '(blacklisted-command
blacklisted-function
blacklisted-collection)
ido-cr+-function-blacklist)))
(it "should prevent ido in a blacklisted command"
(expect
(with-simulated-input "g RET"
(call-interactively 'blacklisted-command))
:to-equal "g"))
(it "should prevent ido in a blacklisted function"
(expect
(with-simulated-input "g RET"
(call-interactively 'cmd-that-calls-blacklisted-function))
:to-equal "g"))
(it "should prevent ido with a blacklisted collection"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " 'blacklisted-collection))
:to-equal "g")))
(describe "when updating ido-cr+"
(before-each
(spy-on 'ido-cr+-update-blacklist :and-call-through))
(it "should update the blacklist when `ido-cr+-auto-update-blacklist' is t"
(assume ido-cr+-function-blacklist)
(let ((orig-blacklist ido-cr+-function-blacklist))
(customize-set-variable 'ido-cr+-auto-update-blacklist t)
(customize-set-variable 'ido-cr+-function-blacklist nil)
(ido-cr+-maybe-update-blacklist)
(expect 'ido-cr+-update-blacklist :to-have-been-called)
(expect ido-cr+-function-blacklist :to-have-same-items-as orig-blacklist)))
(it "should not update the blacklist when `ido-cr+-auto-update-blacklist' is nil"
(assume ido-cr+-function-blacklist)
(let ((orig-blacklist ido-cr+-function-blacklist))
(customize-set-variable 'ido-cr+-auto-update-blacklist nil)
(customize-set-variable 'ido-cr+-function-blacklist nil)
(ido-cr+-maybe-update-blacklist)
(expect 'ido-cr+-update-blacklist :not :to-have-been-called)
(expect ido-cr+-function-blacklist :to-have-same-items-as nil)))
(it "should notify about blacklist updates when `ido-cr+-auto-update-blacklist' is `notify'"
(assume ido-cr+-function-blacklist)
(spy-on 'display-warning)
(let ((orig-blacklist ido-cr+-function-blacklist))
(customize-set-variable 'ido-cr+-auto-update-blacklist 'notify)
(customize-set-variable 'ido-cr+-function-blacklist nil)
(ido-cr+-maybe-update-blacklist)
(expect 'ido-cr+-update-blacklist :not :to-have-been-called)
(expect 'display-warning :to-have-been-called)
(expect ido-cr+-function-blacklist :to-have-same-items-as nil)))))
(describe "with `ido-cr+-function-whitelist'"
(before-all
(setf (symbol-function 'whitelisted-command)
(lambda (arg)
(interactive
(list
(completing-read "Prompt: " '("blue" "yellow" "green"))))
arg)
(symbol-function 'whitelisted-function)
(lambda ()
(completing-read "Prompt: " '("blue" "yellow" "green")))
(symbol-function 'cmd-that-calls-whitelisted-function)
(lambda ()
(interactive)
(funcall 'whitelisted-function))
(symbol-function 'whitelisted-collection)
(lambda (string pred action)
(complete-with-action action '("blue" "yellow" "green") string pred))))
(after-all
(setf (symbol-function 'whitelisted-command) nil
(symbol-function 'whitelisted-function) nil
(symbol-function 'cmd-that-calls-whitelisted-function) nil
(symbol-function 'whitelisted-collection) nil))
(describe "when the whitelist is inactive (i.e. everything is whitelisted)"
(before-each
(setq ido-cr+-function-whitelist nil))
(it "should enable ido in a command"
(expect
(with-simulated-input "g RET"
(call-interactively 'whitelisted-command))
:to-equal "green"))
(it "should enable ido in a function"
(expect
(with-simulated-input "g RET"
(call-interactively 'cmd-that-calls-whitelisted-function))
:to-equal "green"))
(it "should enable ido for a collection"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " 'whitelisted-collection))
:to-equal "green")))
(describe "when the specified functions are whitelisted"
(before-each
(setq ido-cr+-function-whitelist
(append '(whitelisted-command
whitelisted-function
whitelisted-collection)
ido-cr+-function-whitelist)))
(it "should enable ido in a whitelisted command"
(expect
(with-simulated-input "g RET"
(call-interactively 'whitelisted-command))
:to-equal "green"))
(it "should enable ido in a whitelisted function"
(expect
(with-simulated-input "g RET"
(call-interactively 'cmd-that-calls-whitelisted-function))
:to-equal "green"))
(it "should enable ido for a whitelisted collection"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " 'whitelisted-collection))
:to-equal "green")))
(describe "when the whitelist is active but empty (i.e. nothing whitelisted)"
(before-each
(setq ido-cr+-function-whitelist (list nil)))
(it "should prevent ido in a command"
(expect
(with-simulated-input "g RET"
(call-interactively 'whitelisted-command))
:to-equal "g"))
(it "should prevent ido in a function"
(expect
(with-simulated-input "g RET"
(call-interactively 'cmd-that-calls-whitelisted-function))
:to-equal "g"))
(it "should prevent ido for a collection"
(expect
(with-simulated-input "g RET"
(ido-completing-read+ "Prompt: " 'whitelisted-collection))
:to-equal "g"))))
(describe "with `ido-cr+-nil-def-alternate-behavior-list'"
(before-all
(setf (symbol-function 'def-nil-command)
(lambda (arg)
(interactive
(list
(completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
arg)
(symbol-function 'def-nil-function)
(lambda ()
(completing-read "Prompt: " '("blue" "yellow" "green") nil t))
(symbol-function 'cmd-that-calls-def-nil-function)
(lambda ()
(interactive)
(funcall 'def-nil-function))
(symbol-function 'def-nil-collection)
(lambda (string pred action)
(complete-with-action action '("blue" "yellow" "green") string pred))))
(after-all
(setf (symbol-function 'def-nil-command) nil
(symbol-function 'def-nil-function) nil
(symbol-function 'cmd-that-calls-def-nil-function) nil
(symbol-function 'def-nil-collection) nil))
(describe "when the specified functions are not in the list"
(before-each
(setq ido-cr+-nil-def-alternate-behavior-list nil))
(it "should use empty string default in a command"
(expect
(with-simulated-input "RET"
(call-interactively 'def-nil-command))
:to-equal ""))
(it "should use empty string default in a function"
(expect
(with-simulated-input "RET"
(call-interactively 'cmd-that-calls-def-nil-function))
:to-equal ""))
(it "should use empty string default for a collection"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " 'def-nil-collection nil t))
:to-equal "")))
(describe "when the specified functions are in the list"
(before-each
(setq ido-cr+-nil-def-alternate-behavior-list
(append '(def-nil-command
def-nil-function
def-nil-collection)
ido-cr+-nil-def-alternate-behavior-list)))
(it "should not use empty string default in a command"
(expect
(with-simulated-input "RET"
(call-interactively 'def-nil-command))
:to-equal "blue"))
(it "should not use empty string default in a function"
(expect
(with-simulated-input "RET"
(call-interactively 'cmd-that-calls-def-nil-function))
:to-equal "blue"))
(it "should not use empty string default for a collection"
(expect
(with-simulated-input "RET"
(ido-completing-read+ "Prompt: " 'def-nil-collection nil t))
:to-equal "blue"))))
;; Test is currently disabled pending additional information
(xit "should not hang or error when deleting characters in `org-refile' (issue #152)"
(expect
(progn
(ido-ubiquitous-mode 1)
(save-excursion
(with-temp-buffer
(org-mode)
(insert (s-trim "
* Heading 1
** Subheading 1.1
** Subheading 1.2
** Subheading 1.3
* Heading 2
* Heading 3
"))
(goto-char (point-max))
;; TODO Figure out what else needs to be set up to call
;; `org-refile'
(with-simulated-input
"Heading DEL DEL DEL DEL DEL RET"
(command-execute 'org-refile)))))
:not :to-throw)))
(describe "regressions should not occur for"
(it "issue #151: should not hang or error when cycling matches in `Info-menu'"
(expect
(progn
(ido-ubiquitous-mode 1)
(with-temp-info-buffer
(with-simulated-input
'("emacs"
(ido-next-match)
(wsi-simulate-idle-time 5)
(ido-next-match)
(wsi-simulate-idle-time 5)
(ido-next-match)
(wsi-simulate-idle-time 5)
(ido-next-match)
(wsi-simulate-idle-time 5)
"RET")
(command-execute 'Info-menu))))
:not :to-throw))
(it "issue #153: should preserve the selected item when doing a deferred dynamic update"
(expect
(with-simulated-input
'("Emacs"
(ido-next-match)
(wsi-simulate-idle-time 5)
"RET")
(ido-completing-read+
"Choose: "
(collection-as-function '("Emacs" "Emacs A" "Emacs B" "Emacs C"))))
:to-equal "Emacs A"))))
;;; test-ido-completing-read+.el ends here
ido-completing-read-plus-4.13/setversion.sh 0000755 0001750 0001750 00000001074 13514204422 020636 0 ustar dogsleg dogsleg #!/bin/bash
TARGET_VERSION="$1"
if [ -n "$TARGET_VERSION" ]; then
echo "Updating version to $TARGET_VERSION";
perl -i'orig_*' -lape "s/Version: [0-9.]+/Version: $TARGET_VERSION/g;" \
-e "s/((?:defconst|defvar|setq).*-version\s+)\"[0-9.]+\"/\${1}\"$TARGET_VERSION\"/g;" \
-e "s/(Package-Requires.*\(ido-completing-read\+\s+)\"[0-9.]+\"\)/\${1}\"${TARGET_VERSION}\")/g;" \
-e "s/\(package \"ido-ubiquitous\" \"[0-9.]+\"/(package \"ido-ubiquitous\" \"${TARGET_VERSION}\"/g" \
*.el Cask
else
echo "Usage: $0 VERSION_NUMBER"
fi
ido-completing-read-plus-4.13/ido-completing-read+.el 0000644 0001750 0001750 00000147213 13514204422 022324 0 ustar dogsleg dogsleg ;;; ido-completing-read+.el --- A completing-read-function using ido -*- lexical-binding: t -*-
;; Copyright (C) 2011-2017 Ryan C. Thompson
;; Filename: ido-completing-read+.el
;; Author: Ryan Thompson
;; Created: Sat Apr 4 13:41:20 2015 (-0700)
;; Version: 4.13
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5") (s "0.1") (memoize "1.1"))
;; URL: https://github.com/DarwinAwardWinner/ido-completing-read-plus
;; Keywords: ido, completion, convenience
;; This file is NOT part of GNU Emacs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;; If you use the excellent `ido-mode' for efficient completion of
;; file names and buffers, you might wonder if you can get ido-style
;; completion everywhere else too. Well, that's what this package
;; does! ido-ubiquitous is here to enable ido-style completion for
;; (almost) every function that uses the standard completion function
;; `completing-read'.
;; This package implements the `ido-completing-read+' function, which
;; is a wrapper for `ido-completing-read'. Importantly, it detects
;; edge cases that ordinary ido cannot handle and either adjusts them
;; so ido *can* handle them, or else simply falls back to Emacs'
;; standard completion instead. Hence, you can safely set
;; `completing-read-function' to `ido-completing-read+' without
;; worrying about breaking completion features that are incompatible
;; with ido.
;; To use this package, call `ido-ubiquitous-mode' to enable the mode,
;; or use `M-x customize-variable ido-ubiquitous-mode' it to enable it
;; permanently. Once the mode is enabled, most functions that use
;; `completing-read' will now have ido completion. If you decide in
;; the middle of a command that you would rather not use ido, just use
;; C-f or C-b at the end/beginning of the input to fall back to
;; non-ido completion (this is the same shortcut as when using ido for
;; buffers or files).
;; Note that `completing-read-default' is a very general function with
;; many complex behaviors that ido cannot emulate. This package
;; attempts to detect some of these cases and avoid using ido when it
;; sees them. So some functions will not have ido completion even when
;; this mode is enabled. Some other functions have ido disabled in
;; them because their packages already provide support for ido via
;; other means (for example, magit). See `M-x describe-variable
;; ido-cr+-function-blacklist' for more information.
;; ido-completing-read+ version 4.0 is a major update. The formerly
;; separate package ido-ubiquitous has been subsumed into
;; ido-completing-read+, so ido-ubiquitous 4.0 is just a wrapper that
;; loads ido-completing-read+ and displays a warning about being
;; obsolete. If you have previously customized ido-ubiquitous, be sure
;; to check out `M-x customize-group ido-completing-read-plus' after
;; updating to 4.0 and make sure the new settings are to your liking.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see .
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(defconst ido-completing-read+-version "4.13"
"Currently running version of ido-completing-read+.
Note that when you update ido-completing-read+, this variable may
not be updated until you restart Emacs.")
(require 'ido)
(require 'minibuf-eldef)
(require 'cl-lib)
(require 'cus-edit)
(require 's)
;; Optional dependency, only needed for optimization
(require 'memoize nil t)
;; Silence some byte-compiler warnings
(eval-when-compile
(require 'minibuf-eldef)
(require 'flx-ido nil t))
;;; Debug messages
(define-minor-mode ido-cr+-debug-mode
"If non-nil, ido-cr+ will print debug info.
Debug info is printed to the *Messages* buffer."
nil
:global t
:group 'ido-completing-read-plus)
(defsubst ido-cr+--debug-message (format-string &rest args)
(when ido-cr+-debug-mode
(apply #'message (concat "ido-completing-read+: " format-string) args)))
;;; Ido variables
;; For unknown reasons, these variables need to be re-declared here to
;; silence byte-compiler warnings, despite already being declared in
;; ido.el.
(defmacro define-ido-internal-var (symbol &optional initvalue docstring)
"Declare and initialize an ido internal variable.
This is used to suppress byte-compilation warnings about
reference to free variables when ido-cr+ attempts to access
internal ido variables with no initial value set. Such variables
are originally declared like `(defvar VARNAME)'.
This is a wrapper for `defvar' that supplies a default for the
INITVALUE and DOCSTRING arguments."
`(defvar ,symbol ,initvalue
,(or docstring
"Internal ido variable.
This variable was originally declared in `ido.el' without an
initial value or docstring. The documentation you're reading
comes from re-declaring it in `ido-completing-read+.el' in order
to suppress some byte-compilation warnings. Setting another
package's variable is not safe in general, but in this case it
should be, because ido always let-binds this variable before
using it, so the initial value shouldn't matter.")))
(define-ido-internal-var ido-context-switch-command)
(define-ido-internal-var ido-cur-list)
(define-ido-internal-var ido-cur-item)
(define-ido-internal-var ido-require-match)
(define-ido-internal-var ido-process-ignore-lists)
;; Vars and functions from flx-ido package
(defvar flx-ido-mode)
(declare-function flx-ido-reset "ext:flx-ido.el")
;;;###autoload
(defvar ido-cr+-minibuffer-depth -1
"Minibuffer depth of the most recent ido-cr+ activation.
If this equals the current minibuffer depth, then the minibuffer
is currently being used by ido-cr+, and ido-cr+ feature will be
active. Otherwise, something else is using the minibuffer and
ido-cr+ features will be deactivated to avoid interfering with
the other command.
This is set to -1 by default, since `(minibuffer-depth)' should
never return this value.")
(defvar ido-cr+-assume-static-collection nil
"If non-nil, ido-cr+ will assume that the collection is static.
This is used to avoid unnecessary work in the case where the
collection is a function, since a function collection could
potentially change the set of completion candidates
dynamically.")
(defvar ido-cr+-current-command nil
"Command most recently invoked by `call-interactively'.
This is necessary because `command-execute' and
`call-interactively' do not set `this-command'. Instead, the C
code that calls `command-execute' sets it beforehand, so using
either of those functions directly won't set `this-command'.")
(defvar ido-cr+-dynamic-collection nil
"Stores the collection argument if it is a function.
This allows ido-cr+ to update the set of completion candidates
dynamically.")
(defvar ido-cr+-last-dynamic-update-text nil
"The value of `ido-text' last time a dynamic update occurred.")
(defvar ido-cr+-dynamic-update-idle-time 0.25
"Time to wait before updating dynamic completion list.")
(defvar ido-cr+-dynamic-update-timer nil
"Idle timer for updating dynamic completion list.")
(defvar ido-cr+-exhibit-pending nil
"This is non-nil after calling `ido-tidy' until the next call to `ido-exhibit'.
Typically this is non-nil while any command is running and nil at all
other times, since those two functions are in `pre-command-hook'
and `post-command-hook' respectively. In particular, this will
generally be nil while running an idle timer.")
(make-obsolete-variable
'ido-cr+-no-default-action
" This variable no longer has any effect. Customize `ido-cr+-nil-def-alternate-behavior-list' instead."
"4.2")
(defvar ido-cr+-orig-completing-read-args nil
"Original arguments passed to `ido-completing-read+'.
These are used for falling back to `completing-read-default'.")
(defvar ido-cr+-all-completions-memoized 'all-completions
"Memoized version of `all-completions'.
During completion with dynamic collection, this variable is set
to a memoized copy of `all-completions'.")
(defvar ido-cr+-all-prefix-completions-memoized 'ido-cr+-all-prefix-completions
"Memoized version of `ido-cr+-all-prefix-completions'.
During completion with dynamic collection, this variable is set
to a memoized copy of `ido-cr+-all-prefix-completions'.")
(defvar ido-cr+-active-restrictions nil
"List of restrictions in place from `ido-restrict-to-matches'.
Each element is a cons cell of (REMOVEP . TEXT), where REMOVEP is
the prefix argument to `ido-restrict-to-matches' and TEXT is the
pattern used to restrict.")
(defgroup ido-completing-read-plus nil
"Extra features and compatibility for `ido-completing-read'."
:group 'ido)
(defcustom ido-cr+-fallback-function
;; Initialize to the current value of `completing-read-function',
;; unless that is already set to the ido completer, in which case
;; use `completing-read-default'.
(if (memq completing-read-function
'(ido-completing-read+
ido-completing-read
;; Current ido-ubiquitous function
completing-read-ido-ubiquitous
;; Old ido-ubiquitous functions that shouldn't be used
completing-read-ido
ido-ubiquitous-completing-read))
'completing-read-default
completing-read-function)
"Alternate completing-read function to use when ido is not wanted.
This will be used for functions that are incompatible with ido
or if ido cannot handle the completion arguments. It will also be
used when the user requests non-ido completion manually via C-f
or C-b."
:type '(choice (const :tag "Standard emacs completion"
completing-read-default)
(function :tag "Other function"))
:group 'ido-completing-read-plus)
(defcustom ido-cr+-max-items 30000
"Max collection size to use ido-cr+ on.
If `ido-completing-read+' is called on a collection larger than
this, the fallback completion method will be used instead. To
disable fallback based on collection size, set this to nil."
:type '(choice (const :tag "No limit" nil)
(integer
:tag "Limit" :value 30000
:validate
(lambda (widget)
(let ((v (widget-value widget)))
(if (and (integerp v)
(> v 0))
nil
(widget-put widget :error "This field should contain a positive integer")
widget)))))
:group 'ido-completing-read-plus)
(defcustom ido-cr+-function-blacklist
'(read-file-name-internal
read-buffer
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/60
todo-add-category
;; Gnus already supports ido on its own
gnus-emacs-completing-read
gnus-iswitchb-completing-read
grep-read-files
;; Magit already supports ido on its own
magit-builtin-completing-read
;; ESS already supports ido on its own
ess-completing-read
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/39
Info-read-node-name
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/44
tmm-prompt
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/156
org-tags-completion-function
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/159
ffap-read-file-or-url
ffap-read-file-or-url-internal
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/161
sly-read-symbol-name
)
"Functions & commands for which ido-cr+ should be disabled.
Each entry can be either a symbol or a string. A symbol means to
fall back specifically for the named function. A regular
expression means to fall back for any function whose name matches
that regular expression. When ido-cr+ is called through
`completing-read', if any function in the call stack of the
current command matches any of the blacklist entries, ido-cr+
will be disabled for that command. Additionally, if the
collection in the call to `completing-read' matches any of the
blacklist entries, ido-cr+ will be disabled.
Note that using specific function names is generally preferable
to regular expressions, because the associated function
definitions will be compared directly, so if the same function is
called by another name, it should still trigger the fallback. For
regular expressions, only name-based matching is possible."
:group 'ido-completing-read-plus
:type '(repeat (choice (symbol :tag "Function or command name")
(string :tag "Regexp"))))
(defcustom ido-cr+-function-whitelist
nil
"Functions & commands for which ido-cr+ should be enabled.
If this variable is nil, the whitelist will not be used, and
ido-cr+ will be allowed in all functions/commands not listed in
`ido-cr+-function-backlist'.
If this variable is non-nil, ido-cr+'s whitelisting mode will be
enabled, and ido-cr+ will be disabled for *all* functions unless
they match one of the entries. Matching is done in the same
manner as `ido-cr+-function-blacklist', and blacklisting takes
precedence over whitelisting."
:group 'ido-completing-read-plus
:type '(repeat (choice (symbol :tag "Function or command name")
(string :tag "Regexp"))))
(defcustom ido-cr+-nil-def-alternate-behavior-list
'("\\`describe-\\(function\\|variable\\)\\'"
"\\`wl-"
;; https://github.com/mrkkrp/ebal/issues/12
"\\`ebal-"
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/4
webjump
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/83
where-is
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/51
find-tag
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/89
"\\`etags-select-"
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/58
imenu--completion-buffer
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/116
project--completing-read-strict
;; https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues/127#issuecomment-319463217
bookmark-completing-read
)
"Functions & commands with alternate behavior when DEF is nil.
This variable has the same format as
`ido-cr+-function-blacklist'. When `ido-completing-read+` is
called through `completing-read' by/with any command, function,
or collection matched by entries in this list, it will behave
differently when DEF is nil. Instead of using the empty string as
the default value, it will use the first element of COLLECTION.
This is needed for optimal compatibility with commands written
under the assumption that REQUIRE-MATCH means that a match is
required."
:group 'ido-completing-read-plus
:type '(repeat (choice (symbol :tag "Function or command name")
(string :tag "Regexp"))))
(defvaralias 'ido-cr+-nil-def-wall-of-shame 'ido-cr+-nil-def-alternate-behavior-list
"Functions and commands whose authors need to read the docstring for `completing-read'.
Many functions that call `completing-read' are written with the
assumption that the setting the REQUIRE-MATCH argument of
`completing-read' to t means it is required to return a match.
While that would make logical sense, it's wrong. the docstring
for `completing-read' describes the correct behavior.
> If the input is null, ‘completing-read’ returns DEF, or the
> first element of the list of default values, or an empty string
> if DEF is nil, regardless of the value of REQUIRE-MATCH.
This can be avoided by passing an element of COLLECTION as DEF
instead of leaving it as nil.")
;;;###autoload
(defcustom ido-cr+-replace-completely nil
"If non-nil, replace `ido-completeing-read' completely with ido-cr+.
Enabling this may interfere with or cause errors in other
packages that use `ido-completing-read'. If you discover any such
incompatibilities, please file a bug report at
https://github.com/DarwinAwardWinner/ido-completing-read-plus/issues"
:type 'boolean)
;; Signal used to trigger fallback
(define-error 'ido-cr+-fallback "ido-cr+-fallback")
(defsubst ido-cr+--explain-fallback (arg)
;; This function accepts a string, or an ido-cr+-fallback
;; signal.
(when ido-cr+-debug-mode
(when (and (listp arg)
(eq (car arg) 'ido-cr+-fallback))
(setq arg (cadr arg)))
(ido-cr+--debug-message "Falling back to `%s' because %s."
ido-cr+-fallback-function arg)))
;;;###autoload
(defsubst ido-cr+-active ()
"Returns non-nil if ido-cr+ is currently using the minibuffer."
(>= ido-cr+-minibuffer-depth (minibuffer-depth)))
(defun ido-cr+--called-from-completing-read ()
"Returns non-nil if the most recent call to ido-cr+ was from `completing-read'."
(equal (cadr (backtrace-frame 1 'ido-completing-read+))
'completing-read))
(defmacro ido-cr+-function-is-in-list (fun fun-list &optional list-name)
"Return non-nil if FUN matches an entry in FUN-LIST.
This is used to check for matches to `ido-cr+-function-blacklist'
and `ido-cr+-function-whitelist'. Read those docstrings to see
how the matching is done.
This is declared as macro only in order to extract the variable
name used for the second argument so it can be used in a debug
message. It should be called as if it were a normal function."
(when (null list-name)
(if (symbolp fun-list)
(setq list-name (symbol-name fun-list))
(setq list-name "list")))
`(cl-loop
for entry in ,fun-list
if (cond
;; Nil: Never matches anything
((null entry)
nil)
;; Symbol: Compare names and function definitions
((symbolp entry)
(or (eq entry ,fun)
(let ((entry-def (ignore-errors (indirect-function entry)))
(fun-def (ignore-errors (indirect-function ,fun))))
(and
fun-def entry-def
(eq
(indirect-function entry-def)
(indirect-function fun-def))))))
;; String: Do regexp matching against function name if it is a
;; symbol
((stringp entry)
(and (symbolp ,fun)
(string-match-p entry (symbol-name ,fun))))
;; Anything else: invalid blacklist entry
(t
(ido-cr+--debug-message "Ignoring invalid entry in %s: `%S'" ,list-name entry)
nil))
return entry
;; If no blacklist entry matches, return nil
finally return nil))
(defun ido-cr+-function-is-blacklisted (fun)
"Return non-nil if FUN is blacklisted.
See `ido-cr+-function-blacklist'."
(ido-cr+-function-is-in-list fun ido-cr+-function-blacklist))
(defun ido-cr+-function-is-whitelisted (fun)
"Return non-nil if FUN is whitelisted.
See `ido-cr+-function-whitelist'."
(or (null ido-cr+-function-whitelist)
(ido-cr+-function-is-in-list fun ido-cr+-function-whitelist)))
;;;###autoload
(defun ido-completing-read+ (prompt collection &optional predicate
require-match initial-input
hist def inherit-input-method)
"ido-based method for reading from the minibuffer with completion.
See `completing-read' for the meaning of the arguments.
This function is a wrapper for `ido-completing-read' designed to
be used as the value of `completing-read-function'. Importantly,
it detects edge cases that ido cannot handle and uses normal
completion for them."
(let* (;; Save the original arguments in case we need to do the
;; fallback
(ido-cr+-orig-completing-read-args
(list prompt collection predicate require-match
initial-input hist def inherit-input-method))
;; Need to save a copy of this since activating the
;; minibuffer once will clear out any temporary minibuffer
;; hooks, which need to get restored before falling back so
;; that they will trigger again when the fallback function
;; uses the minibuffer. We make a copy in case the original
;; list gets modified in place.
(orig-minibuffer-setup-hook (cl-copy-list minibuffer-setup-hook))
;; Need just the string part of INITIAL-INPUT
(initial-input-string
(cond
((consp initial-input)
(car initial-input))
((stringp initial-input)
initial-input)
((null initial-input)
"")
(t
(signal 'wrong-type-argument (list 'stringp initial-input)))))
(ido-cr+-active-restrictions nil)
;; If collection is a function, save it for later, unless
;; instructed not to
(ido-cr+-dynamic-collection
(when (and (not ido-cr+-assume-static-collection)
(functionp collection))
collection))
(ido-cr+-last-dynamic-update-text nil)
;; Only memoize if the collection is dynamic.
(ido-cr+-all-prefix-completions-memoized
(if (and ido-cr+-dynamic-collection (featurep 'memoize))
(memoize (indirect-function 'ido-cr+-all-prefix-completions))
'ido-cr+-all-prefix-completions))
(ido-cr+-all-completions-memoized
(if (and ido-cr+-dynamic-collection (featurep 'memoize))
(memoize (indirect-function 'all-completions))
'all-completions))
;; If the whitelist is empty, everything is whitelisted
(whitelisted (not ido-cr+-function-whitelist))
;; If non-nil, we need alternate nil DEF handling
(alt-nil-def nil))
(condition-case sig
(progn
;; Check a bunch of fallback conditions
(when (and inherit-input-method current-input-method)
(signal 'ido-cr+-fallback
'("ido cannot handle alternate input methods")))
;; Check for black/white-listed collection function
(when (functionp collection)
;; Blacklist
(when (ido-cr+-function-is-blacklisted collection)
(if (symbolp collection)
(signal 'ido-cr+-fallback
(list (format "collection function `%S' is blacklisted" collection)))
(signal 'ido-cr+-fallback
(list "collection function is blacklisted"))))
;; Whitelist
(when (and (not whitelisted)
(ido-cr+-function-is-whitelisted collection))
(ido-cr+--debug-message
(if (symbolp collection)
(format "Collection function `%S' is whitelisted" collection)
"Collection function is whitelisted"))
(setq whitelisted t))
;; nil DEF list
(when (and
require-match (null def)
(ido-cr+-function-is-in-list
collection
ido-cr+-nil-def-alternate-behavior-list))
(ido-cr+--debug-message
(if (symbolp collection)
(format "Using alternate nil DEF handling for collection function `%S'" collection)
"Using alternate nil DEF handling for collection function"))
(setq alt-nil-def t)))
;; Expand all currently-known completions.
(setq collection
(if ido-cr+-dynamic-collection
(funcall ido-cr+-all-prefix-completions-memoized
initial-input-string collection predicate)
(all-completions "" collection predicate)))
;; No point in using ido unless there's a collection
(when (and (= (length collection) 0)
(not ido-cr+-dynamic-collection))
(signal 'ido-cr+-fallback '("ido is not needed for an empty collection")))
;; Check for excessively large collection
(when (and ido-cr+-max-items
(> (length collection) ido-cr+-max-items))
(signal 'ido-cr+-fallback
(list
(format
"there are more than %i items in COLLECTION (see `ido-cr+-max-items')"
ido-cr+-max-items))))
;; If called from `completing-read', check for
;; black/white-listed commands/callers
(when (ido-cr+--called-from-completing-read)
;; Check calling command and `ido-cr+-current-command'
(cl-loop
for cmd in (list this-command ido-cr+-current-command)
if (ido-cr+-function-is-blacklisted cmd)
do (signal 'ido-cr+-fallback
(list "calling command `%S' is blacklisted" cmd))
if (and (not whitelisted)
(ido-cr+-function-is-whitelisted cmd))
do (progn
(ido-cr+--debug-message "Command `%S' is whitelisted" cmd)
(setq whitelisted t))
if (and
require-match (null def) (not alt-nil-def)
(ido-cr+-function-is-in-list
cmd ido-cr+-nil-def-alternate-behavior-list))
do (progn
(ido-cr+--debug-message
"Using alternate nil DEF handling for command `%S'" cmd)
(setq alt-nil-def t)))
;; Check every function in the call stack starting after
;; `completing-read' until to the first
;; `funcall-interactively' (for a call from the function
;; body) or `call-interactively' (for a call from the
;; interactive form, in which the function hasn't actually
;; been called yet, so `funcall-interactively' won't be on
;; the stack.)
(cl-loop for i upfrom 1
for caller = (cadr (backtrace-frame i 'completing-read))
while caller
while (not (memq (indirect-function caller)
'(internal--funcall-interactively
(indirect-function 'call-interactively))))
if (ido-cr+-function-is-blacklisted caller)
do (signal 'ido-cr+-fallback
(list (if (symbolp caller)
(format "calling function `%S' is blacklisted" caller)
"a calling function is blacklisted")))
if (and (not whitelisted)
(ido-cr+-function-is-whitelisted caller))
do (progn
(ido-cr+--debug-message
(if (symbolp caller)
(format "Calling function `%S' is whitelisted" caller)
"A calling function is whitelisted"))
(setq whitelisted t))
if (and require-match (null def) (not alt-nil-def)
(ido-cr+-function-is-in-list
caller ido-cr+-nil-def-alternate-behavior-list))
do (progn
(ido-cr+--debug-message
(if (symbolp caller)
(format "Using alternate nil DEF handling for calling function `%S'" caller)
"Using alternate nil DEF handling for a calling function"))
(setq alt-nil-def t))))
(unless whitelisted
(signal 'ido-cr+-fallback
(list "no functions or commands matched the whitelist for this call")))
(when (and require-match (null def))
;; Replace nil with "" for DEF if match is required, unless
;; alternate nil DEF handling is enabled
(if alt-nil-def
(ido-cr+--debug-message
"Leaving the default at nil because alternate nil DEF handling is enabled.")
(ido-cr+--debug-message
"Adding \"\" as the default completion since no default was provided.")
(setq def (list ""))))
;; In ido, the semantics of "default" are simply "put it at
;; the front of the list". Furthermore, ido can't handle a
;; list of defaults, nor can it handle both DEF and
;; INITIAL-INPUT being non-nil. So, just pre-process the
;; collection to put the default(s) at the front and then
;; set DEF to nil in the call to ido to avoid these issues.
(unless (listp def)
;; Ensure DEF is a list
(setq def (list def)))
(when def
;; Ensure DEF are strings
(setq def (mapcar (apply-partially #'format "%s") def))
;; Prepend DEF to COLLECTION and remove duplicates
(setq collection (delete-dups (append def collection))
def nil))
;; Check for a specific bug
(when (and ido-enable-dot-prefix
(version< emacs-version "26.1")
(member "" collection))
(signal 'ido-cr+-fallback
'("ido cannot handle the empty string as an option when `ido-enable-dot-prefix' is non-nil; see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26997")))
;; Fix ido's broken handling of cons-style INITIAL-INPUT on
;; Emacsen older than 27.1.
(when (and (consp initial-input)
(version< emacs-version "27.1"))
;; `completing-read' uses 0-based index while
;; `read-from-minibuffer' uses 1-based index.
(cl-incf (cdr initial-input)))
;; Finally ready to do actual ido completion
(prog1
(let ((ido-cr+-minibuffer-depth (1+ (minibuffer-depth)))
(ido-cr+-dynamic-update-timer nil)
(ido-cr+-exhibit-pending t)
;; Reset this for recursive calls to ido-cr+
(ido-cr+-assume-static-collection nil))
(unwind-protect
(ido-completing-read
prompt collection
predicate require-match initial-input hist def
inherit-input-method)
(when ido-cr+-dynamic-update-timer
(cancel-timer ido-cr+-dynamic-update-timer)
(setq ido-cr+-dynamic-update-timer nil))))
;; This detects when the user triggered fallback mode
;; manually.
(when (eq ido-exit 'fallback)
(signal 'ido-cr+-fallback '("user manually triggered fallback")))))
;; Handler for ido-cr+-fallback signal
(ido-cr+-fallback
(let (;; Reset `minibuffer-setup-hook' to original value
(minibuffer-setup-hook orig-minibuffer-setup-hook)
;; Reset this for recursive calls to ido-cr+
(ido-cr+-assume-static-collection nil))
(ido-cr+--explain-fallback sig)
(apply ido-cr+-fallback-function ido-cr+-orig-completing-read-args))))))
;;;###autoload
(defun ido-completing-read@ido-cr+-replace (orig-fun &rest args)
"This advice allows ido-cr+ to completely replace `ido-completing-read'.
See the varaible `ido-cr+-replace-completely' for more information."
(if (or (ido-cr+-active)
(not ido-cr+-replace-completely))
;; ido-cr+ has either already activated or isn't going to
;; activate, so just run the function as normal
(apply orig-fun args)
;; Otherwise, we need to activate ido-cr+.
(apply #'ido-completing-read+ args)))
;;;###autoload
(advice-add 'ido-completing-read :around
#'ido-completing-read@ido-cr+-replace)
;;;###autoload
(defun call-interactively@ido-cr+-record-current-command
(orig-fun command &rest args)
"Let-bind the command being interactively called.
See `ido-cr+-current-command' for more information."
(let ((ido-cr+-current-command command))
(apply orig-fun command args)))
;;;###autoload
(advice-add 'call-interactively :around
#'call-interactively@ido-cr+-record-current-command)
;; Fallback on magic C-f and C-b
(defun ido-magic-forward-char@ido-cr+-fallback (&rest _args)
"Allow falling back in ido-completing-read+."
(when (ido-cr+-active)
;; `ido-context-switch-command' is already let-bound at this
;; point.
(setq ido-context-switch-command #'ido-fallback-command)))
(advice-add 'ido-magic-forward-char :before
#'ido-magic-forward-char@ido-cr+-fallback)
(defun ido-magic-backward-char@ido-cr+-fallback (&rest _args)
"Allow falling back in ido-completing-read+."
(when (ido-cr+-active)
;; `ido-context-switch-command' is already let-bound at this
;; point.
(setq ido-context-switch-command #'ido-fallback-command)))
(advice-add 'ido-magic-backward-char :before
#'ido-magic-backward-char@ido-cr+-fallback)
(defun ido-select-text@ido-cr+-fix-require-match (orig-fun &rest args)
"Fix ido behavior when `require-match' is non-nil.
Standard ido will allow C-j to exit with an incomplete completion
even when `require-match' is non-nil. Ordinary completion does
not allow this. In ordinary completion, RET on an incomplete
match is equivalent to TAB, and C-j selects the first match.
Since RET in ido already selects the first match, this advice
sets up C-j to be equivalent to TAB in the same situation.
This advice only activates if the current ido completion was
called through ido-cr+."
(if (and
;; Only override C-j behavior if...
;; We're using ico-cr+, and...
(ido-cr+-active)
;; Require-match is non-nil, and...
ido-require-match
;; The current input doesn't exactly match a known option, and...
(not (member ido-text ido-cur-list))
;; The current input doesn't exactly match an option according
;; to `test-completion' (or the collection is not dynamic).
(or (not ido-cr+-dynamic-collection)
(test-completion ido-text ido-cr+-dynamic-collection
(nth 2 ido-cr+-orig-completing-read-args))))
(progn
(ido-cr+--debug-message
"Overriding C-j behavior for require-match: performing completion instead of exiting with current text. (This might still exit with a match if `ido-confirm-unique-completion' is nil)")
(ido-complete))
(apply orig-fun args)))
(advice-add 'ido-select-text :around
#'ido-select-text@ido-cr+-fix-require-match)
(defun ido-tidy@ido-cr+-set-exhibit-pending (&rest _args)
(setq ido-cr+-exhibit-pending t))
(advice-add 'ido-tidy :after 'ido-tidy@ido-cr+-set-exhibit-pending)
(defun ido-exhibit@ido-cr+-clear-exhibit-pending (&rest _args)
(setq ido-cr+-exhibit-pending nil))
(advice-add 'ido-exhibit :before 'ido-exhibit@ido-cr+-clear-exhibit-pending)
(defun ido-cr+-all-prefix-completions
(string collection &optional predicate)
"Run `all-completions' on every prefix of STRING.
Arguments COLLECTION and PREDICATE are as in `all-completions'.
Note that \"all prefixes\" includes both STRING itself and the
empty string. The return value is the union of all the returned
lists, with elements ordered by their first occurrence.
This function is only useful if COLLECTION is a function that
might return additional completions for certain non-empty strings
that it wouldn't return for the empty string. If COLLECTION is
not a function, this is equivalent to
`(all-completions \"\" COLELCTION PREDICATE)'."
(cond
;; Dynamic collection.
((functionp collection)
;; Collect completions for all prefixes of STRING starting from
;; "".
(cl-loop
for i from 0 upto (length string)
append (funcall
ido-cr+-all-completions-memoized
(s-left i string)
collection
predicate)
into completion-list
finally return (delete-dups completion-list)))
;; If COLLECTION is not dynamic, then just call `all-completions'
;; on the empty string, which will already return every possible
;; completion.
(t
(all-completions "" collection predicate))))
(defun ido-cr+-apply-restrictions (collection restrictions)
"Filter COLLECTION through RESTRICTIONS in sequence.
COLLECTION is a list of strings. RESTRICTIONS is a list of cons
cells, with the cdr being the restriction text and the car being
nil to include matches for that text and t to exclude matches for
that text. The return value is a list of strings that satisfy all
the restrictions, in the same order as they appeared in
COLLECTION.
RESTRICTIONS are applied one by one in order, which is important
because in theory the order can make a difference to the final
result."
(cl-loop
with filtered-collection = collection
with need-reverse = nil
for (removep . text) in restrictions
for restriction-matches =
(let ((ido-text text)
(ido-cur-item (or ido-cur-item 'list)))
(ido-set-matches-1 filtered-collection t))
do (setq filtered-collection
(if removep
(seq-difference filtered-collection restriction-matches)
(setq need-reverse (not need-reverse))
restriction-matches))
;; Each run of `ido-set-matches-1' reverses the order, so reverse
;; it one more time if it had an odd number of reverses.
finally return
(if need-reverse
(nreverse filtered-collection)
filtered-collection)))
(defun ido-cr+-cyclicp (x)
"Returns non-nill if X is a list containing a circular reference."
(cl-loop
for tortoise on x
for hare on (cdr x) by #'cddr
thereis (eq tortoise hare)))
(defun ido-cr+-update-dynamic-collection ()
"Update the set of completions for a dynamic collection.
This has no effect unless `ido-cr+-dynamic-collection' is non-nil."
(when (and ido-cr+-dynamic-collection
(ido-cr+-active))
;; (cl-assert (not (ido-cr+-cyclicp ido-cur-list)))
(let ((orig-ido-cur-list ido-cur-list)
(ido-text
(buffer-substring-no-properties (minibuffer-prompt-end)
ido-eoinput)))
;; If current `ido-text' is equal to or a prefix of the previous
;; one, a dynamic update is not needed.
(when (or (null ido-cr+-last-dynamic-update-text)
(not (s-prefix? ido-text ido-cr+-last-dynamic-update-text)))
(ido-cr+--debug-message "Doing a dynamic update because `ido-text' changed from %S to %S"
ido-cr+-last-dynamic-update-text ido-text)
(setq ido-cr+-last-dynamic-update-text ido-text)
(condition-case-unless-debug err
(let* ((predicate (nth 2 ido-cr+-orig-completing-read-args))
(first-match (car ido-matches))
(strings-to-check
(cond
;; If no match, then we only check `ido-text'
((null first-match)
(list ido-text))
;; If `ido-text' is a prefix of `first-match', then we
;; only need to check `first-match'
((and first-match
(s-prefix? ido-text first-match))
(list first-match))
;; Otherwise we need to check both
(t
(list ido-text first-match))))
(new-completions
(cl-loop
for string in strings-to-check
append
(funcall
ido-cr+-all-prefix-completions-memoized
string ido-cr+-dynamic-collection predicate)
into result
finally return result)))
;; (cl-assert (not (ido-cr+-cyclicp new-completions)))
(if (equal new-completions ido-cur-list)
(ido-cr+--debug-message "Skipping dynamic update because the completion list did not change.")
(when (and (bound-and-true-p flx-ido-mode)
(functionp 'flx-ido-reset))
;; Reset flx-ido since the set of completions has changed
(funcall 'flx-ido-reset))
(setq ido-cur-list (delete-dups (append ido-cur-list new-completions)))
(when ido-cr+-active-restrictions
(setq ido-cur-list (ido-cr+-apply-restrictions
ido-cur-list
ido-cr+-active-restrictions)))
(ido-cr+--debug-message
"Updated completion candidates for dynamic collection. `ido-cur-list' now has %s elements"
ido-text (length ido-cur-list))
;; Recompute matches with new completions
(let ((ido-rescan t))
(ido-set-matches))
(setq ido-rescan nil)
;; Put the pre-update first match (if any) back in
;; front
(when (and first-match
(not (equal first-match (car ido-matches)))
(member first-match ido-matches))
(ido-cr+--debug-message "Restoring first match %S after dynamic update" first-match)
(setq ido-matches (ido-chop ido-matches first-match)))
;; Rebuild the completion display unless ido is already planning
;; to do it anyway
(unless ido-cr+-exhibit-pending
(ido-tidy)
(let ((ido-rescan nil))
(ido-exhibit)))))
(error
(display-warning 'ido-cr+
(format
"Disabling dynamic update due to error: %S"
err))
;; Reset any variables that might have been modified during
;; the failed update
(setq ido-cur-list orig-ido-cur-list)
;; Prevent any further attempts at dynamic updating
(setq ido-cr+-dynamic-collection nil))))))
;; Always cancel an active timer when this function is called.
(when ido-cr+-dynamic-update-timer
(cancel-timer ido-cr+-dynamic-update-timer)
(setq ido-cr+-dynamic-update-timer nil)))
(defun ido-cr+-schedule-dynamic-collection-update ()
"Schedule a dynamic collection update for now or in the future."
(when (and (ido-cr+-active)
ido-cr+-dynamic-collection)
;; Cancel the previous timer
(when ido-cr+-dynamic-update-timer
(cancel-timer ido-cr+-dynamic-update-timer)
(setq ido-cr+-dynamic-update-timer nil))
(cl-assert (not (ido-cr+-cyclicp ido-cur-list)))
(if (<= (length ido-matches) 1)
;; If we've narrowed it down to zero or one matches, update
;; immediately.
(ido-cr+-update-dynamic-collection)
;; If there are still several choices, defer update until idle
(setq ido-cr+-dynamic-update-timer
(run-with-idle-timer (max 0.01 ido-cr+-dynamic-update-idle-time) nil
#'ido-cr+-update-dynamic-collection)))))
(defun ido-cr+-minibuffer-setup ()
"set up minibuffer `post-command-hook' for ido-cr+ "
(when (ido-cr+-active)
(add-hook 'post-command-hook
'ido-cr+-schedule-dynamic-collection-update)))
(add-hook 'ido-minibuffer-setup-hook
'ido-cr+-minibuffer-setup)
;; Also need to update dynamic collections on TAB, and do so *before*
;; deciding to exit based on `ido-confirm-unique-completion'
(defun ido-complete@ido-cr+-update-dynamic-collection (oldfun &rest args)
"Maybe update the set of completions when pressing TAB."
(when ido-cr+-dynamic-collection
;; First run with `ido-confirm-unique-completion' non-nil so it
;; can't exit
(let ((ido-confirm-unique-completion t))
(apply oldfun args))
;; Update `ido-eoinput'
(setq ido-eoinput (point-max))
;; Clear this var to force an update
(setq ido-cr+-last-dynamic-update-text nil)
;; Now do update
(ido-cr+-update-dynamic-collection))
;; After maybe updating the dynamic collection, if there's still
;; only one completion, now it's allowed to exit
(apply oldfun args))
(advice-add 'ido-complete :around 'ido-complete@ido-cr+-update-dynamic-collection)
;; When using `ido-restrict-to-matches', we also need to add an
;; equivalent predicate to the dynamic collection so that
;; dynamically-added completions are also properly restricted.
(defun ido-restrict-to-matches@ido-cr+-record-restriction
(&optional removep)
"Record the restriction criterion for ido-cr+"
(ido-cr+--debug-message "Appending restriction %S to `ido-cr+-active-restrictions'"
(cons removep ido-text))
(add-to-list 'ido-cr+-active-restrictions (cons removep ido-text) t))
(advice-add 'ido-restrict-to-matches :before
'ido-restrict-to-matches@ido-cr+-record-restriction)
;; Interoperation with minibuffer-electric-default-mode: only show the
;; default when the input is empty and the empty string is the
;; selected choice
(defun minibuf-eldef-update-minibuffer@ido-cr+-compat (orig-fun &rest args)
"This advice allows minibuffer-electric-default-mode to work with ido-cr+."
(if (ido-cr+-active)
(unless (eq minibuf-eldef-showing-default-in-prompt
(and (string= (car ido-cur-list) "")
(string= ido-text "")))
;; Swap state.
(setq minibuf-eldef-showing-default-in-prompt
(not minibuf-eldef-showing-default-in-prompt))
(overlay-put minibuf-eldef-overlay 'invisible
(not minibuf-eldef-showing-default-in-prompt)))
(apply orig-fun args)))
(advice-add 'minibuf-eldef-update-minibuffer :around
#'minibuf-eldef-update-minibuffer@ido-cr+-compat)
;;;###autoload
(define-minor-mode ido-ubiquitous-mode
"Use ido completion instead of standard completion almost everywhere.
If this mode causes problems for a function, you can customize
when ido completion is or is not used by customizing
`ido-cr+-function-blacklist'."
nil
:global t
:group 'ido-completing-read-plus
;; Actually enable/disable the mode by setting
;; `completing-read-function'.
(setq completing-read-function
(if ido-ubiquitous-mode
#'ido-completing-read+
ido-cr+-fallback-function)))
(defcustom ido-cr+-auto-update-blacklist 'notify
"Whether to add new overrides when updating ido-cr+.
This variable has 3 possible values, with the following meanings:
`t': Auto-update the blacklist
`notify': Notify you about updates but do not apply them
`nil': Ignore all blacklist updates
Ido-cr+ comes with a default blacklist for commands that are
known to be incompatible with ido completion. New versions of
ido-cr+ may come with updates to this blacklist as more
incompatible commands are discovered. However, customizing your
own overrides would normally prevent you from receiving these
updates, since Emacs will not overwrite your customizations.
To resolve this problem, you can set this variable to `t', and
then ido-cr+ can automatically add any new built-in overrides
whenever it is updated. (Actually, the update will happen the
next time Emacs is restarted after the update.) This allows you
to add your own overrides but still receive updates to the
default set.
If you want ido-cr+ to just notify you about new default
overrides instead of adding them itself, set this variable to
`notify'. If you don't want this auto-update behavior at all, set
it to `nil'.
(Note that having this option enabled effectively prevents you
from removing any of the built-in default blacklist entries,
since they will simply be re-added the next time Emacs starts.)"
:type '(choice :tag "When new overrides are available:"
(const :menu-tag "Auto-add"
:tag "Add them automatically"
t)
(const :menu-tag "Notify"
:tag "Notify me about them"
notify)
(const :menu-tag "Ignore"
:tag "Ignore them"
nil))
:group 'ido-completing-read-plus)
(defun ido-cr+-update-blacklist (&optional save quiet)
"Re-add any missing default blacklist entries.
This is useful after an update of ido-ubiquitous that adds new
default overrides. See `ido-cr+-auto-update-blacklist' for more
information.
If SAVE is non-nil, also save the new blacklist to the user's
Custom file (but only if it was already customized beforehand).
When called interactively, a prefix argument triggers a save.
When called from Lisp code, this function returns non-nil if the
blacklist was modified."
(interactive "P")
(let* ((var-state (custom-variable-state 'ido-cr+-function-blacklist
ido-cr+-function-blacklist))
(curval ido-cr+-function-blacklist)
(defval (eval (car (get 'ido-cr+-function-blacklist 'standard-value))))
(newval (delete-dups (append defval curval)))
(new-entries (cl-set-difference defval curval :test #'equal))
(modified nil)
(saved nil)
(message-lines ()))
(cl-case var-state
(standard
;; Var is not customized, just set the new default
(ido-cr+--debug-message "Blacklist was not customized, so it has been updated to the new default value.")
(setq ido-cr+-function-blacklist defval
modified new-entries))
((saved set changed)
;; Var has been customized and saved by the user, so set the
;; new value and maybe save it
(ido-cr+--debug-message "Updating user-customized blacklist with new default entries.")
(setq ido-cr+-function-blacklist newval
modified t)
(when (and save (eq var-state 'saved))
(ido-cr+--debug-message "Saving new blacklist value to Custom file.")
(customize-save-variable 'ido-cr+-function-blacklist ido-cr+-function-blacklist)
(setq saved t)))
(otherwise
(ido-cr+--debug-message "Customization status of blacklist is unknown. Not modifying it.")))
(if (and modified (not quiet))
(progn
(push (format "Added the following entries to `ido-cr+-function-blacklist': %S" new-entries)
message-lines)
(if saved
(push "Saved the new value of `ido-cr+-function-blacklist' to your Custom file."
message-lines)
(push "However, the new value of `ido-cr+-function-blacklist' has not yet been saved for future sessions. To save it. re-run this command with a prefix argument: `C-u M-x ido-cr+-update-blacklist'; or else manually inspect and save the value using `M-x customize-variable ido-cr+-function-blacklist'."
message-lines)))
(push "No updates were required to `ido-cr+-function-blacklist'." message-lines))
(unless quiet
(message (mapconcat #'identity (nreverse message-lines) "\n")))
modified))
(defun ido-cr+-maybe-update-blacklist ()
"Maybe call `ico-cr+-update-blacklist.
See `ido-cr+-auto-update-blacklist' for more information."
(if ido-cr+-auto-update-blacklist
(let* ((curval ido-cr+-function-blacklist)
(defval (eval (car (get 'ido-cr+-function-blacklist 'standard-value))))
(new-entries (cl-set-difference defval curval :test #'equal)))
(if new-entries
(if (eq ido-cr+-auto-update-blacklist 'notify)
(display-warning 'ido-completing-read+ (format "There are %s new blacklist entries available. Use `M-x ido-cr+-update-blacklist' to install them. (See `ido-cr+-auto-update-blacklist' for more information.)" (length new-entries)))
(ido-cr+--debug-message "Initiating blacklist update.")
(ido-cr+-update-blacklist t))
(ido-cr+--debug-message "No blacklist updates available.")))
(ido-cr+--debug-message "Skipping blacklist update by user request.")))
(ido-cr+-maybe-update-blacklist)
(provide 'ido-completing-read+)
;;; ido-completing-read+.el ends here
ido-completing-read-plus-4.13/Makefile 0000644 0001750 0001750 00000001257 13514204422 017541 0 ustar dogsleg dogsleg ELISP_FILES := $(shell cask files)
ELC_FILES := $(patsubst %.el,%.elc,$(ELISP_FILES))
.PHONY: test compile clean
.INTERMEDIATE: .compile.intermediate
all: test
# We run clean-elc first because undercover.el doesn't support elc
# files. We run the tests first without loading flx-ido, and then with
# it. We only send the coverage report when running the full test
# suite.
test: clean
cask exec buttercup -L . tests
test-with-flx: clean
cask exec buttercup -l tests/setup-undercover.el -L . tests tests-with-flx-ido
all-tests: test test-with-flx
compile: $(ELC_FILES)
$(ELC_FILES): .compile.intermediate
.compile.intermediate: $(ELISP_FILES)
cask build
clean:
cask clean-elc
ido-completing-read-plus-4.13/Cask 0000644 0001750 0001750 00000000402 13514204422 016674 0 ustar dogsleg dogsleg (source gnu)
(source melpa)
(package-file "ido-completing-read+.el")
(depends-on "s")
(depends-on "memoize" "1.1")
(development
(depends-on "flx-ido")
(depends-on "with-simulated-input" "2.2")
(depends-on "buttercup" "1.9")
(depends-on "undercover"))
ido-completing-read-plus-4.13/tests-with-flx-ido/ 0000755 0001750 0001750 00000000000 13514204422 021547 5 ustar dogsleg dogsleg ido-completing-read-plus-4.13/tests-with-flx-ido/test-ido-completing-read+-with-flx-ido.el 0000644 0001750 0001750 00000024312 13514204422 031257 0 ustar dogsleg dogsleg ;;; -*- lexical-binding: t -*-
;; This file contains tests specifically for ido-cr+ interoperating
;; with flx-ido. These tests were split out from the main test file,
;; which unfortunately means that they brought a lot of the
;; scaffolding from the main test file with them. This might get
;; cleaned up at a later date. Putting these in a separate file is
;; necessary so that the main test suite can be both with and without
;; flx-ido loaded.
(require 'ido)
(require 'flx-ido)
(require 'minibuf-eldef)
(require 'ido-completing-read+)
(require 'buttercup)
(require 'cl-lib)
(require 'with-simulated-input)
(defun collection-as-function (collection)
"Return a function equivalent to COLLECTION.
The returned function will work equivalently to COLLECTION when
passed to `all-completions' and `try-completion'."
(completion-table-dynamic (lambda (string) (all-completions string collection))))
(defun shadow-var (var &optional temp-value)
"Shadow the value of VAR.
This will push the current value of VAR to VAR's
`shadowed-values' property, and then set it to TEMP-VALUE. To
reverse this process, call `unshadow-var' on VAR. Vars can
be shadowed recursively, and must be unshadowed once for each
shadowing in order to restore the original value. You can think
of shadowing as dynamic binding with `let', but with manual
control over when bindings start and end.
If VAR is a Custom variable (see `custom-variable-p'), it will be
set using `customize-set-variable', and if TEMP-VALUE is nil it
will be replaces with VAR's standard value.
Other variables will be set with `set-default', and a TEMP-VALUE
of nil will not be treated specially.
`shadow-var' only works on variables declared as special (i.e.
using `defvar' or similar). It will not work on lexically bound
variables."
(unless (special-variable-p var)
(error "Cannot shadow lexical var `%s'" var))
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(temp-value (or temp-value
(and use-custom
(eval (car (get var 'standard-value)))))))
;; Push the current value on the stack
(push (symbol-value var) (get var 'shadowed-values))
(funcall setter var temp-value)))
(defun var-shadowed-p (var)
"Return non-nil if VAR is shadowed by `shadow-var'."
;; We don't actually want to return that list if it's non-nil.
(and (get var 'shadowed-values) t))
(defun unshadow-var (var)
"Reverse the last call to `shadow-var' on VAR."
(if (var-shadowed-p var)
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(value (pop (get var 'shadowed-values))))
(funcall setter var value))
(error "Var is not shadowed: %s" var)))
(defun fully-unshadow-var (var)
"Reverse *all* calls to `shadow-var' on VAR."
(when (var-shadowed-p var)
(let* ((use-custom (custom-variable-p var))
(setter (if use-custom 'customize-set-variable 'set-default))
(value (car (last (get var 'shadowed-values)))))
(put var 'shadowed-values nil)
(funcall setter var value))))
(defun fully-unshadow-all-vars (&optional vars)
"Reverse *all* calls to `shadow-var' on VARS.
If VARS is nil, unshadow *all* variables."
(if vars
(mapc #'fully-unshadow-var vars)
(mapatoms #'fully-unshadow-var))
nil)
(defmacro shadow-vars (varlist)
"Shadow a list of vars with new values.
VARLIST describes the variables to be shadowed with the same
syntax as `let'.
See `shadow-var'."
(declare (indent 0))
(cl-loop
with var = nil
with value = nil
for binding in varlist
if (symbolp binding)
do (setq var binding
value nil)
else
do (setq var (car binding)
value (cadr binding))
collect `(shadow-var ',var ,value) into exprs
finally return `(progn ,@exprs)))
(defmacro unshadow-vars (vars)
"Un-shadow a list of VARS.
This is a macro for consistency with `shadow-vars', but it will
also accept a quoted list for the sake of convenience."
(declare (indent 0))
(when (eq (car vars) 'quote)
(setq vars (eval vars)))
`(mapc #'unshadow-var ',vars))
(describe "Within the `ido-completing-read+' package"
;; Reset all of these variables to their standard values before each
;; test, saving the previous values for later restoration.
(before-each
(shadow-vars
((ido-mode t)
(ido-ubiquitous-mode t)
(ido-cr+-debug-mode t)
ido-cr+-auto-update-blacklist
ido-cr+-fallback-function
ido-cr+-max-items
ido-cr+-function-blacklist
ido-cr+-function-whitelist
ido-cr+-nil-def-alternate-behavior-list
ido-cr+-replace-completely
ido-confirm-unique-completion
ido-enable-flex-matching
ido-enable-dot-prefix
flx-ido-mode
(minibuffer-electric-default-mode t)))
;; Suppress all messages during tests
(spy-on 'message))
;; Restore the saved values after each test
(after-each
(fully-unshadow-all-vars))
(describe "the `ido-completing-read+' function"
(describe "with dynamic collections"
(before-all
(setq my-dynamic-collection
(completion-table-dynamic
(lambda (text)
(cond
;; Sub-completions for "hello"
((s-prefix-p "hello" text)
'("hello" "hello-world" "hello-everyone" "hello-universe"))
;; Sub-completions for "goodbye"
((s-prefix-p "goodbye" text)
'("goodbye" "goodbye-world" "goodbye-everyone" "goodbye-universe"))
;; General completions
(t
'("hello" "goodbye" "helicopter" "helium" "goodness" "goodwill")))))))
(after-all
(setq my-dynamic-collection nil))
(before-each
(setq ido-enable-flex-matching t
ido-confirm-unique-completion nil)
(spy-on 'ido-cr+-update-dynamic-collection
:and-call-through))
(describe "with flx-ido-mode"
(before-each
(flx-ido-mode 1)
(flx-ido-reset))
(it "should allow selection of dynamically-added completions"
(expect
(with-simulated-input "hello-w RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal "hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should allow ido flex-matching of dynamically-added completions"
(expect
(with-simulated-input "hello-ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when pressing TAB"
(expect
(with-simulated-input "h TAB -ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when idle"
(expect
(with-simulated-input
'("h"
(wsi-simulate-idle-time (1+ ido-cr+-dynamic-update-idle-time))
"-ld RET")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should do a dynamic update when there is only one match remaining"
(expect
(with-simulated-input "hell-ld RET"
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should not exit with a unique match if new matches are dynamically added"
(expect
(with-simulated-input '("hell TAB -ld RET")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"hello-world")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should exit with a match that is still unique after dynamic updating"
(expect
(with-simulated-input '("helic TAB")
(ido-completing-read+ "Say something: " my-dynamic-collection))
:to-equal
"helicopter")
(expect 'ido-cr+-update-dynamic-collection
:to-have-been-called))
(it "should respect `ido-restrict-to-matches' when doing dynamic updates"
(let ((collection
(list "aaa-ddd-ggg" "aaa-eee-ggg" "aaa-fff-ggg"
"bbb-ddd-ggg" "bbb-eee-ggg" "bbb-fff-ggg"
"ccc-ddd-ggg" "ccc-eee-ggg" "ccc-fff-ggg"
"aaa-ddd-hhh" "aaa-eee-hhh" "aaa-fff-hhh"
"bbb-ddd-hhh" "bbb-eee-hhh" "bbb-fff-hhh"
"ccc-ddd-hhh" "ccc-eee-hhh" "ccc-fff-hhh"
"aaa-ddd-iii" "aaa-eee-iii" "aaa-fff-iii"
"bbb-ddd-iii" "bbb-eee-iii" "bbb-fff-iii"
"ccc-ddd-iii" "ccc-eee-iii" "ccc-fff-iii")))
;; Test the internal function
(expect
(ido-cr+-apply-restrictions
collection
(list (cons nil "bbb")
(cons nil "eee")))
:to-equal '("bbb-eee-ggg" "bbb-eee-hhh" "bbb-eee-iii"))
;; First verify it without a dynamic collection
(expect
(with-simulated-input "eee C-SPC bbb C-SPC ggg RET"
(ido-completing-read+
"Pick: " collection nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg")
;; Now test the same with a dynamic collection
(expect
(with-simulated-input "eee C-SPC bbb C-SPC ggg RET"
(ido-completing-read+
"Pick: " (collection-as-function collection) nil t nil nil (car collection)))
:to-equal "bbb-eee-ggg")))))))
;;; test-ido-completing-read+.el ends here