-
Notifications
You must be signed in to change notification settings - Fork 61
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
Can't delete function call using dsf
.
#41
Comments
Similarly, it's not possible to change a function call to something else using |
I have pushed a first attempt at removing a function. It will not change it though. The problem with deleting functions, is that it will try to get an outer and inner overlay from evil using f as the char argument, for which evil has not text-objects. I added a test case in the |
I've re-written evil-surround-delete-function, so it uses evil procedures. I have tested and it works pretty well. I have commited it to my test branch. Please review and test it. And let me know if you find anything wrong with it. |
Thanks for working on this! I'm testing it right now. It works in Python and R scripts but for some reason not in the scratch buffer. There it is doing weird things, deleting wrong characters. As you say, it only works correctly when the cursor is in the parenthesis. Perhaps, you could change it to do nothing at all when the cursor is outside? That would be much better than the erratic behaviour that we get with the current code when the point is outside. Here is an interesting case:
When you place the cursor on arg and enter |
You mean emacs' scratch buffer? Thats wierd. Do you have a test case? It should do nothing when it is outside. I'm relying on '[ (' Which doesn't move unless it's inside the function. In the test case you post, you have unbalanced parens. I don't know how to handle that case. If the parens where balanced, you could delete funB, by placing point on any of 'funA('. |
Sorry, there was a typo in the test case. What I meant was of course this:
I can't reproduce the erratic behaviour in the scratch buffer, so forget that. However, when I place the cursor on "u" in the following example
and enter
This happens in the scratch buffer and in other buffers as well. |
Are you sure you are using the version in my test branch? I'm not getting the behavior you describe. If I place the point anywhere in |
I'm using ac3017c from the test branch. I think I found the problem: in line 171, you assume that |
Thats strange.
Here is the code of the function. If |
On my system, I have this definition:
This is also the version in the current development version of Evil. Git blame says that this function was changed in January by Frank Fischer. See here. |
Oops. I have pulled evil master. And updated the function to test for -1 first, then thought it would be better to test for 0. So I made another commit to fix that. Should work now. |
Works, nice. The question is whether we can rely on the return value of
|
Good Idea. Done!. Just changed |
Ah, right. |
I would like to work on this problem. It plagues more than just the function surround, also things like #69. Is there no word from @timcharper on how he would like this to look? |
well, I stopped using evil since then for vanilla emacs. My implementation worked just fine for me. It deleted the surrounding function, but I didn't get around at implementing changing the surrounding function. IIRC. Tim proposed this addition to vim surround and it wasn't accepted so he didn't include it here for compatibility with the original. I may be wrong though. |
Yeah, this project targets compatibility with vim.surround... for... reasons. The plugin, right now (for the most part...), doesn't have any special considerations for different major modes. I'd like to keep it that way. There's no standard Emacs way to define an overlay for a function. It just doesn't exist. This feature would require a special function for every major mode people use. If you come up with a snippet that people can paste in to their |
Adding a surrounding function isn't specialized by major mode either, though. The feature I was looking for was for |
Those keybindings don't seem to work for me. And, I'm not sure what you mean by "adding a surrounding function isn't specialized by major mode". It's syntax specific. In |
Really? That's not what I'm seeing. Let me use non-visual state so the bindings are the same. For example with cursor on the word Are we talking about the same thing? |
Okay; I've never used the key sequence. You're right, it does work, and it doesn't the right thing lisps (it assumes that all functions in all modes are called with |
Is this supported in |
for those seeking a quick fix, https://github.com/cute-jumper/embrace.el combined with evil-embrace (linked there--hooks into evil-surround with one line) allows (non-language-aware) dsf and csf |
Awesome, thanks for sharing, @braham-snyder. |
With the existence of evil-embrace, I think we can close this now. |
Since it's possible to wrap a text object in a function call with, e.g.,
yssf
, I would expectdsf
to delete that function call. Seems like a very useful feature.The text was updated successfully, but these errors were encountered: