Oleh Krehel [Sat, 14 Nov 2015 15:27:41 +0000 (16:27 +0100)]
swiper.el (swiper-all): New command to swiper all file buffers
* swiper.el (swiper--candidates): Add NUMBERS-WIDTH arg. It could be
done better by calculating the line count of each buffer and then
getting the max of that, but this way is faster, since the collections
are traversed only once.
(swiper-multi): Update.
(swiper-all): New command. This is like `swiper-multi' where the buffer
list is pre-selected to be all file visiting buffers.
(swiper--multi-candidates): New defun.
(swiper-multi-action-1): Use `swiper--multi-candidates'.
(swiper-multi-action-2): Update - the line number is in the 'display
property of the first char.
Oleh Krehel [Fri, 13 Nov 2015 14:37:15 +0000 (15:37 +0100)]
Allow user-specified matched candidate sorting
* ivy.el (ivy-prefix-sort): Remove defcustom.
(ivy--filter): Forward sorting of matched candidates to `ivy--sort'.
(ivy-sort-matches-functions-alist): New defcustom.
(ivy--sort): New defun.
Oleh Krehel [Fri, 13 Nov 2015 14:04:56 +0000 (15:04 +0100)]
ivy.el (ivy-prefix-sort): New defcustom, off by default for now
* ivy.el (ivy--filter): When `ivy-prefix-sort' is non-nil, additionally
sort the matching candidates with `ivy--prefix-sort'.
(ivy--prefix-sort): New defun.
Oleh Krehel [Wed, 11 Nov 2015 14:47:02 +0000 (15:47 +0100)]
Allow counsel-git-grep -> ivy-occur -> wgrep
* ivy.el (ivy-exit-with-action): New defun.
(ivy-occur-action): Remove defvar. It's part of `ivy-occur-last' now.
(ivy-occur-last): Update doc.
(ivy-occur-map): Rename to `ivy-occur-mode-map'.
(ivy-occur-mode): New major mode.
(ivy-occur): When the caller is `counsel-git-grep', enter `grep-mode';
otherwise enter the new `ivy-occur-mode'.
For `wgrep' to work, two things are changed: candidates need to start on
the 5th line, and candidates need to be prefixed with "./".
(ivy-occur-read-action): New command, bound to "a".
(ivy-occur-dispatch): New command, bound to "o".
(ivy-occur-press): Update to work with `grep-mode'.
(ivy-occur-grep-mode-map): New defvar.
(ivy-occur-grep-mode): New major mode. Basically, it's grep-mode with
"C-x C-q" bound to `wgrep-change-to-wgrep-mode'.
Oleh Krehel [Wed, 11 Nov 2015 11:01:43 +0000 (12:01 +0100)]
swiper.el (swiper-toggle-face-matching): Add and bind to "C-c C-f"
* swiper.el (swiper-map): Bind `swiper-toggle-face-matching' to
"C-c C-f".
(swiper-invocation-face): New defvar.
(swiper--ivy): Set `swiper-invocation-face'.
(swiper-toggle-face-matching): Toggle `ivy-state-matcher' between
nil (the initial value) and 'swiper--face-matcher.
(swiper--face-matcher): New defun. In addition to filtering CANDIDATES
by having them match REGEXP, also ensure that every match has
`swiper-invocation-face'.
Example of usage:
1. Move point to a variable with e.g. `font-lock-keyword-face' and "C-s"
<input>.
2. Use "C-c C-f" to filter the candidates further by selecting only the
ones that have `font-lock-keyword-face'.
Note that "M-q" (`swiper-query-replace') is also affected by the filtering.
Oleh Krehel [Thu, 5 Nov 2015 13:42:36 +0000 (14:42 +0100)]
Add a better ivy-occur pulse to swiper and counsel-git-grep
* ivy.el (ivy-occur-press): Bind `ivy-exit' to 'done, so that
`swiper--add-overlays' called by ACTION don't do anything.
Call another `swiper--add-overlays' for swiper and counsel-git-grep,
limited to the current line. Call `swiper--cleanup' with a delay of 1
second.
Oleh Krehel [Wed, 4 Nov 2015 18:10:09 +0000 (19:10 +0100)]
ivy.el (ivy-occur-press): Extend with-ivy-window
ivy-occur-action should be called in (ivy--get-window ivy-last).
This means, for purposes of e.g. `counsel-find-symbol' or
`lispy--action-jump` that if *ivy-occur* is the only window, it will be
re-used.
But if the user wants *ivy-occur* not to get buried, then having at
least 2 windows solves that problem.
mike [Wed, 4 Nov 2015 15:08:51 +0000 (10:08 -0500)]
fix 1-too-far scrolling issue
Functions `ivy-scroll-up-command' and `ivy-scroll-down-command' would
scroll 1 unit too far. So one item in the list would be skipped
and never seen for each scroll.
Oleh Krehel [Wed, 4 Nov 2015 11:51:04 +0000 (12:51 +0100)]
Pulse after ivy-occur-press
* ivy.el (ivy-state): New field TEXT.
(ivy-occur): Add `ivy-text' to the name of the buffer. Also store
`ivy-text' in `ivy-occur-last'. Might be needed in the future for a more
specific pulse.
(ivy-occur-press): Pulse the selected line.
Oleh Krehel [Tue, 3 Nov 2015 15:12:06 +0000 (16:12 +0100)]
Make ivy work with enable-recursive-minibuffers
* ivy.el (ivy-read): Fix the doc of DYNAMIC-COLLECTION. Store the old
`ivy-last' in case `ivy-read' is called while inside the minibuffer.
Restore it after `ivy-call'.
Oleh Krehel [Tue, 3 Nov 2015 10:43:47 +0000 (11:43 +0100)]
ivy.el (ivy-occur): Add and bind to "C-c o"
* ivy.el (ivy-minibuffer-map): Update.
(ivy-occur-action):
(ivy-occur-last):
(ivy-occur-map): New defvar.
(ivy-occur): New command.
(ivy-occur-click): New command bound to mouse click.
(ivy-occur-press): New command bound to "RET" press.
`ivy-occur' allows to store the current completion session for further
use. An unlimited amount of these sessions can be used, each in its own
buffer.
Oleh Krehel [Mon, 2 Nov 2015 14:12:26 +0000 (15:12 +0100)]
Highlight modified file buffers with 'ivy-modified-buffer face
* ivy.el (ivy-modified-buffer): New face, blank by default.
(ivy--format): When the collection is 'internal-complete-buffer,
highlight unsaved file visiting buffers with 'ivy-modified-buffer.
Oleh Krehel [Sat, 31 Oct 2015 12:11:23 +0000 (13:11 +0100)]
counsel.el (counsel-git-grep-query-replace): Add and bind to "M-q"
* counsel.el (counsel-git-grep-map): Bind "M-q" to
`counsel-git-grep-query-replace'.
(counsel-git-grep-query-replace): New command. Perform `query-replace'
on all matches of git-grep in all buffers.
Oleh Krehel [Fri, 30 Oct 2015 14:00:30 +0000 (15:00 +0100)]
"C-x C-f M-n" can call ffap-url-fetcher when at URL
* ivy.el (ivy--cd-maybe): Check if the input is a valid URL.
If so, exit immediately by calling (funcall ffap-url-fetcher url).
Otherwise, do the usual `ivy--cd' thing.
Oleh Krehel [Fri, 30 Oct 2015 13:50:05 +0000 (14:50 +0100)]
counsel.el (counsel--find-symbol): Resolve name clash better
* counsel.el (counsel--find-symbol): When the symbol is both bound and
fbound, prefer the fbound one, unless the :caller is
`counsel-describe-variable'.
(counsel-describe-variable): Declare :caller.
(counsel-describe-function): Declare :caller.
One example is going to the definition of `isearch-forward' (also with
`counsel-M-x').
Oleh Krehel [Thu, 22 Oct 2015 10:27:37 +0000 (12:27 +0200)]
"C-j" should not stop completion for a pasted file path
* ivy.el (ivy-alt-done): If you paste a file path, it won't match
anything in the current directory. Previously, "C-j" would open dired
for that path. Now, "C-j" will switch to the pasted directory and
continue completion.
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.