`swiper--candidates' replaces "\t" with four spaces for a consistent
look in the minibuffer. By the domino effect, this affects
`swiper--re-builder' and `swiper--update-input-ivy'.
Oleh Krehel [Mon, 22 Feb 2016 15:32:31 +0000 (16:32 +0100)]
ivy.el (ivy--preselect-index): Don't use regexp-quote
I don't remember why `regexp-quote' was needed in the first place. But
it's useful to have it as a regex at least for `lispy--occur-preselet'
which returns things like "^42" to preselect line 42.
Oleh Krehel [Fri, 19 Feb 2016 14:29:36 +0000 (15:29 +0100)]
counsel.el (counsel-locate-options): Make obsolete
* counsel.el (counsel-locate-cmd): New defcustom that replaces
`counsel-locate-options'.
(counsel-locate-cmd-default): New defun. Corresponds to the default
value of `counsel-locate-options' on linux.
(counsel-locate-cmd-noregex): New defun. Corresponds to the default
value of `counsel-locate-options' on darwin.
(counsel-locate-function): Use `counsel-locate-cmd'.
Oleh Krehel [Sun, 14 Feb 2016 09:10:17 +0000 (10:10 +0100)]
Fix an extra action being called for `completing-read'
* ivy.el (ivy-read): `ivy-call' got confused for a combination of
`completing-read' and `ivy-set-actions t` - since there was no first
action, the first of the extra actions was assumed to be that.
Now put `identity' as the first action for `completing-read'.
Oleh Krehel [Thu, 11 Feb 2016 16:21:44 +0000 (17:21 +0100)]
Customize ivy-occur per command with ivy-set-occur
* ivy.el (ivy--occurs-list): New defvar.
(ivy-set-occur): New API function for defining custom occur behavior.
(ivy--occur-insert-lines): New defun.
(ivy-occur): Simplify, move counsel-git-grep specific stuff away.
* counsel.el (counsel-git-grep-occur): New defun. Sets up an occur
buffer with a mode that derives from `grep-mode' that means that the
error functions (`next-error' etc) etc are available. Also allows to
edit the contents with `wgrep' by pressing "C-x C-q".
* swiper.el (swiper-occur): New defun, similar to
`counsel-git-grep-occur'. Except it turns off `font-lock-mode' to keep
the original syntax-highlighted faces.
(swiper--action): Update to make it work from ivy-occur buffers.
Oleh Krehel [Tue, 9 Feb 2016 09:28:53 +0000 (10:28 +0100)]
doc/ivy.org: Improve the markup
* doc/ivy.org (defopt): Get rid of the macro.
(Writing this manual): New section.
Use a lot more definition lists - they look nice in both HTML and
Texinfo export.
(Hydra in the minibuffer): Extend the section.
(Saving the current completion session to a buffer): Extend.
* doc/ivy-ox.el (org-texinfo-plain-list): Improve the user-option
formatting.
Stephen Whipple [Mon, 8 Feb 2016 10:41:15 +0000 (03:41 -0700)]
Add ignore pattern toggling
* ivy.el (ivy-minibuffer-map): Bind "C-c C-a" to `ivy-toggle-ignore'.
(ivy-use-ignore): New defvar.
(ivy-toggle-ignore): New command to toggle ignore
patterns (user-configured filtering). If the ignore patterns are enabled
and there are zero candidates after ignoring, display the ones that
match the current text. This feature currently works for
`ivy-switch-buffer' and `counsel-find-file'.
(ivy--buffer-list): Simplify.
(ivy--switch-buffer-matcher): New defun.
(ivy-switch-buffer): Use `ivy--switch-buffer-matcher'.
* counsel.el (counsel--find-file-matcher): Use `ivy-use-ignore'.
Oleh Krehel [Mon, 1 Feb 2016 19:21:19 +0000 (20:21 +0100)]
Allow to compose static collections with `counsel--async-command'
* ivy.el (ivy--sources-list): New defvar.
(ivy-set-sources): New defun that sets `ivy--sources-list'
(ivy--extra-candidates): New defvar.
(ivy-read): Use `ivy--sources-list' to set `ivy--extra-candidates' - a
list that composes itself with `ivy--all-candidates'.
(ivy--set-candidates): New defun.
Example - stack `recentf' on top of `counsel-locate':
Here, (original-source) represents the async candidates of
`counsel-locate'. All extra sources are static - each function is called
once to generate a list of strings, which will be filtered later.
Oleh Krehel [Mon, 1 Feb 2016 17:38:57 +0000 (18:38 +0100)]
Modify "M-n" prediction when region is active
* ivy.el (ivy--reset-state): When the region is active and "M-n" is
called, insert the region contents into the minibuffer and deactivate
the region. The region deactivation is done for `swiper', to make it
easier to search for multiple words or a subword.
Oleh Krehel [Thu, 28 Jan 2016 16:37:23 +0000 (17:37 +0100)]
counsel.el (counsel-yank-pop): Truncate during display
* counsel.el (counsel-yank-pop-truncate): Remove defcustom.
(counsel-yank-pop-truncate-radius): New defcustom.
(counsel--yank-pop-truncate): New defun.
(counsel--yank-pop-format-function): New defun.
During the completion, only the context around the match will be shown.
By default, the context is +2 lines above and +2 lines below the match.
It can be adjusted with `counsel-yank-pop-truncate-radius'.
Additionally, `ivy-height' is temporarily bound to 5 during completion.
This way, the maximum minibuffer height should be 1+4*5=21 lines.
* ivy.el (ivy-ffap-url-functions): New defvar.
(ivy--cd-maybe): When calling a function in `ivy-ffap-url-functions'
results in a string, stop completion and open that string with
`ffap-url-fetcher'.
* counsel.el (counsel-github-url-p): New defun.
(ivy-ffap-url-functions): Add `counsel-github-url-p' to the list.
This feature allows to quickly visit Github issues from either
`magit-commit-mode' or from a version-controlled file. The point has to
be at the "#" char in e.g. "#123", that represents an issue.
It's possible to customize `ivy-ffap-url-functions' to do a similar
thing for places other than Github.
The "C-x C-f M-n" key binding will work better with `counsel-find-file',
for plain `find-file' it will open a `dired' buffer in addition to
opening the URL.
Oleh Krehel [Mon, 18 Jan 2016 13:10:54 +0000 (14:10 +0100)]
Fix swiper "backward" search
* ivy.el (ivy-recompute-index-swiper): When none of the previous
candidates after the point match the current input, instead of
returning 0, return the index of the last matching candidate. This is
a good choice, because that candidate is the closest to the point of
the initial search start.
Stephen Whipple [Fri, 15 Jan 2016 12:24:29 +0000 (05:24 -0700)]
Special case empty ivy-count-format completion.
- Switch ivy-count-format test to empty string rather than nil.
- Since the prompt is based on user input, sanitize the prompt to
later be formatted, except in the case of empty ivy-count-format.
Oleh Krehel [Tue, 12 Jan 2016 13:46:31 +0000 (14:46 +0100)]
Add counsel-descbinds
* ivy.el (ivy-read-action): Update prompt for "C-M-a".
* counsel.el (counsel--find-symbol): Use ivy-window.
(counsel--descbinds-cands): New defun.
(counsel-descbinds-history): New defvar.
(counsel-descbinds-action-describe): New defun.
(counsel-descbinds-action-find): New defun.
(counsel-descbinds-action-info): New defun.
(counsel-descbinds): New command. Very similar to `counsel-M-x', except
that only bound commands are displayed.
justbur [Tue, 12 Jan 2016 00:26:09 +0000 (19:26 -0500)]
counsel: Add counsel-up-directory to find-file-map
New function that moves up to the parent directory and at the same time
preselects the current directory. This is useful for moving up and down
a file tree quickly.
Oleh Krehel [Fri, 8 Jan 2016 08:38:04 +0000 (09:38 +0100)]
ivy.el (ivy-completion-in-region): Fix a few bugs
* ivy.el (ivy-completion-common-length): New defun.
`all-completions' doesn't always return candidates that can replace the
whole region between BEG and END. That's why
`completion-all-completions' should be used, which marks the common part
with 'completions-common-part face. Then the new region to replace is
((- END common-length) . END).
Note also that `text-property-any' doesn't always work in
`ivy-completion-common-length', since the 'face property can be a list.
(ivy-completion-in-region): Set `enable-recursive-minibuffers'.
Oleh Krehel [Thu, 7 Jan 2016 16:27:47 +0000 (17:27 +0100)]
Properly support matching ignoring order
* ivy.el (ivy--regex-ignore-order): Return a list of regexps rather than
a single regexp.
(ivy--re-filter): New defun, extracted from `ivy--filter'.
(ivy--filter): Update.
(ivy--format-minibuffer-line): Add special highlighting for
`ivy--regex-ignore-order'.
* counsel.el (counsel--find-file-matcher): Use `ivy--re-filter'.
Felix Lange [Wed, 6 Jan 2016 22:28:24 +0000 (23:28 +0100)]
ivy: fix ivy--resize-minibuffer-to-fit for small delta
Very small size increments can be necessary if the initial candidate
list is short (e.g. 3 items) and line-height is set to something other
than zero. In that case, only half of the last line is initially
visible. ivy--resize-minibuffer-to-fit recognizes this and tries to
enlarge the window up the the exact pixel height required, however
window-resize doesn't do anything if the delta is below
frame-char-height.