Comments (6)
Would this be something that should be built into avy
? You could achieve this yourself with a small snippet:
(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))))
from avy.
Even simpler:
(avy--generic-jump "while" nil 'pre)
from avy.
@abo-abo Great to know that it's just that simple. Maybe you could provide a macro that wraps around avy--generic-jump
: a user can use this macro to define his jump command to a particular regexp. For example, let's name this macro avy-def-jump
. A user can use it like this:
(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.
from avy.
It's great that avy
already accepts regexp. Now I can jump to any conditional sexp in Lisp with this simple snippet:
(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 avy
homepage. Now we only need a macro for ease customization.
from avy.
Now we only need a macro for ease customization.
A macro unnecessarily restricts the things you can do:
- naming
- documenting
- advising
- re-using
- calling by name
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)))
from avy.
But then, new users will have to write boilerplate code like that. I am assuming avy
users are non-Elisp programmers as well.
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
from avy.
Related Issues (20)
- Reverse the order of key-labels for avy-goto-*-above HOT 2
- Avy's upstream and its version in elpa.git diverged
- Dimming buttons and headers HOT 1
- First char not highlighted
- Is there a workaround for shifted characters in variable-pitch-mode? HOT 1
- avy-copy/move-line/region expects a keystroke on emacs 28 HOT 2
- add-text-properties can be called on empty string
- Contribution Guidance Request: avy-goto-char-timer populate lead key face automatically
- How do I "activate" the avy-org-* commands?
- avy-dispatch-alist to invoke "isearch-forward-symbol-at-point" on C-s HOT 2
- What does de-bruijn style do? HOT 1
- avy-goto-char-2 display overlays after first character like Neovim's leap
- Go to word(-0) in line? HOT 1
- avy-org-refile-as-child error
- avy-org-refile-as-child error
- [FR] Select two arbitrary characters and copy the content between them HOT 1
- Temporarily disable prettify-symbols-mode
- avy-linum-mode clashes with visual-line-mode
- The mouse position after executing the avy-copy-region command?
- Some useful functions (with suggested optimizations) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avy.