Open sogaiu opened 2 hours ago
Some points of consideration include:
(comment ...)
forms. It's not that useful to return nil
and it's not likely what a user intends.(defn ...)
s).If tree-sitter functionality is used, the cost involved to account for the above points may be reasonable.
A non-tree-sitter-based implementation that tries to handle the items above seems like it would be (much?) more costly. One idea is to provide something simpler.
Another consideration is how to handle detection of tree-sitter capabilities and behave appropriately.
Here is an initial attempt (note: this is on a separate branch).
A new command named ajrepl-send-top-level-exression
is provided. It is bound to C-M-x
(what eval-defun
's keybinding is locally). It's also exposed via the Ajrepl menu.
The following method was used to provide an alternate implementation in case tree-sitter functionality is not available:
;; https://emacs.stackexchange.com/a/30086
(when (not (require 'ajrepl-ts nil 'noerror))
(defun ajrepl-send-top-level-expression ()
"Send top-level expression containing point."
(interactive)
(save-excursion
(let ((beg nil)
(end nil))
(ajrepl--column-zero-target-backward)
(setq beg (point))
(forward-sexp)
(setq end (point))
(ajrepl-send-region beg end)))))
Some rearrangement of code was done to get the above to work out.
It was pointed out on Zulip that there is no command to send a top-level expression.