Skip to content
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 easy-kill to select content between pairs #14

Open
tuhdo opened this issue Apr 14, 2014 · 11 comments
Open

Allow easy-kill to select content between pairs #14

tuhdo opened this issue Apr 14, 2014 · 11 comments

Comments

@tuhdo
Copy link

tuhdo commented Apr 14, 2014

It would be useful if easy-kill can select content in between a pair. The default pairs should be:

  • " ... "
  • ' ... '
  • < ... >
  • [ ... ]
  • { ... }
  • ( .... )

This should be extended for 'M-w l' (save list at point). Or it can have a different command and bound to 'M-w p' (save pair content at point).

Users should be able to add customized pairs as well.

@leoliu
Copy link
Owner

leoliu commented Apr 14, 2014

Hi Tuhdo,

M-w l selects a list which is the enclosing sexp. So in most programming modes [] () and {} should work already. <> might not work unless the mode set its syntax properly. In nXML, M-w l will select the enclosing tag pair. In js2 mode it will select the enclosing node.

For strings it is a bit tricky. At the moment you can only reach the entire string by expanding from a sexp or list selection inside the string.

Does this meet your needs? I have been thinking about how to make easy-kill more useful for modes that don't have reasonable parsers. Suggestions?

Thanks,
Leo

@tuhdo
Copy link
Author

tuhdo commented Apr 14, 2014

Hi Leo,

Thanks for the info and I tried on C/C++ modes. It works nicely except for strings. Is it possible to add string selection (whole string content between " ... ") and customized pairs to easy-kill?

For text mode, it should be able to select anything between a separator and be able to add more if needed. For example, I have this sentence:

  • Statement a, statement b; statement c: statement d.

I can select any statement at point (a statement contains many words) by M-w l.

leoliu added a commit that referenced this issue Apr 15, 2014
When inside a string and no enclosing list at point, treat the whole
string as the list.
@leoliu
Copy link
Owner

leoliu commented Apr 15, 2014

As the first step, I have made M-w l work better with strings. Could you try it out? Thanks.

@tuhdo
Copy link
Author

tuhdo commented Apr 15, 2014

New change is nice, except that it should select the inner content of the string first, not the whole string including double quotes. Then, you can expand it to include double quotes by pressing +.

@tuhdo
Copy link
Author

tuhdo commented Apr 15, 2014

Also, in an s-expr which contains a string, when the cursor is on the string, M-w l should first select content of the string; subsequent pressing l will expands to parent lists. Parent lists are outer s-expressions; s-expressions are parentheses ( ... ) in Lisp modes, or a pair ( [ ... ], ( ... ), { ...} ... ) according to the semantics of non-Lisp modes.

@tuhdo
Copy link
Author

tuhdo commented Apr 15, 2014

easy-kill is a nice package. If it has the above features, I will replace expand-region with this package.

@leoliu
Copy link
Owner

leoliu commented Apr 16, 2014

M-w l always select the enclosing sexp. Something inside parenthesis or strings. When you are on the beginning of " of a string the enclosing sexp is not the string.
M-w s select the sexp at point.
The semantics of these two are well defined in emacs. BTW, I probably use these two commands a hundred times each day (along with copy lines).

Although list-wise +/- is nice it is not as effective as directly get to the thing you need. So unlike expand-region you don't have to start small and move upwards. You get to it directly. i.e. if you need the entire function M-w d is better then M-w l + + + etc.

Having said I plan to tweaks +/- so that it can stop at certain boundaries of interest i.e. the inner of strings or lists etc.

@YangZhao11
Copy link

I recently started using anchored-transpose and have this bound to "t":

(put 'easy-kill-transpose 'easy-kill-exit t)
(defun easy-kill-transpose ()
(interactive)
(save-mark-and-excursion
(easy-kill-mark-region)
(call-interactively 'anchored-transpose)))

Right now I'm using it like this:

  • select thing A, then t
  • select thing B, then t

I do miss the ability to select inside a list, so I can do

  • select inside list, then t
  • select the anchor, then t

The second form is easier sometimes.

What does it take to implement this? Does it require major rewrite?

@leoliu
Copy link
Owner

leoliu commented Sep 12, 2015

Hi @YangZhao11,

Could you open a new issue on this? I had something similar quite a while ago when planning a small rewrite of easy-kill. Thanks, Leo.

@YangZhao11
Copy link

Hi - by "a new issue", do you mean the ability to select inside a list (which is slightly different from "between pairs"), or do add a transpose function?

@leoliu
Copy link
Owner

leoliu commented Sep 14, 2015

@YangZhao11,

My bad. I thought this issue is closed.

Leo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants