Oleh Krehel [Mon, 11 May 2015 14:02:57 +0000 (16:02 +0200)]
When completing file names, defer to `minibuffer-complete' for "TAB"
* ivy.el (ivy-partial-or-done): Call `minibuffer-complete'. If the
resulting text is a valid directory, move there.
(ivy-read): Setup `minibuffer-completion-table' and
`minibuffer-completion-predicate'. This makes `minibuffer-complete'
work.
Oleh Krehel [Mon, 11 May 2015 10:42:56 +0000 (12:42 +0200)]
Allow to customize the minibuffer formatter
* ivy.el (ivy-format-function): New defvar.
(ivy-format-function-default): New defun.
(ivy-format-function-arrow): New defun, alternative for
`ivy-format-function'.
Oleh Krehel [Mon, 11 May 2015 09:07:07 +0000 (11:07 +0200)]
Swiper should use the :re-builder argument
* ivy.el (ivy--transform-re): Remove defun, :re-builder should be used
for this logic.
(ivy--filter): Update.
* swiper.el (swiper-avy): Use `ivy--regex'.
(swiper--init): Don't set `ivy--regex-function' - it will be set by
:re-builder.
(swiper--re-builder): New defun.
(swiper--ivy): Use :re-builder in call to `ivy-read'.
(swiper--update-input-ivy): Use `ivy--regex'.
(swiper--action): Use `ivy--regex'.
Oleh Krehel [Fri, 8 May 2015 15:47:51 +0000 (17:47 +0200)]
Add support for virtual buffers
* ivy.el (ivy-mode-map): New defvar. Remap `switch-to-buffer' to
`ivy-switch-buffer'.
(ivy-mode): Use `ivy-mode-map'.
(ivy--virtual-buffers): New devar.
(ivy--virtual-buffers): New defun.
(ivy-buffer-list): Return a list of buffers, taking
`ido-use-virtual-buffers' into account.
(ivy-switch-buffer): New command.
Oleh Krehel [Wed, 6 May 2015 19:01:14 +0000 (21:01 +0200)]
Try to prevent the resize of minibuffer window
* ivy.el (ivy--insert-minibuffer): Temporarily bind
`resize-mini-windows' to nil.
From its doc:
A value of `grow-only', the default, means let mini-windows grow only;
they return to their normal size when the minibuffer is closed, or the
echo area becomes empty.
It could be that an update catches this minibuffer empty during
`ivy--insert-minibuffer'.
Oleh Krehel [Wed, 6 May 2015 09:49:01 +0000 (11:49 +0200)]
Add parents using 'display for `counsel-load-library'
* counsel.el (counsel--find-symbol): The argument string may have a
'full-name property.
(counsel-string-compose): New defun.
(counsel-load-library): Make libraries unique through text properties.
Oleh Krehel [Wed, 6 May 2015 08:42:17 +0000 (10:42 +0200)]
Add counsel-load-library
* counsel.el (counsel-directory-parent): New defun.
(counsel-load-library): New command.
Improve on `load-library':
- don't consider .*elc or .*pkg.elc?, they're usually useless
- resolve duplicates in a similar way to uniquify (prepend parent directory)
- allow to jump-to-library with "C-." (see `counsel-describe-map')
Oleh Krehel [Wed, 6 May 2015 07:09:04 +0000 (09:09 +0200)]
Work around grep-read-files
* ivy.el (ivy--done): If history is `grep-files-history', the caller is
`grep-read-files'. Don't expand the file name, since it's probably a
glob, and `find' doesn't work with expanded globs.
It should now be possible to simply "M-x" rgrep "RET" "RET" "RET".
Oleh Krehel [Tue, 5 May 2015 08:14:17 +0000 (10:14 +0200)]
Improve "TAB" interaction with `confirm-nonexistent-file-or-buffer'
* ivy.el (ivy-partial-or-done): When
`confirm-nonexistent-file-or-buffer' is t, and there are no
candidates, modify the prompt to "(confirm)" right after the first
"TAB".
Oleh Krehel [Mon, 4 May 2015 07:38:20 +0000 (09:38 +0200)]
ivy.el (ivy-tab-space): New defcustom
* ivy.el (ivy-partial-or-done): Insert an extra space when
`ivy-tab-space' is non-nil. This is useful to complete partially and
start a new group at once.
Oleh Krehel [Sun, 3 May 2015 14:31:47 +0000 (16:31 +0200)]
Add an option for out-of-order matching
* ivy.el (ivy--regex-ignore-order): New defun.
* swiper.el (swiper--init): Set `ivy--regex-function'.
(swiper--update-input-ivy): Use `ivy--regex-function'.
(swiper--action): Use `ivy--regex-function'.
Oleh Krehel [Fri, 1 May 2015 20:01:30 +0000 (22:01 +0200)]
ivy-resume now works for functions that supply action
ivy.el (ivy-resume): Use action
Functions like `counsel-describe-funtion' and `counsel-describe-varible'
are now resume-able: after finishing with "RET" or breaking out with
"C-g" it's possible to resume the query in the same state as it
was (same collection, input, index).
With:
(global-set-key (kbd "C-c C-r") 'ivy-resume)
it's possible to e.g.:
- "F1 f" info read "RET" to describe Info-breadcrumbs
- "C-c C-r" "C-n" to describe Info-read-node-name
- "C-c C-r" "C-n" to describe Info-read-node-name-1
...
Oleh Krehel [Fri, 1 May 2015 19:49:25 +0000 (21:49 +0200)]
Merge ivy--action into ivy-last
* ivy.el (ivy-state): Add action field.
(ivy-set-action): New defun. Just a shortcut to set action.
(ivy--action): Remove defvar.
(ivy-read): Add action argument. Check (ivy-state-action ivy-last) in
the end and call it, since the action can change during the completion.
(ivy--insert-prompt): Add `counsel-find-symbol' to the list.
(ivy--format): If there are no matches, set `ivy--current' to "".
Oleh Krehel [Fri, 1 May 2015 18:01:08 +0000 (20:01 +0200)]
Add ivy-state struct
* ivy.el (ivy-state): New defstruct.
(ivy-last): A single global to store an `ivy-state' struct.
(ivy-require-match): Move into `ivy-last'.
(ivy-done): Update.
(ivy-resume): New defun. Initial draft, kind of works for swiper. Need
to add a callback of what to do with the result as an argument.
(ivy-read): Store all arguments into `ivy-last'.
(ivy-completing-read): Update doc.
Oleh Krehel [Wed, 29 Apr 2015 15:00:54 +0000 (17:00 +0200)]
Update and improve faces
* ivy.el (ivy-subdir): Inherit from dired-directory.
* swiper.el (swiper-match-face-1): Update doc.
(swiper-match-face-2): Update doc.
(swiper-match-face-3): Update doc.
(swiper-match-face-4): Inherit from isearch-fail.
(swiper--add-overlays): Fix the faces order swapping on the second
match.
Now it finally works as planned: face-1 is the background (re group 0),
next it cycles: face-2, face-3, face-4, face-2, face-3, face-4.
Oleh Krehel [Wed, 29 Apr 2015 10:10:09 +0000 (12:10 +0200)]
ivy.el (ivy--exhibit): Fixup last commit
* ivy.el (ivy--old-text): Should always be a string.
(ivy-read): Update.
(ivy--exhibit): Recompute candidates on flip, always set `ivy--old-re'
to nil.
Oleh Krehel [Tue, 28 Apr 2015 08:46:28 +0000 (10:46 +0200)]
Store the preselect and use it for empty ivy-text
* ivy.el (ivy-def): New defvar.
(ivy-read): Store `ivy-def'.
(ivy-completing-read): Update.
(ivy--filter): When the input is empty, set `ivy--index' to select
`ivy-def'.
Oleh Krehel [Sat, 25 Apr 2015 11:44:52 +0000 (13:44 +0200)]
Improve completion history using the propertize trick
* ivy.el (ivy-previous-history-element): Update.
(ivy-next-history-element): Update.
(ivy--maybe-scroll-history): New defun. When the history element string
has ivy-index property, set `ivy--index' to that.
Oleh Krehel [Fri, 24 Apr 2015 10:52:40 +0000 (12:52 +0200)]
Improve the match confirm while completing files
* ivy.el (ivy-confirm-face): New face.
(ivy-match-required-face): New face.
(ivy--prompt-extra): New defvar, the prompt is concatenaded with this.
(ivy--extend-prompt): Remove.
(ivy-done): Update.
(ivy--insert-prompt): Use `ivy--prompt-extra'. Reset it unless the
`this-command' is appropriate.
(ivy--set-match-props): New defun.
Oleh Krehel [Wed, 22 Apr 2015 13:37:11 +0000 (15:37 +0200)]
ivy.el (ivy--exhibit): Wrap in `while-no-input'
* ivy.el (ivy--exhibit): `ivy--dynamic-function' will sometimes use
`call-process'. Adding `while-no-input' speeds up things a lot, at the
cost of a small message interrupting the minibuffer when
`call-process' takes too long or the user types too fast.
This message is not an issue for emacs-snapshot.
Oleh Krehel [Wed, 22 Apr 2015 13:36:46 +0000 (15:36 +0200)]
Bind "M-q" to `ivy-toggle-regexp-quote'
* ivy.el (ivy-minibuffer-map): Update.
(ivy--regexp-quote): New defvar.
(ivy-toggle-regexp-quote): New command, toggle `ivy--regex-function'
between the value selected in `ivy-read' and `ivy--regexp-quote'.
(ivy-read): Reset `ivy--regexp-quote' to 'regexp-quote.
Oleh Krehel [Wed, 22 Apr 2015 10:59:21 +0000 (12:59 +0200)]
ivy.el (ivy-done): Be more strict for `require-match'
When `require-match' isn't in (nil confirm confirm-after-completion),
don't allow to exit if there isn't a match. Instead, amend the prompt
with "(match required)".
Oleh Krehel [Wed, 22 Apr 2015 10:56:19 +0000 (12:56 +0200)]
Change `ivy-read' to a cl-defun
* ivy.el (ivy-read): All args but PROMPT and COLLECTION are now keys.
The existing basic calls to `ivy-read' should still work, the others
need to be updated. It's best to try to use `ivy-completing-read' if
possible, since it conforms to the `completing-read' arguments.
New arguments: REQUIRE-MATCH and HISTORY. If HISTORY is nil, `ivy-history'
is used.
(ivy--sorted-files): Don't try to extend the collection.
(ivy-completing-read): Update.
* swiper.el (swiper--ivy): Update.
* counsel.el (counsel-describe-symbol-history): New defvar.
(counsel-describe-variable): Update the call, require match, use
`counsel-describe-symbol-history'.
(counsel-describe-function): Update the call, require match, use
`counsel-describe-symbol-history'.
* ivy-test.el: Update tests, since zero and one length input doesn't
return immediately any more.