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.
This is specifically for 'read-file-name-internal collection.
The input needs to be set to nil for e.g. `rgrep', which supplies
the *absolute* path as `initial-input', resulting in a mess.
For now, don't set input to nil if :action was passed to `ivy-read'.
Oleh Krehel [Tue, 5 Jan 2016 14:32:18 +0000 (15:32 +0100)]
ivy.el (ivy-mode): Set completing-read-function
* ivy.el (ivy-completion-beg): Rename from `counsel-completion-beg'.
(ivy-completion-end): Rename from `counsel-completion-end'.
(ivy-completion-in-region-action): Rename from `counsel--el-action'.
(ivy-completion-in-region): New defun.
(ivy-mode): Set `completing-read-function' to 'ivy-completion-in-region.
Oleh Krehel [Tue, 5 Jan 2016 10:39:15 +0000 (11:39 +0100)]
counsel.el (counsel-git): Fix window selection
* counsel.el (counsel--git-dir): New defvar.
(counsel-git): Update.
(counsel-git-action): New defun. Use `with-ivy-window', so that each new
file chosen with e.g. "C-M-n" is selected in the same window.
justbur [Thu, 31 Dec 2015 22:05:11 +0000 (17:05 -0500)]
Add cousel-ag-base-command var
Allows the command run by counsel-ag-function to be customized. There
are several reasons to allow this: The vimgrep option is a recent
addition; on windows it's more convenient to use pt; and the user might
want to customize ignored files.
Oleh Krehel [Thu, 17 Dec 2015 08:45:30 +0000 (09:45 +0100)]
Fix ivy-reverse-i-search broken by recursive update
* ivy.el (ivy-recursive-restore): New defvar.
(ivy-read): Don't restore `ivy-last' on exit if `ivy-recursive-restore'
is nil.
(ivy-reverse-i-search): Bind `ivy-recursive-restore' to nil.
Oleh Krehel [Sat, 12 Dec 2015 08:41:07 +0000 (09:41 +0100)]
Improve swiper for multiple occurrences on one line
* swiper.el (swiper--current-line):
(swiper--current-match-start): New defvar.
(swiper--init): Update.
(swiper--update-input-ivy): Don't move to line NUM if
`swiper--current-line' is equal to NUM. Later, store NUM in
`swiper--current-line' to avoid calling `line-number-at-pos'.
Additionally store `swiper--current-match-start' - it's necessary to
move there before searching for the regexp, since the point currently is
after the old regexp.
Oleh Krehel [Fri, 4 Dec 2015 07:30:17 +0000 (08:30 +0100)]
swiper.el (swiper--update-input-ivy): Add a work-around for "M-j"
When `ivy-yank-word' is called, don't move to the line of the current
candidate. We're already there anyway. And not moving helps when there
are multiple occurrences of the current input on the current line.
Oleh Krehel [Sun, 29 Nov 2015 16:01:35 +0000 (17:01 +0100)]
Fix due to visual-line-mode weirdness
* swiper.el (swiper--candidates): Under a specific random condition,
(line-move 1) from the beginning of line doesn't move to the beginning
of the next visual line.
This change fixes it, but will result in an even slower startup when
`visual-line-mode' is active.
Oleh Krehel [Sun, 29 Nov 2015 10:15:17 +0000 (11:15 +0100)]
Fix ivy-resume issue caused by the recursive calls change
* ivy.el (ivy-read): recursive-ivy-last is only set if there's an active
minibuffer window. If this check isn't made, it causes the previous
`ivy-last' to be reset after the current one, so `ivy-resume' would
resume not the last command.
Oleh Krehel [Sun, 29 Nov 2015 10:13:45 +0000 (11:13 +0100)]
Fix the preselect for (swiper "one") again
* ivy.el (ivy--reset-state): Take into account :preselect being integer.
This means that it's void once the candidates are filtered over
:initial-input.
Oleh Krehel [Thu, 26 Nov 2015 11:52:34 +0000 (12:52 +0100)]
Ease production of functions like ivy-format-function-default
* ivy.el (ivy--format-function-generic): New defun.
(ivy-format-function-default):
(ivy-format-function-arrow):
(ivy-format-function-line): Use `ivy--format-function-generic'.
* counsel.el (counsel--M-x-transformer): Add an extra space to simplify
the logic.
Stephen Whipple [Thu, 26 Nov 2015 07:07:16 +0000 (00:07 -0700)]
Convert ivy formatting functions to dotted pairs.
`ivy-format-function' now expects to operate on dotted pairs
representing (stub . extra), where `stub' is the original
candidate and `extra' is any extra information that has been
added by counsel or other libraries.
The format function can differentiate between the original stub
and extra information and choose how to display the result to
the user.
Oleh Krehel [Wed, 25 Nov 2015 14:24:58 +0000 (15:24 +0100)]
Add counsel-grep
* ivy.el (ivy--reset-state): Don't push preselect onto collection for
:dynamic-collection.
(ivy-recompute-index-swiper-async): New defun. It's useful for
re-anchoring on collections produced async processes. The major
difference from `ivy-recompute-index-swiper' is using `equal' instead of `eq'.
* counsel.el (counsel--async-sentinel): Add index recomputing logic.
When `ivy--old-cands' are null, recompute the index according to
:preselect, otherwise try `ivy--recompute-index'.
(counsel-grep): New command. Very similar to `swiper', except calls an
external process for each key update. Should be much faster for very
large files, both for startup and for matching. For smaller files, it's
less convenient.
(counsel-grep-function): New defun.
(counsel-grep-action): New defun.
Oleh Krehel [Tue, 24 Nov 2015 11:09:37 +0000 (12:09 +0100)]
Fix broken candidate index in ivy-resume
* ivy.el (ivy--reset-state): When given initial-input, call
`ivy--preselect-index' on candidates filtered by initial-input. This
is important for `ivy-resume'.