joddie / macrostep

interactive macro-expander for Emacs
204 stars 27 forks source link

`macrostep-expand` fails with a "Scan error" unlike `eval-last-sexp` #11

Open wasamasa opened 9 years ago

wasamasa commented 9 years ago

With eval-last-sexp you can evaluate the last expression even if you put your cursor on the whitespace after the outer form, macrostep-expand however fails with Scan error: "Unbalanced parentheses". Would it make sense to remedy this behaviour for more consistency?

stsquad commented 6 years ago

Now I know what the problem is I have this fairly dumb solution:

;; see https://github.com/joddie/macrostep/issues/11
(defun my-macrostep-expand-wrapper ()
  "Workaround `macrostep-expand' not liking white-space after a sexp."
  (interactive)
  (when (and (= ?\n (char-after))
             (= (point) (cdr (bounds-of-thing-at-point 'sexp))))
    (backward-char))
  (macrostep-expand))