Oleh Krehel [Mon, 18 Apr 2016 07:42:05 +0000 (09:42 +0200)]
ivy.el (ivy-use-ignore-default): New defcustom
* ivy.el (ivy-use-ignore): Is now set to `ivy-use-ignore-default'.
(ivy-toggle-ignore): Update.
(ivy--reset-state): Update.
(ivy--switch-buffer-matcher): When `ivy-use-ignore' is t, and they
only cands that match the input also match `ivy-ignore-buffers' show
them anyway. But when `ivy-use-ignore' is 'always, show nothing in that
case.
Oleh Krehel [Wed, 13 Apr 2016 17:29:12 +0000 (19:29 +0200)]
Fix counsel-grep-last-line bug
Need to reset `counsel-grep-last-line' each time the input changes.
That var should only be used for cycling the complete cands, not during
input updates.
Oleh Krehel [Wed, 13 Apr 2016 17:14:15 +0000 (19:14 +0200)]
Add much faster scrolling to counsel-grep
* counsel.el (counsel-grep-last-line): New defvar.
(counsel-grep): Set `counsel-grep-last-line' to nil.
(counsel-grep-action): Instead of going to `point-min' and
`forward-line' with a huge arg (e.g. to scroll 50K lines). Scroll
relative to the last position stored in `counsel-grep-last-line'.
This change resulted in a much smoother scrolling in a 50K line file
with 22K matches.
Oleh Krehel [Wed, 13 Apr 2016 17:04:58 +0000 (19:04 +0200)]
Make ivy--regex work with "[^ ]"
* ivy.el (ivy--split): Add a work around to not consider spaces like
"[^ ]". It's pretty hacky, the space has to come right after "[^".
But better than nothing.
* ivy-test.el (ivy--split): Add test.
Use-case: open a freedict file, where each word being defined is with no
indentation and the explanation is with indentation.
`swiper' or `counsel-grep' will now work properly with input "^[^ ]".
Oleh Krehel [Mon, 11 Apr 2016 14:48:28 +0000 (16:48 +0200)]
New feature: virtual views in ivy-switch-buffer
* ivy.el (ivy-views): New defvar that stores the pre-defined views.
(ivy-source-views): New defun.
(ivy-set-view-recur): New defun.
(ivy--switch-buffer-action): Extend.
(ivy-set-sources): Attach `ivy-source-views' as an additional source to
`ivy-switch-buffer'.
How to use: just set `ivy-views' appropriately. An example value is
provided (but nulled, so that it's empty initially).
Oleh Krehel [Fri, 8 Apr 2016 11:38:16 +0000 (13:38 +0200)]
Allow to customize the action hint formatter
* ivy.el (ivy-read-action-format-function): New defvar.
(ivy-read-action-format-default): New defun, extracted from
`ivy-read-action'.
(ivy-read-action'): Update.
- delete duplication of #'ivy-next-line and #'ivy-previous-line
- replace alias #'backward-delete-char by #'delete-backward-char because
only the second is bound to a key
* ivy.el: Make sure user keybindings are reused in ivy-minibuffer-map.
Without this patch, if the user specifies his own keybinding for a
standard command (e.g., `beginning-of-buffer`, normally bound to
`M-<`), ivy keeps using the default keybinding (e.g., `M-<`) in
ivy-minibuffer-map instead of the user-specified one.
Fixes the algorithm selecting the first matching candidate in case there
are 0 matching candidates following point. Now the last matching
candidate will be selected, resulting in less scrolling.
Oleh Krehel [Mon, 4 Apr 2016 15:22:24 +0000 (17:22 +0200)]
counsel-grep now works with ivy-occur-revert-buffer
Press "g" in a *ivy-occur counsel-grep ...* buffer to refresh the list
of matches, due to possible changes in the file.
* counsel.el (counsel-grep-base-command): New defcustom.
(counsel-grep-occur): New defun.
(counsel-set-async-exit-code 'counsel-grep): Make it look more like swiper.
* counsel.el (counsel-grep-function): Use different quoting. Now it's
possible to use e.g. "(defun foo" as input.
(counsel-unquote-regex-parens): Does the proper unquote now - 4
replacements instead of previous 2.
Oleh Krehel [Thu, 31 Mar 2016 14:06:23 +0000 (16:06 +0200)]
swiper.el (swiper-query-replace): Improve "M-n"
To replace a symbol with a similar symbol,
1. Press "C-s" "M-n" for `swiper' and select the symbol at point as input.
2. Press "M-q" for `swiper-query-replace'
3. Press "M-n" to yank the symbol to replace.
Here step-3 was modified to yank e.g. "symbol" instead of "\_<symbo\_>"
previously.
The function `my-find-file' knows nothing about the extra source, it's
only purpose is to introduce a :caller to attach things to, as to not to
mess up e.g. `counsel-find-file'.
The function `my-extra-source' gets called once in `ivy-read' via
`ivy--reset-state'. It takes no args and returns a list of strings,
possibly empty.
Oleh Krehel [Fri, 25 Mar 2016 21:07:42 +0000 (22:07 +0100)]
Improve counsel-async initial anchoring
* counsel.el (counsel--async-sentinel): Rely on
`ivy-recompute-index-swiper-async' even when `ivy--old-cands' is nil.
* ivy.el (ivy--recompute-index): Check for `ivy--old-cands' being nil
before trying to index it.
(ivy-recompute-index-swiper-async): When `ivy--old-cands' is nil, look
for a string that's closest to the line number at point.
and counsel-describe-variable to the current-window work-around.
Since they can switch the buffer, ensure that the occur buffer stays
active, so that the calling state ("c") still allows to quickly cycle
through all those buffers.
justbur [Thu, 17 Mar 2016 17:09:52 +0000 (13:09 -0400)]
counsel.el (counsel-mode): Allow use of describe-prefix-bindings
Add option to let counsel-descbinds override describe-bindings in
counsel-mode.
counsel.el (counsel-descbinds): Make signature match describe-bindings
counsel.el (counsel--descbinds-cands): Adjust for previous change
counsel.el (counsel-mode-override-describe-bindings): New option
This function should only care about producing a list of strings from
the process buffer.
A new function should take this list and take care of everything else.
justbur [Mon, 7 Mar 2016 20:05:09 +0000 (15:05 -0500)]
Add optional exit-code table to counsel--async-cmd
This argument can be used to associate exit codes with the underlying
reason. Used in counsel-ag-function to signal that an exit code of 1
means that no matches were found.
Oleh Krehel [Mon, 7 Mar 2016 16:40:49 +0000 (17:40 +0100)]
counsel.el (counsel-git-grep-map): Bind "C-c C-m" to counsel-git-grep-switch-cmd
* counsel.el (counsel-git-grep-switch-cmd): New command.
The initial command always runs on all files.
To run only on *.el files, "C-c C-m" followed by "M-i" -- *.el.
To run on *.c and *.h files, "C-c C-m" followed by "M-i" -- *.c *.h.
To switch to all files again, "C-c C-m" and select the appropriate
entry.
justbur [Mon, 7 Mar 2016 01:59:14 +0000 (20:59 -0500)]
counsel-ag: Fix escaping problem
Before this it is not possible to pass the string "string1\|string2" to
ag, because inputing string1\|string2 gets translated into
"string1\\|string2" via %S.
Instead I use %s and shell-quote-argument to take care of escaping for
the command line, which fixes the issue for me.
Please test.
Also see https://github.com/syl20bnr/spacemacs/issues/5378