Skip to content

simple way to evaluate context sensitive expressions #2161

@qq00

Description

@qq00

motivation

file a ticket and put there our conversation highlights. Then everything is possible. -- @bbatsov 

problem

Consider the following expression:

(let [doge 20]
  (def awesome (fn [x] (* x 3)))
  (let [cider (awesome doge)]
    (+ cider doge) ;; cursor is here
    (stuff we d9n 't care about)
    (more stuff we dont care about)))

Is there a wa yto make C-x C-e work ?

key idea

  1. find 'outermost enclosing sexp' by repeatedly looking up parent element
  2. prematurely end sexp by adding )]} at cursor
  3. evaluate the 'new parent sexp'
  4. in the above case, we end up executing
(let [doge 20]
  (def awesome (fn [x] (* x 3)))
  (let [cider (awesome doge)]
    (+ cider doge) ;; cursor is here))

praise for this approach

That’s actual much simpler as we already have the code that finds the top-level expression and the only thing needed it just terminate the expression after the current sexp. Should be trivial to implement.
-- @bbatsov 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions