Description
Is your feature request related to a problem? Please describe.
I usually want to call commands like cider-inspect
, and cider-macroexpand
with my cursor point at the beginning or middle of a form, instead of at the end like Cider expects.
Describe the solution you'd like
It's mainly a personal preference and habit, so I had cider-last-sexp
edited to the following, which moves the point to the appropriate position. Because lots of commands use this under the hood, it automatically makes them able to work with the point at beginning of a paren or symbol.
(defun cider-last-sexp (&optional bounds)
"Return the sexp preceding the point.
If BOUNDS is non-nil, return a list of its starting and ending position
instead."
(apply (if bounds #'list #'buffer-substring-no-properties)
(save-excursion
(unless (eq (point) (cdr (bounds-of-thing-at-point 'sexp))) ;; <== added
(forward-sexp 1)) ;; <== added
(clojure-backward-logical-sexp 1)
(list (point)
(progn (clojure-forward-logical-sexp 1)
(skip-chars-forward "[:blank:]")
(when (looking-at-p "\n") (forward-char 1))
(point))))))
Describe alternatives you've considered
nil
Additional context
This fix means that the command names and docstrings are no longer accurate - should be something like "sexp at point" instead of "preceding sexp"