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
Oleh Krehel [Fri, 4 Mar 2016 13:58:50 +0000 (14:58 +0100)]
New command ivy-occur-revert-buffer bound to "g"
* ivy.el (ivy-occur-mode-map): Move `ivy-occur-press' from "g" to "f".
Bind "g" to `ivy-occur-revert-buffer'.
(ivy-occur-revert-buffer): New command. Does what e.g. `revert-buffer'
does for *Help* buffers.
* swiper.el (swiper-faces): Add :group and :type.
(swiper-occur): Try to avoid calling `ivy-occur-grep-mode' as it will
kill all local variables.
(swiper--action): Update so that `ivy-occur-toggle-calling' works properly.
Oleh Krehel [Wed, 2 Mar 2016 11:17:05 +0000 (12:17 +0100)]
ivy-occur-mode: new commands on "j", "k", "c"
* ivy.el (ivy-calling): Make variable buffer-local.
(ivy-occur-toggle-calling): New command bound to "c".
(ivy-occur-next-line): New command bound to "j".
(ivy-occur-previous-line): New command bound to "k".
This makes `ivy-occur' much more convenient, instead of "gjgjgjg", just
"cjjj". Especially good for commands that change the contents of the
other window, like `describe-function' or `counsel-git-grep'.
Oleh Krehel [Tue, 1 Mar 2016 18:30:38 +0000 (19:30 +0100)]
ivy.el (ivy-next-history-element): No "\\_<" for dynamic-collection
"\\_<" regex is Emacs-specific and should only be done if
:dynamic-collection is nil.
It is nil for `counsel-git-grep' with repositories < 20000 lines, but
non-nil for larger ones.
Oleh Krehel [Tue, 1 Mar 2016 15:53:30 +0000 (16:53 +0100)]
ivy-dispatching-done should not permanently modify default action index
* ivy.el (ivy-read):
When (numberp (car-safe (ivy-state-action ivy-last))), reset it to 1.
This was an issue for `ivy-read' calls that specified :action as a
list (`counsel-rhythmbox' and `counsel-list-processes'), instead using a
single function and `ivy-set-actions'.
Oleh Krehel [Mon, 29 Feb 2016 08:20:33 +0000 (09:20 +0100)]
"C-x C-f" can un-ignore dotfiles with a leading dot input
* counsel.el (counsel-find-file-ignore-regexp): Add a recommended value,
all dotfiles.
(counsel--find-file-matcher): When `ivy-text' starts with a dot, don't
use `counsel-find-file-ignore-regexp'. The generic way to do this is
with "C-c C-a" (`ivy-toggle-ignore'), but this is faster and more convenient.
Oleh Krehel [Sat, 27 Feb 2016 12:48:11 +0000 (13:48 +0100)]
Move read-file-name to :display-transformer-fn
* ivy.el (ivy-set-display-transformer): Set 'read-file-name-internal to
'ivy-read-file-transformer.
(ivy-read-file-transformer): New defun.
(ivy--format): Simplify.
Oleh Krehel [Sat, 27 Feb 2016 12:40:00 +0000 (13:40 +0100)]
Move switch-to-buffer to :display-transformer-fn
* ivy.el (ivy-read): Use also COLLECTION as a key for
`display-transformer-fn'.
(ivy--format): Simplify.
(ivy-switch-buffer-transformer): New defun.
(ivy-set-display-transformer): Set 'ivy-switch-buffer and
'internal-complete-buffer to 'ivy-switch-buffer-transformer.
Oleh Krehel [Sat, 27 Feb 2016 07:53:57 +0000 (08:53 +0100)]
Simplify the ivy-format-function interface
* ivy.el (ivy--format-function-generic): Third arg is no longer a list
of cons cells, but a list of strings instead.
(ivy-format-function-default):
(ivy-format-function-arrow):
(ivy-format-function-line): Take a string instead of a cons cell.
(ivy--format): Feed strings instead of cons cells to
`ivy-format-function'.
* ivy-test.el (ivy--format): Update test.
* counsel.el (counsel--yank-pop-format-function): Take a string instead
of a cons cell.
Oleh Krehel [Sat, 27 Feb 2016 07:32:01 +0000 (08:32 +0100)]
New API function ivy-set-display-transformer
* ivy.el (ivy--display-transformers-list): New defvar.
(ivy-set-display-transformer): New defun. Keys are :caller, values are
str->str lambda.
(ivy-state): New field display-transformer-fn.
(ivy-read): Set :display-transformer-fn.
(ivy--format): Apply :display-transformer-fn to each displayed
candidate, in the context of ivy-window.
* counsel.el (ivy-set-display-transformer): Set for `counsel-M-x'.
(counsel-M-x-transformer): Promote from `counsel--M-x-transformer'.
Now takes a string instead of a cons cell.
(counsel-M-x): No more messing with `ivy-format-function'.
Oleh Krehel [Fri, 26 Feb 2016 13:27:28 +0000 (14:27 +0100)]
Give ivy-read-read-action enough minibuffer space
* ivy.el (ivy-read-action): Bind (resize-mini-windows 'grow-only).
Return non-nil when everything went OK.
(ivy-dispatching-done): Call `ivy-done' only if read-action went OK.
Previously, an action would be called after "M-o C-g".