Turns out that calling `file-directory-p' in `cl-sort' is too expensive.
So when `ivy-sort-file-function' is `ivy-sort-file-function-default',
propertize all strings with whether they are directories or not.
When `ivy-sort-file-function' is something different,
e.g. `string-lessp', don't do propertizing since it also can be slow.
Oleh Krehel [Mon, 20 Apr 2015 08:55:18 +0000 (10:55 +0200)]
Allow "C-." to jump to current symbol definition
* counsel.el (counsel-describe-map): New defvar.
(counsel-find-symbol): New defun.
(counsel--find-symbol): New defun - jump to definition of function or
symbol or library.
(counsel-describe-variable): Use `counsel-describe-map'.
(counsel-describe-function): Use `counsel-describe-map'.
Oleh Krehel [Sun, 19 Apr 2015 13:26:23 +0000 (15:26 +0200)]
Add a matching optimization
* ivy.el (ivy-completions): When the new regex `re' is a contains the
old regex `ivy--old-re', it must be true that all candidates that
match `re' are contained inside all candidates that match
`ivy--old-re', i.e. the pre-computed in the last step
`ivy--old-cands'.
This should speed up completion for large (~100k) amount of candidates,
for the particular case of regex simply being extended.
Oleh Krehel [Sat, 18 Apr 2015 18:12:45 +0000 (20:12 +0200)]
swiper.el: Add a work-around for window-start not being current
* swiper.el (swiper--update-input-ivy): Update.
This results in double the window-height amount of lines being
heightlighted, instead of just window-height. But at least it doesn't
happen that some candidates within the current window aren't highlighted
since they're beyond the outdated window-start and window-end.
An alternative would be to use `redisplay' to update `window-start' and
`window-end', but that causes excessive blinking.
Oleh Krehel [Sat, 18 Apr 2015 16:13:05 +0000 (18:13 +0200)]
Add a work-around for completing topics in the info dir
* ivy.el (ivy-read): Weirdly, the topic names need to be wrapped in
"(...)". Also, `all-completions' returns nothing for "", but returns
stuff for "(". Also, `all-completions' for "(" returns plenty of
duplicates.
Oleh Krehel [Fri, 17 Apr 2015 11:29:41 +0000 (13:29 +0200)]
Add sorting for file completion
* ivy.el (ivy-alt-done): Exit with current directory when on first
element, which is always "./", thanks to sorting.
(ivy--cd): Update.
(ivy--sorted-files): New defun for sorting file names. "./" and "../"
are always the first, then come the directories, then the files.
(ivy-read): Update.
Oleh Krehel [Fri, 17 Apr 2015 10:53:43 +0000 (12:53 +0200)]
Add "/" and "~" shortcuts while finding files
* ivy.el (ivy--cd): New defun.
(ivy-backward-delete-char): Use `ivy--cd'.
(ivy--exhibit): When the file completion text ends in "/" or "~", move to
those dirs.
Oleh Krehel [Thu, 16 Apr 2015 19:20:42 +0000 (21:20 +0200)]
Ivy-mode now works better with `find-file'
* ivy.el (ivy-minibuffer-map): Bind "C-j" to visit a directory without
exiting the minibuffer.
(ivy--directory): New defvar.
(ivy-done): Expand file names.
(ivy-alt-done): New defun.
(ivy-backward-delete-char): When completing file names, visit the parent dir.
(ivy-read): Add the predicate argument, similar to `completing-read'.
All code that uses `ivy-read' needs to be updated. Move the collection/predicate stuff here.
(ivy-completing-read): Update.
(ivy--insert-prompt): Display the current directory when completing file names.
Oleh Krehel [Thu, 16 Apr 2015 16:26:52 +0000 (18:26 +0200)]
Add require-match functionality
* ivy.el (ivy-require-match): New defvar.
(ivy-done): When nothing matches, and `ivy-require-match' isn't t, use
the current text anyway.
(ivy-completing-read): Update.
Oleh Krehel [Thu, 9 Apr 2015 14:08:23 +0000 (16:08 +0200)]
Add four more commands
* counsel.el (counsel-describe-variable): New defun.
(counsel-describe-function): New defun.
(counsel-info-lookup-symbol): New defun.
(counsel-unicode-char): New defun.
Oleh Krehel [Fri, 27 Mar 2015 18:50:05 +0000 (19:50 +0100)]
swiper.el (swiper-map): Bind "C-l" to recenter
* swiper.el (swiper-map): Update.
(swiper-recenter-top-bottom): New defun.
(swiper--update-input-ivy): Use `<=' in order for `recenter-top-bottom'
to work.
Oleh Krehel [Wed, 25 Mar 2015 18:36:47 +0000 (19:36 +0100)]
Allow to cancel "M-q" with "C-g"
swiper.el (swiper-query-replace): If the TO argument to
`perform-replace' isn't read, don't exit minibuffer.
If the user called `swiper-query-replace' and isn't happy with the
current input being the FROM arg of `perform-replace', it's possible to
cancel with "C-g", and edit the input once again.
Oleh Krehel [Wed, 25 Mar 2015 11:53:51 +0000 (12:53 +0100)]
Add swiper-query-replace
* ivy.el (ivy-read): Update signature - a keymap is also accepted and
the argument order has changed.
The keymap is composed with `ivy-minibuffer-map'.
Update for `ivy--action'.
(ivy--action): New defvar. If a function sets it, `ivy-read' will call it.
* swiper.el (swiper-map): New defvar.
(swiper-query-replace): New defun.
(swiper--ivy): Use swiper-map in the call to `ivy-read'.
* counsel.el (couns-git): Fix one empty candidate.
Oleh Krehel [Mon, 23 Mar 2015 20:20:03 +0000 (21:20 +0100)]
Ensure that inserted candidates don't have read-only property
* ivy.el (ivy-completions): Update.
Fixes #28.
The issue was that the whole text of erc buffer has (read-only t)
property. That means if I copy some of those strings and insert them
into the minibuffer, I can't delete them unless I set
`inhibit-read-only' to t. Instead, I set the read-only to nil for the
string that I insert. It doesn't affect the original buffer string.
John Mastro [Sat, 21 Mar 2015 22:23:40 +0000 (15:23 -0700)]
ivy.el (ivy-wrap): New defcustom
(ivy-next-line): Wrap around if `ivy-wrap' is non-nil
(ivy-next-line-or-history): Wrap around if `ivy-wrap' is non-nil
(ivy-previous-line): Wrap around if `ivy-wrap' is non-nil
(ivy-previous-line-or-history): Wrap around if `ivy-wrap' is non-nil
Oleh Krehel [Sat, 21 Mar 2015 16:47:50 +0000 (17:47 +0100)]
Update "C-n" and "C-p" bindings
* ivy.el (ivy-next-line): Don't touch history.
(ivy-next-line-or-history): Select previous history element if there's
no input.
(ivy-previous-line): Don't touch history.
(ivy-previous-line-or-history): Select previous history element if
there's no input.
Oleh Krehel [Sat, 21 Mar 2015 15:35:54 +0000 (16:35 +0100)]
Use `font-lock-append-text-property' to non-destructively modify a
string
* ivy.el (ivy--add-face): Improve.
`font-lock-append-text-property' non-destructively changes properties in
a string, which means if a string was copied from another and modified,
the original will not be changed.
In this way, it's better than `add-face-text-property'; and still better
than `propertize' that simply erases all properties before applying.
Oleh Krehel [Thu, 19 Mar 2015 18:11:06 +0000 (19:11 +0100)]
ivy.el (ivy-read): Allow for format-style PROMPT
* ivy.el (ivy-read): When given a prompt of e.g. "%d pattern: ", update
the number of candidates in the prompt.
(ivy--prompt): New defvar.
(ivy--insert-prompt): New defun.
(ivy--exhibit): Call `ivy--insert-prompt'.
(ivy-completions): Fix a bug of `ivy--index' becoming -1 when the number
of matches becomes zero.
* swiper.el (swiper--format-spec): New defvar.
(swiper--candidates): Update.
(swiper--ivy): Use `swiper--format-spec' to make the prompt.
Oleh Krehel [Thu, 19 Mar 2015 17:44:36 +0000 (18:44 +0100)]
ivy.el (ivy-read): Change index to preselect
* ivy.el (ivy-read): Update signature. Instead of giving the integer
index of what to preselect, give a string to preselect.
(ivy--preselect-index): New defun.
* swiper.el (swiper--index-at-point): Rename to `ivy--preselect-index'.
(swiper--ivy): Simplify.
Oleh Krehel [Wed, 18 Mar 2015 18:04:15 +0000 (19:04 +0100)]
Add isearch-like history behavior
* ivy.el (ivy-next-line): Select previous history element for empty
input.
(ivy-previous-line): Select previous history element for empty input.
(ivy-previous-history-element): New defun.
(ivy-next-history-element): New defun.