emacsorphanage / macrostep

interactive macro-expander for Emacs
GNU General Public License v3.0
15 stars 6 forks source link

macrostep-c Not working with c-ts-mode #8

Open Dickby opened 1 year ago

Dickby commented 1 year ago

Whenever I try to use macrostep in c-ts-mode it errors with Scan error: "Unbalanced parentheses". If i really need to use it, i have to switch to c-mode just for that command.

montchr commented 8 months ago

I am also running into this same error message. However, it is happening even in emacs-lisp-mode.

I do also use some tree-sitter modes, though I still run into this error in sessions where none of them have been activated.

montchr commented 8 months ago

@Dickby do you happen to be using lispy + the macrostep lispy-compat feature?

montchr commented 8 months ago

Well, it might not matter anyway -- this is a known issue from the original repo (see the list). See https://github.com/joddie/macrostep/issues/11#issuecomment-384936570 for a workaround, which I can confirm fixes the issue. Reposting so it doesn't get lost:

;; <https://github.com/joddie/macrostep/issues/11>
;; <https://github.com/emacsorphanage/macrostep/issues/8>
(defun my-macrostep-expand-wrapper ()
  "Work around `macrostep-expand' not liking whitespace after a sexp."
  (interactive)
  (when (and (= ?\n (char-after))
             (= (point) (cdr (bounds-of-thing-at-point 'sexp))))
    (backward-char))
  (macrostep-expand))