abo-abo / avy

Jump to things in Emacs tree-style
1.75k stars 111 forks source link

Mark textobjects, strings and so on? #78

Closed ghost closed 9 years ago

ghost commented 9 years ago

This might be possible (even simple) to do this in avy already, but have you 1) considered allowing hints for general text objects like inside and around parentheses, in or around strings sexps and so on?

Would also be neat if you 2) could combine an action with a text-object and then pop the mark afterwards in one keycombo like Eno does: https://github.com/enoson/eno.el

I starred eno because it seems like a good idea, but I really do not want to use many different "jumpers".

ghost commented 9 years ago

OT, but I have a HHKB 2 Pro I'll sell to you real cheap if you want it (I love it but got the JP version since I'd rather have modifiers instead of a long SPC).

I'll send it to you to check out without payment beforehand if interested (I read you might be in the market for one on reddit emacs).

http://bildr.no/view/Qm9SUXZj

abo-abo commented 9 years ago

This might be possible (even simple) to do this in avy already

It is kind of simple, but I'm always interested in making it better, if it comes at no expense to the basic functionality.

could combine an action with a text-object and then pop the mark afterwards

So basically, combine e.g. avy-goto-word-1 + kill-word + pop-mark. Sounds OK, but a lot of the time, you don't want to pop-mark at the end. So there's one more variation there.

eno

The problem I see with eno is that it has 4*10 commands that need to be bound globally. That's a huge number. 10 is a much better number. So if I'm going to implement this stuff for avy, I need to fit all actions into a single command. It's doable, I've done it with ace-window, but it will take time.

I'll send it to you to check out without payment beforehand if interested

Thanks for the offer, it's actually hard to check it out before buying. I didn't buy it initially because I wasn't sure I'd could go on without F1-F12 keys. From the picture, it looks like the keys are unmarked. How much do you want for it, and where from do you deliver?

ghost commented 9 years ago

Unmarked, yes. Half the price at most. Norway. If still interested send an email to endrebak@stud.ntnu.no and we can remove the kb stuff from this issue.

ghost commented 9 years ago

Only do it if it makes sense to you.

Perhaps it is better to have avy only do what it does best and have others provide addons using avy. I might be interested in making an avy eno addon.

I leave the closing of this issue up to you. Perhaps leave it open for discussion a little while?

Edit: come to think of it, it is probably better to have avy as a tool that does one thing well. Software complexity grows quickly, even when adding seemingly simple features.

Whether marking text objects (including user defined ones) should be a part of the core I dunno though. Seems super useful to me, but something you would need to hook into avy internals to do and therefore hard to do for external package writers.

On the other hand, having avy do several things after another (like I sketched out in the original post) is probably best outsourced to another package.

Ps. it is trivial to remap hold SPC + 1, 2, 3... as f1, f2, f3 etc (even hold SPC + a, s, d). Perhaps try it on your current kb and see if it suits you (The fn button is slightly far away on this board for my tastes).

abo-abo commented 9 years ago

Please have a look at the new functionality. And let me know if anything is missing.

Citing the commit message:

**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".
ghost commented 9 years ago

Only have my cell phone the next two weeks, but cannot wait to try this out.

PythonNut commented 9 years ago

@endrebak I'm curious, but could you do this even more efficiently with a transient-map hydra-style? You could M-g w to the word, and copy/mark/kill with n/m/x. The advantage, though it that it'll save you an a for evey invocation.

Personally, I'd like to see avy be something of a core library that other plugins would hack on. (It's so easy since @abo-abo has done a great job with the API). Not that it's my choice but I desperately fear feature creep.

ghost commented 9 years ago

Not using hydra, but will keep in mind, thanks!

phikal commented 5 years ago

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".

Sorry for bringing this up again, but I just can't re-create this. Whenever I type (for example) <avy-goto-word-1 key> x I will jump to a word beginning with x, instead of waiting for another key to be read in. Is there another variable I have forgot to set?

abo-abo commented 5 years ago

@phikal It's likely that there's only one word in the buffer that starts with x.

phikal commented 5 years ago

Yeah, it seems that was the issue. I was confused by what order the commends had to be entered in. Thanks for the help!