-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Clojure-mode evaling last sexpr not using current char #646
Comments
Bump. This makes it impossible to evaluate the SEXP behind the cursor in normal mode unless you've |
I'm also experiencing this problem. If you set the cursor on the ")" in |
For the benefit of people googling this, the problem is related to |
Can you try with |
@syl20bnr Setting |
Ok thank you for the feedback. |
I hope that this does not affect |
What behavior ? The difference in behavior between elisp and clojure is expected ? |
The default behavior in Emacs in any Lisp is that an sexpression is considered last sexpression when point is after its closing parenthesis. For example, |
So we have a bug in elisp. |
editI've just tested this and it's working fine (if (< 4 5)(message "yes")) having the cursor on the last paren evaluated that line, whoops I've been using eLisp a little, and when doing so this is something that I've noticed. That I have to go to the end of the line, add a space exit insert mode and run. Otherwise the cursor will land on the |
Which bug? In Emacs, it is expected the way I described and it should stick with |
@tuhdo I've just tested this out and it worked fine actually! (if (< 4 5)(message "yes")) having the cursor on the last paren evaluated that line |
The expected behavior in |
..... There is a different behavior in elisp and clojure, when one is true it @tuhdo you say that clojure behavior is expected then elisp has a bug, they Le mercredi 27 mai 2015, Tu Do notifications@github.com a écrit :
-syl20bnr- |
Because Emacs users write these Lisp packages, it is expected to behave the way I described in any Lisp. If Vim users have problem with it, then it should only be fixed when Vim editing style is active, or let Vim users get used to it. |
I understand what you mean and I won't touch the way Emacs users eval their code. I just realized that we cannot have consistent behavior between holy-mode and vim because in vim the point cannot go beyond the last character of a line (I never had this trouble because of So in Vim style we will evaluate the sexp with the point included everywhere. In holy-mode we don't touch anything and eval the sexp before the point. |
But............ we will have inconsistencies with insert state. Argh....... tough tough decision. I can set |
@syl20bnr is there a way to set the evil-cursor-back only before doing The probelm it seems is that...even though the cursor is at the paren, Emacs interpretes the cursor as being on the left. |
@CestDiego You are onto something. I bet there is some code in Evil to specifically evaluate last-sexp while being on the parenthesis instead of after to fix the end of line issue. |
@syl20bnr but currently it works in emacs lisp! D: |
What's working ? :p on the parenthesis ? after the parenthesis ? |
I think the code where evil is monkey-patching the "last-sexp" functions is here: https://github.com/emacsmirror/evil/blob/3aef97498926100c4c7e5f335dd32d49ef0c56a1/evil-integration.el#L315-L330 |
So I would go with another solution than the Evil one for this issue, that is:
Since it diverges a bit from Vim I doubt it can be OK to propose it to Evil maintainer, but in Spacemacs we can do it. |
The following advice seems to fix it for me: (defadvice cider-last-sexp (around evil activate)
"In normal-state or motion-state, last sexp ends at point."
(if (or (evil-normal-state-p) (evil-motion-state-p))
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
ad-do-it)
ad-do-it)) Note that I don't really know elisp and hadn't heard the term advice applied to lisp as of 15 min ago. |
if you known python |
@pesterhazy so we have a solution for the second fix possibility 👍 I still like to investigate the other possibility though. |
I just tried it in stock That also means that the cursor should be able to go behind the last character in the line, as it does when you press |
I suppose it makes more sense if |
Huh, now I understand what you were saying in the first place; |
@syl20bnr If I remember correctly it was this |
PR submitted to allow to set the point beyond the last character of a line and to have regular eval-sexp everywhere in Emacs: https://bitbucket.org/lyro/evil/pull-request/13/add-new-configuration-variable-evil-move/diff |
has this gotten any attention from |
I proposed a PR which got merged, it is a new variable to get the emacs Le samedi 4 juillet 2015, Diego Berrocal notifications@github.com a
-syl20bnr- |
I just realised |
Hi guys, was poking with same problem. And spotted this issue. How can I use this new vaiable? Is it avaiable at the current stable release? Where should I define it? |
As far as I understand solution by @syl20bnr is to allow to move cursor behind end of the line. |
It is now possible to move the cursor behind the end character of a line. In emacs-lisp the behavior is back to normal where the evaluated expression corresponds to the expression Note that some work remains to be done to fix the |
yay, works great! Thanks a lot! On 08/12/2015 04:51 AM, Sylvain Benner wrote:
|
I'm messing around with spacemacs for clojure development. Way cool! I've been using emacs for a long time and am just now learning vim and modal editing. I'm working on some interactive development stuff and I'm wondering how I can avoid chopping off the last character of the expression I am evaluating. If I do ",es" it doesn't include the current character inside the sexpr it goes back to find. This isn't the case in elisp mode.
For example:
If the selected character is to the right of the | above, then using ",es" will not use the last
)
and will return two instead of the new function.The text was updated successfully, but these errors were encountered: