Oleh Krehel [Thu, 15 Oct 2015 13:28:38 +0000 (15:28 +0200)]
Add feedback for long-running async processes
* counsel.el (counsel--async-time): New defvar.
(counsel--async-filter): New defun.
(counsel--async-command): Use `counsel--async-filter'.
Each time 0.5s pass after the last input, if the external process hasn't
finished yet, update minibuffer with the amount of candidates collected
so far. This is useful to see that long running commands like
`counsel-locate' or `counsel-ag' (when in a very large directory) aren't
stuck.
Oleh Krehel [Wed, 14 Oct 2015 16:35:03 +0000 (18:35 +0200)]
Adjust the swiper regexp builder for the display change
* swiper.el (swiper--re-builder): Update. The old re-builder was for
when the line numbers were part of the candidates. Now the line
numbers are the text properties of the candidates.
Oleh Krehel [Wed, 14 Oct 2015 12:55:02 +0000 (14:55 +0200)]
Fix "C-x h" selection and "C-b" bug
* ivy.el (ivy--exhibit): Add another `constrain-to-field'.
This ensures that the point doesn't cross into the prompt text.
Previously, there was a bug that pressing "C-b" once more when already
at the start of the input set `ivy-text' to "", i.e. ignoring the
minibuffer input.
Oleh Krehel [Sat, 10 Oct 2015 11:09:24 +0000 (13:09 +0200)]
ivy.el (ivy-case-fold-search): New defvar
* ivy.el (ivy--reset-state): Set `ivy-case-fold-search' to 'auto.
(ivy-toggle-case-fold): New command.
(ivy--filter): Use `ivy-case-fold-search' to determine `case-fold-search'.
* ivy-hydra.el (hydra-ivy): Bind "C" to `ivy-toggle-case-fold'.
Oleh Krehel [Thu, 8 Oct 2015 12:31:37 +0000 (14:31 +0200)]
Move setq ivy--index to ivy--recompute-index
* ivy.el (ivy--recompute-index): Move the setq statement here, so that
the customization functions have less internal variables to deal with.
(ivy-recompute-index-swiper): Update.
(ivy-recompute-index-zero): Update.
Oleh Krehel [Thu, 8 Oct 2015 12:13:32 +0000 (14:13 +0200)]
ivy.el (ivy-index-functions-alist): New variable
* ivy.el (ivy-state): Add `caller' field.
(ivy-read): Add `caller' keyword arg; update docstring. Use
`ivy--recompute-index'.
(ivy--recompute-index): New defun, dispatch according to `caller' and
`ivy-index-functions-alist'.
(ivy-recompute-index-swiper): New defun.
(ivy-recompute-index-zero): New defun.
Oleh Krehel [Wed, 7 Oct 2015 12:14:35 +0000 (14:14 +0200)]
Fix ivy-state-preselect for file name completion
* ivy.el (ivy--preselect-index): Add a check for null preselect.
(ivy--filter): Use `ivy--preselect-index' instead of `cl-position'. The
reason is that the collection contains e.g "foo/" while the preselect is "foo".
Oleh Krehel [Wed, 7 Oct 2015 11:31:13 +0000 (13:31 +0200)]
Adjust ivy-state-preselect for file name completion
* ivy.el (ivy--reset-state): Since `ivy--index' is now recomputed more,
`ivy-state-preselect' needs to be in the collection properly, so that
`ivy--index' is set to preselect whenever the input is empty.
Oleh Krehel [Tue, 6 Oct 2015 13:29:27 +0000 (15:29 +0200)]
ivy.el (ivy--insert-prompt): Use newlines instead of truncation
When the prompt string is longer than window-width, insert newlines
appropriately so that the whole prompt fits in the window without
scrolling. Finally, when prompt+entered text would be larger than
window-width, reformat the prompt so that entered text starts on a
newline. When completing file names, move the whole path to a new line
in that case.
Oleh Krehel [Sat, 3 Oct 2015 07:59:39 +0000 (09:59 +0200)]
Customize ivy-avy and fix compile warnings
* ivy.el (ivy-avy): Require avy. Allow the user to customize `avy-keys',
`avy-background' and `avy-style' (but prefer 'pre to 'at-full, since
it doesn't obscure any letters). Don't issue an extra `ivy-call'.
Oleh Krehel [Fri, 2 Oct 2015 13:33:07 +0000 (15:33 +0200)]
Use forward-line instead of line-move if possible
* swiper.el (swiper--candidates):
(swiper--update-input-ivy):
(swiper--action): `line-move' is much slower than `forward-line'. Use it
only if `visual-line-mode' is on.
Oleh Krehel [Fri, 2 Oct 2015 12:02:16 +0000 (14:02 +0200)]
Make swiper compatible with visual-line-mode
* swiper.el (swiper--candidates): Use `end-of-visual-line' and
`line-move' appropriately.
(swiper--update-input-ivy):
(swiper--action): Use `line-move' instead of `forward-line'.
(swiper--add-overlays): Update.
Oleh Krehel [Fri, 2 Oct 2015 09:40:15 +0000 (11:40 +0200)]
Specify shell command for counsel-git-grep with prefix arg
* counsel.el (counsel-git-grep-cmd): New defvar.
(counsel-git-grep-function): Use `counsel-git-grep-cmd'.
(counsel-git-grep-cmd-history): New defvar.
(counsel-git-grep): Update signature. When called with a prefix arg,
prompt for a command reading from and recording to
`counsel-git-grep-cmd-history'.
Remember to use "M-i" to insert the current candidate into the
minibuffer.
Oleh Krehel [Wed, 30 Sep 2015 13:26:41 +0000 (15:26 +0200)]
Add flx sorting
* ivy.el (ivy--flx-cache): New defvar.
(ivy--filter): Since flx is costly, move the caching to an earlier
point. This means immediate return for when the input hasn't changed,
i.e. for "C-n" or "C-p". When flx is installed, and
(eq ivy--regex-function 'ivy--regex-fuzzy) for current function (through
`ivy-re-builders-alist'), then sort the final candidates with
`ivy--flx-sort'.
(ivy--flx-sort): New defun. In the worst case when some error pops up return
the same list. In the best case sort the `cands' that all match `name'
by closeness to `name'.
How to use:
1. Have flx installed - (require 'flx) should succeed.
2. Configure `ivy-re-builders-alist' appropriately to use `ivy--regex-fuzzy', for example:
Oleh Krehel [Wed, 30 Sep 2015 13:22:39 +0000 (15:22 +0200)]
ivy.el (ivy-call): "C-M-n" should not leave the minibuffer
Make sure that the minibuffer window remains selected as long as the
completion hasn't finished.
For example, "<f1> f" to call `counsel-describe-function' input
"forward" and spam "C-M-n" to read the doc for each function that starts
with "forward". The *Help* window popup would move the window focus, but
this change moves it back to the minibuffer.
Oleh Krehel [Sat, 26 Sep 2015 11:28:46 +0000 (13:28 +0200)]
Make ivy-display-style more compatible with 24.3
* ivy.el (ivy--format-minibuffer-line): Use
`font-lock-append-text-property' instead of
`add-face-text-property'. It's not optimal, since the new face needs
to be put in front, but at least it doesn't error out.
Oleh Krehel [Tue, 22 Sep 2015 11:03:02 +0000 (13:03 +0200)]
swiper.el (swiper--ivy): Use minibuffer-allow-text-properties
Using `minibuffer-allow-text-properties' makes Emacs not strip the text
properties from the result of `read-from-minibuffer'. This is better
because a function call result is used instead of a global var to pass
this info.
It also happens when resize-mini-windows is set to 'grow-only (default)
and multiple frames are open.
(Although SHA:435f2b6edfe3ab517c9eda56c6351f0bcfdf3845 work around it)
Temporarily bind `resize-mini-windows' to nil before calling
`read-from-minibuffer'.
Fix #237 and #229
It might fix #77 although this need to be checked as I cannot reproduce it.
Oleh Krehel [Fri, 11 Sep 2015 14:52:02 +0000 (16:52 +0200)]
Make line numbers in swiper into display properties
* swiper.el (swiper--candidates): Each candidate is now a single space
plus the original string. The display property of the single space
holds the line number. This means that it's no longer possible to
match line numbers in queries. Also, the preselect of the current line
is slightly worse (in case there are two identical lines in a buffer).
(swiper--ivy): Update the preselect to not include the line
number. Also, call `ivy--action' on `ivy-current' instead of `res',
because `res' doesn't have the string property that points to the line
number.
(swiper--update-input-ivy): Update.
(swiper--action): Update.
Oleh Krehel [Mon, 7 Sep 2015 12:03:08 +0000 (14:03 +0200)]
Make the minibuffer faces look nicer
* ivy.el (ivy-current-match): Update background and add white
foreground for light themes. Update background and add black
foreground for dark themes.
(ivy--add-face): If a face has an explicit foreground, add it ahead,
with no blending. Blend the background as usual.
* swiper.el (swiper-minibuffer-match-face-1):
(swiper-minibuffer-match-face-2): Update the background for light
themes.
(swiper-minibuffer-match-face-4): Update the background for dark themes.
Oleh Krehel [Fri, 4 Sep 2015 09:38:38 +0000 (11:38 +0200)]
Make ivy-current blend correctly for fancy minibuffer
* ivy.el (ivy--format-minibuffer-line): Stop setting :height - it messes
with blending. Also, the minibuffer height issue was fixed in an
earlier pull request.
(ivy--format): Call `ivy--add-face' on modified string, not on the
original one.