Oleh Krehel [Wed, 6 Jan 2016 09:36:33 +0000 (10:36 +0100)]
Don't shorten selector string for visual-line-mode and bolp
* avy.el (avy--overlay-at-full): When at an empty line, there's plenty
of space to display the full selector. No need to truncate it to avoid
visual-line-mode reformatting the buffer text.
Aleksey Fedotov [Fri, 18 Dec 2015 18:43:16 +0000 (21:43 +0300)]
avy.el (avy-goto-line): fix for narrowed regions
When 'avy-goto-line' is called with numbered argument, it tries to mimic
behaviour of 'goto-line'. However, if some part of text is hidden by
narrowing, 'avy-goto-line' failed to account for that.
This patch temporarily disables narrowing, jumps on line and then
restores narrowing, just like 'goto-line' does.
Oleh Krehel [Mon, 7 Dec 2015 13:54:16 +0000 (14:54 +0100)]
Customize extra chars for avy-goto-subword-1
* avy.el (avy-subword-extra-word-chars): New defcustom.
(avy-goto-subword-0): Modify the syntax table temporarily using
`avy-subword-extra-word-chars'.
Oleh Krehel [Mon, 7 Dec 2015 09:36:01 +0000 (10:36 +0100)]
avy.el (avy-all-windows-alt): New defcustom
* avy.el (avy-dowindows): Use `avy-all-windows-alt'.
(avy--regex-candidates):
(avy--read-candidates): Use `current-prefix-arg'. At some later point, it
could be passed as an argument instead.
Dale Sedivec [Sun, 15 Nov 2015 16:32:46 +0000 (10:32 -0600)]
Fix De Bruijn "No catch for tag" error
When using avy-goto-line and typing a line number with avy-style
de-bruijn, you would get an error after entering your line number and
pressing RET:
No catch for tag: done, exit
I believe this is because avy-read is wrapped with (catch 'done ...) but
avy-read-de-bruijn doesn't catch done. This adds the catch to
avy-read-de-bruijn.
Tassilo Horn [Thu, 22 Oct 2015 13:25:13 +0000 (15:25 +0200)]
Beep when there are no matches
If avy--read-candidates doesn't find any candidates for the current
input, the user has surely made a typo. In that case, beep at the user
to make him aware of that.
Oleh Krehel [Thu, 22 Oct 2015 08:57:21 +0000 (10:57 +0200)]
Fix for combined org-indent-mode and visual-line-mode
* avy.el (avy-styles-alist): Make `avy-goto-line' use the 'pre style.
(avy--overlay): Clone `line-prefix' and `wrap-prefix' text properties if
any. These are the properties that `org-indent-mode' uses.
(avy--line): Set `temporary-goal-column' to 0 - this affects
`line-move-visual'.
Oleh Krehel [Wed, 21 Oct 2015 11:37:12 +0000 (13:37 +0200)]
Optimize avy-goto-char-timer
Previously, the candidate list would be generated twice: by
`avy--read-string-timer' and by `avy--generic-jump'.
* avy.el (avy--read-string-timer): Rename to `avy--read-candidates'.
(avy--read-candidates): Return the list of candidates instead of a
string which the candidates match.
(avy-goto-char-timer): Update.
Yasushi SHOJI [Sun, 18 Oct 2015 12:53:21 +0000 (21:53 +0900)]
Search only in the visible region
The current version of `avy--regex-candidates` first searches for the
given regex then skip the match if it's invisible. This works fine with
less than a few thousand lines of buffer, however, it takes quit time if
your have tens of thousand lines hidden, say, in org file.
This patch reverse the strategy. Find all visible regions in given the
window first, then map the original search function to that list. This
change reduced candidates search time from 10 or more seconds to instant
on my 100,000+ lines of org file.
It might be possible to have hundreds of visibility-interleaved regions
in a huge window on the 4K or 8K monitor in near the future, but this
reversed strategy should be fast enough for those system.
Tassilo Horn [Tue, 6 Oct 2015 19:31:12 +0000 (21:31 +0200)]
Properly highlight depending on avy-all-windows
Before this change, the highlighting was only performed in the selected
window even if avy-all-windows was true. Now it's consistent with the
value of that variable.
1. Handle DEL in order to fix typos.
2. Handle RET in order to use the current input string immediately
without waiting for another char for avy-timeout-seconds.
3. Highlight matches while reading chars.
Improve avy-goto-char-timer so that it may read 1 or many chars
Now you can use avy-goto-char-timer and type as many chars as you want
given each char comes before avy-timeout-seconds (and the very first
char is mandatory, i.e., there is no timeout for the first one).
Oleh Krehel [Fri, 7 Aug 2015 13:04:08 +0000 (15:04 +0200)]
avy.el (avy-pop-mark): use own history for points and windows
* avy.el (avy-action-goto): Don't save mark here, since the window was
already changed.
(avy--process): Set mark here.
(avy-ring): New defvar.
(avy-push-mark): New defun.
(avy-pop-mark): Use `avy-ring' unless it's empty. Then use the mark ring.
Oleh Krehel [Thu, 16 Jul 2015 12:50:48 +0000 (14:50 +0200)]
Allow to switch action midway from goto to kill/mark/copy
* avy.el (avy-action): New defvar.
(avy-dispatch-alist): New defvar.
Customize this to add new dispatch functionality.
(avy-handler-default): Use `avy-dispatch-alist'.
(avy--with-avy-keys): Set `avy-action' to nil, which means
`avy-action-goto' will be called by default.
(avy--goto): Remove defun. Redirect it as an obsolete alias to identity.
(avy-action-goto): New defun.
(avy-action-mark): New defun.
(avy-action-copy): New defun.
(avy-action-kill): New defun.
(avy--process): Call `avy-action'. This function alone now does
what (avy--goto (avy--process ...)) used to do.
(avy--generic-jump): Remove `avy--goto'.
(avy-goto-char-in-line): Remove `avy--goto'.
(avy-isearch): Remove `avy--goto'.
(avy--line): Set `avy-action' to identity so that `avy--process' doesn't
move point.
(avy-goto-line): Replace `avy--goto' with `avy-action-goto'.
(avy-copy-line): `avy--line' now returns a point, not a cons.
(avy-move-line): `avy--line' now returns a point, not a cons.
(avy-copy-region): `avy--line' now returns a point, not a cons.
**Example of use.**
Suppose you have:
(global-set-key (kbd "M-g w") 'avy-goto-word-1)
To jump to a certain word (e.g. first one on screen): "M-g wa".
To copy the word instead of jumping to it: "M-g wna".
To mark the word after jumping to it: "M-g wma".
To kill the word after jumping to it: "M-g wxa".
* avy.el (avy--overlay-at-full): Account for `overlays-in' not being
returned in the buffer order sometimes: it seems to be random order.
Instead, look at the minimum of all overlay starts that are on the
current line.
Oleh Krehel [Wed, 3 Jun 2015 16:19:00 +0000 (18:19 +0200)]
Modify `at-full' and `de-bruijn' overlays to color depth
* avy.el (avy-lead-face-2): New face.
(avy-lead-faces): New defconst. Each element will be used to color the
corresponding depth.
(avy--overlay-at-full): Use `avy-lead-faces' to represent the current
decision depth. For `de-bruijn', prepend the old stuff, so that nothing
moves.
Instead of building a tree (from a flat sequence) and traversing it,
just use the flat sequence. This has the advantage of candidates being
in proper buffer-sequential order.
Tassilo Horn [Tue, 26 May 2015 11:17:37 +0000 (13:17 +0200)]
Add 'de-bruijn option for avy-style
* avy.el (avy-style): New choice option.
(avy--de-bruijn): New defun.
(avy--path-alist-1): New defun.
(avy--group-by): New defun.
(avy--path-alist-to-tree): New defun.
(avy-tree-de-bruijn): New defun, semi-compatible with `avy-tree'.
(avy--process): Use `avy-tree-de-bruijn' when `avy-style' is 'de-bruijn.
(avy--style-fn): Use `avy--overlay-at-full' when `avy-style' is
'de-bruijn.
Fixes #51
Re #5
TODO: When tree produced by `avy-tree-de-bruijn' is traversed
depth-first, the results should be in-order of their appearance in the
window. Only in this case the overlay functions will work correctly,
since they need to be applied sequentially from window end to window
start.