only send top level functions

... and don't get confused by functions within functions
This commit is contained in:
Valentin Boettcher 2025-01-22 12:57:10 -05:00
parent 6b39ac33fc
commit 461b8c423b
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE

View file

@ -584,14 +584,6 @@ point, the cell is assumed to end with the buffer."
If the function has no arguments, the function call is run immediately."
(interactive)
(save-mark-and-excursion
;; (let ((last-mark (mark)))
;; (python-mark-defun)
;; (while (not (eq (mark) last-mark))
;; (setf last-mark (mark))
;; (python-mark-defun 1)))
;; (mark (region-beginning))
;; (next-line)
;; (cl-return)
(let ((begin (save-mark-and-excursion
(python-nav-beginning-of-defun 1)
(point)))
@ -599,6 +591,12 @@ If the function has no arguments, the function call is run immediately."
(python-nav-end-of-defun)
(point))))
(python-nav-beginning-of-defun 1)
(beginning-of-line)
(if (looking-at "[[:blank:]]+.*")
(progn
(previous-line)
(py-vterm-interaction-run-current-function))
(progn
(next-line)
(let ((function-name-regex "def[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)[ \t]*(\\(.*\\))\\([ \t]*->[ \t]*.*?\\)?:"))
(save-match-data
@ -626,7 +624,7 @@ If the function has no arguments, the function call is run immediately."
(py-vterm-interaction-paste-string (format "%s() " name))
(py-vterm-interaction-send-return-key))
(py-vterm-interaction-paste-string (format "%s(" name)))))
(message "No function found"))))))))
(message "No function found"))))))))))
(defun py-vterm-interaction-send-buffer ()
"Send the whole content of the script buffer to the Python REPL line by line."