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.
Oleh Krehel [Fri, 21 Aug 2015 14:57:22 +0000 (16:57 +0200)]
Add swiper-multi command
* swiper.el (swiper-multi-buffers): New defvar.
(swiper-multi-candidates): New defvar.
(swiper-multi-prompt): New defun.
(swiper-multi-action-1): New defun.
(swiper-multi-action-2): New defun.
Fixes #182.
Basic usage tips for selecting multiple buffers:
- Use "C-M-m" (`ivy-call') to add or remove one more buffer without exiting.
- Use "C-m" (`ivy-done') to add one last buffer.
- Or use "C-M-j" (`ivy-immediate-done') to finish without adding more buffers.
- Hold "C-M-n" (`ivy-next-line-and-call') to add a lot of buffers at once.
Tassilo Horn [Wed, 12 Aug 2015 11:34:40 +0000 (13:34 +0200)]
Fix #126 again.
After #126 has been solved, the regexp has been changed to
"\\`[`']?\\(.*\\)'?\\'"
where the trailing ' is optional ("'?"). However, the preceeding
"\\(.*\\)" group will already capture the trailing ' because .* is
greedy. Now I've replaced it with the non-greedy .*? which makes it
work again.
Oleh Krehel [Fri, 7 Aug 2015 14:21:16 +0000 (16:21 +0200)]
Fix :dynamic-collection not being sorted
* ivy.el (ivy--sort-maybe): New defun. If the current completion has
sorting enabled, try to find the sorting function either in :sort or
`ivy-sort-functions-alist'.
(ivy--exhibit): Use `ivy--sort-maybe'.
* counsel.el (counsel--async-sentinel): Use `ivy--sort-maybe'.
Oleh Krehel [Tue, 28 Jul 2015 16:04:49 +0000 (18:04 +0200)]
counsel.el (counsel-org-tag-agenda): New command
* counsel.el (counsel-org-tag-agenda): It's just a flet wrapper around
`org-agenda-set-tags', changing `org-set-tags' to `counsel-org-tag'.
(counsel-org-tag-action): Don't use `with-selected-window', since
`org-agenda-set-tags' will change the buffer for us.
Oleh Krehel [Mon, 27 Jul 2015 11:03:50 +0000 (13:03 +0200)]
Update :dynamic-collection to be a boolean
* ivy.el (ivy--exhibit): Always use `ivy-state-collection', instead of
possibly `ivy-state-dynamic-collection'. The collection function may
return nil if it's async and doesn't want to update the minibuffer on
exit (to update it later in the sentinel).
* counsel.el (counsel-more-chars): New defun.
(counsel-git-grep-function): Use `counsel-more-chars'; in the async
case, return nil.
(counsel-git-grep): Update :dynamic-collection to a boolean.
(counsel--gg-sentinel):
(counsel--async-sentinel): Update to set the candidates to "Error"
instead of message "Error" - a lot less distracting this way.
(counsel-locate-function): Use `counsel-more-chars'; return "Working",
since it takes a few seconds to complete a single locate query.
(counsel-locate): Update.
Oleh Krehel [Mon, 27 Jul 2015 10:24:48 +0000 (12:24 +0200)]
ivy.el (ivy--exhibit): Check if in post-command-hook
* ivy.el (ivy--exhibit): A situation can occur when an async command
calls `ivy--exhibit' in the sentinel. It causes problems when the
minibuffer has already exited with "C-g".
Oleh Krehel [Mon, 27 Jul 2015 09:51:08 +0000 (11:51 +0200)]
Simplify counsel-git-grep logic
* ivy.el (ivy--exhibit): Remove the condition on (eq ivy--full-length -1).
* counsel.el (counsel-git-grep-function): Simplify.
(counsel-gg-state): New defvar. Use this instead of
(setq ivy--full-length -1).
(counsel--gg-candidates): Set `counsel-gg-state' to -2. There are two
async processes to wait for until `ivy--exhibit' can be called:
- get the candidate count
- get the candidates
Each of the async processes will increase the number, and call
`ivy--exhibit' if the number reaches 0.
(counsel--gg-sentinel): Update.
(counsel--gg-count): Update.
Oleh Krehel [Sun, 26 Jul 2015 13:24:34 +0000 (15:24 +0200)]
Allow "M-o j" to switch to virtual buffers in other window
* ivy.el (ivy--switch-buffer-other-window-action): New defun.
(ivy-set-actions): Use `ivy--switch-buffer-other-window-action' instead
of `switch-to-buffer-other-window'.
* counsel.el (counsel-org-tags): New defvar.
(counsel-org-change-tags): New defun, adapted from part of
`org-set-tags'.
(counsel-org-tag-action): New defun.
(counsel-org-tag-prompt): New defun.
(counsel-org-tag): New command.
**Using counsel-org-tag**
- The prompt is auto-updated to the currently selected tags.
- Selecting one of the already selected tags removes it from selection.
The best shortcut for selecting/removing multiple tags is "C-M-m" (or
"g" when the "C-o" hydra is active).
* ivy.el (ivy-dispatching-done): Remove trailing ": ".
(ivy-switch-buffer): Add extra action "j" calls
`switch-to-buffer-other-window'. The change `ivy-dispatching-done' had
to be done because of this.
Oleh Krehel [Thu, 23 Jul 2015 12:01:03 +0000 (14:01 +0200)]
ivy.el (ivy--preselect-index): Add matcher to arglist
* ivy.el (ivy--reset-state): Call `ivy--preselect-index' with matcher.
(ivy--preselect-index): In case there's a special matcher set, it
affects the candidate list, therefore it affects the preselect index.
Oleh Krehel [Wed, 22 Jul 2015 10:10:13 +0000 (12:10 +0200)]
ivy.el (ivy-dispatching-done): New command on "M-o"
* ivy.el (ivy-minibuffer-map): Bind "M-o" to `ivy-dispatching-done'.
(ivy-action-name): Update, all actions are now in hydra's format - key
binding, command, hint.
(ivy-read): The default action is bound to "o" in the dispatch.
(ivy-switch-buffer): Update to new action format.
* counsel.el (counsel-locate):
(counsel-rhythmbox): Update to new action format.
The new interface allows to do whatever you want with the selected
candidate with a very short key binding.
The old interface with "C-o w/s" still works, but:
- it gives a lot more info than necessary for only selecting action
- doesn't scale well with the number of actions: for 10 actions you
would cycle "w/s" a lot.
Example with `ivy-switch-buffer':
- switch to selected buffer: "C-m"
- kill selected buffer: "M-o k"; you get a hint right after "M-o".
When there is only one action, "M-o" will forward to "C-m".
Oleh Krehel [Wed, 22 Jul 2015 20:24:11 +0000 (22:24 +0200)]
ivy.el (ivy-call): Add selected-window work-around for M-x
* ivy.el (ivy-call): For some commands that depend on the buffer, like
`counsel-git-grep' the action needs to be performed in
`ivy-state-window'. However, this results in wrong window for M-x calc.
Add a workaround until I figure out why this happens.
Oleh Krehel [Thu, 9 Jul 2015 13:54:51 +0000 (15:54 +0200)]
Add counsel-rhythmbox
* counsel.el (counsel-completion-beg):
(counsel-completion-end): Move declarations before first use.
(dired-jump): Declare.
(counsel-rhythmbox-enqueue-song): New defun.
(counsel-rhythmbox): New command. Requires `helm-rhythmbox' package, and
Rhythmbox, obviously.
* ivy.el (ivy-call): Make interactive. Add special handling for the case
when the collection is an alist. In that case, call the action not
with the collection item, but with the cdr of said item. A bit weird,
but that's the way Helm does it, and doing it in the same way means
the action functions are cross-compatible.
* ivy-hydra.el (hydra-ivy): Bind "g" to call the current action on
current candidate without exiting.
Now it's possible to make a query to Rhythmbox, "C-o" and navigate to a
song with "j" and "k". Try the song with "g". Or use "s" once and then
enqueue different songs with e.g. "jjgjjjgjgkkg".
Oleh Krehel [Mon, 6 Jul 2015 10:03:59 +0000 (12:03 +0200)]
Add a new interface to customize additional exit points
* ivy.el (ivy--actions-list): New defvar. Store the exit points per
command.
(ivy-set-actions): New defun. Use this to set the extra exit points for
each command.
(ivy-read): Account for `ivy--actions-list'.
(ivy-switch-buffer): Set extra action to kill the buffer. Update the
call to `ivy-read'.
* counsel.el (counsel-locate): Use the single action in the function and
customize the rest via `ivy-set-actions'.
Oleh Krehel [Wed, 1 Jul 2015 13:43:33 +0000 (15:43 +0200)]
Allow to see the candidate index via ivy-count-format
* ivy.el (ivy--insert-prompt): Update.
To use this feature, use something like this:
(setq ivy-count-format "(%d/%d)")
Basically two number specifiers instead of the usual one. The problem
with this approach is that the prompt length will change as you scroll
e.g. from 9 to 10, which is uncomfortable.