-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to customize what to jump to with avy #55
Comments
Would this be something that should be built into (defun avy-goto-while ()
(interactive)
(avy--goto
(avy--process
(mapcar
(lambda (point)
(cons (cons point point)
(get-buffer-window)))
(let ((points))
(save-excursion
(goto-char (window-start))
(while
(prog1
(search-forward "while"
(min (point-max) (window-end))
t)
;; adjust target to beginning of match
(push (- (point) 5) points)))
points)))
(avy--style-fn avy-style)))) |
Even simpler:
|
@abo-abo Great to know that it's just that simple. Maybe you could provide a macro that wraps around (defvar avy-while-object '("while " nil 'pre))
(avy-def-jump global-map (kbd "C-j w") 'avy-while-object) Then it generates appropriate binding for a particular keymap. |
It's great that (avy--generic-jump "(if\\|(cond\\|(when\\|(unless" nil 'pre) So now instead of thinking about jump to a character, I can think about jump to semantic units on screen! I think this is a great feature that should be mentioned on |
A macro unnecessarily restricts the things you can do:
It's only worth it if the abstraction power is high, which it isn't in this case. This is much better in my opinion, and not much longer: (global-set-key
(kbd "C-j w")
(defun avy-goto-while ()
(interactive)
(avy--generic-jump "while " nil 'pre))) |
But then, new users will have to write boilerplate code like that. I am assuming But that's look fine to me. I think this could be turned into a feature, and provide a few built-in commands for popular major modes i.e. C/C++, Python, Lisp |
It would be useful for user to customize what to jump to. For example, a user can create an avy command to jump to all the
if
occurrences; similarwhile
,for
... so I can bind all of them under some prefix key likeC-j
and quickly jump to with a few key strokes with minimal screen disruption.I got the idea from this issue: abo-abo/lispy#77
The text was updated successfully, but these errors were encountered: