Giter Club home page Giter Club logo

Comments (5)

TheBB avatar TheBB commented on May 22, 2024

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make `evil-last-sexp' work with closing parenthesis under point (fixed #17)

This is done by advicing preceeding-sexp' and pp-last-sexp'.

from evil.

TheBB avatar TheBB commented on May 22, 2024

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make `evil-last-sexp' work with closing parenthesis under point (fixed #17)

This is done by advicing preceeding-sexp' and pp-last-sexp'.

from evil.

TheBB avatar TheBB commented on May 22, 2024

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make `evil-last-sexp' work with closing parenthesis under point (fixed #17)

This is done by advicing preceeding-sexp' and pp-last-sexp'.

from evil.

TheBB avatar TheBB commented on May 22, 2024

Original comment by Anonymous:


Thinks. I had to change them slightly so that they continued to work in insert-mode (I'm not sure if that was the intent, but I like it like that). But I have discovered one edge case (which also affects my solution): save-excursion means you can't move the cursor when doing eval-last-sexp in normal-mode. My current fix is to advise the "find the last sexp" functions instead:

(defadvice preceding-sexp (around evil)
  "In normal-state, last sexp ends at point."
  (if (evil-normal-state-p)
      (save-excursion
	(unless (or (eobp) (eolp)) (forward-char))
	ad-do-it)
    ad-do-it))

(defadvice pp-last-sexp (around evil)
  "In normal-state, last sexp ends at point."
  (if (evil-normal-state-p)
      (save-excursion
	(unless (or (eobp) (eolp)) (forward-char))
	ad-do-it)
    ad-do-it))

(I'm not sure why both of these functions exist.) I haven't noticed any problems with this. It's possible that if someone uses these functions noninteractively, things would break; in that case, I can't think of a better solution than "reimplement [pp-]eval-last-sexp". But in core, they don't seem to be used anywhere bad: just a helper function of eval-last-sexp, and pp-eval-last-sexp and pp-macroexpand-last-sexp, respectively.

from evil.

TheBB avatar TheBB commented on May 22, 2024

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


You may try the following code which advices some function when evil
is activated. If you use at least 35ff006 those modifications should
be activated if and only if evil is active. If those modifications
work they could go into evil's code.

;;; eval-last-sexp
(defadvice eval-last-sexp (around evil)
  "Last sexp ends at point."
  (when (evil-normal-state-p)
    (save-excursion
      (unless (or (eobp) (eolp)) (forward-char))
      ad-do-it)))

;;; pp-eval-last-sexp
(defadvice pp-eval-last-sexp (around evil)
  "Last sexp ends at point."
  (when (evil-normal-state-p)
    (save-excursion
      (unless (or (eobp) (eolp)) (forward-char))
      ad-do-it)))

from evil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.