From fe9389377c2ac19757278413a717a0a047029c17 Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Sat, 29 Mar 2025 16:55:49 +0100 Subject: [PATCH] New command sage-shell-edit:attach-buffer * sage-shell-mode.el: (sage-shell-edit:attach-buffer): New command. Allows attaching the current buffer to the Sage process. This complements the existing attach-file function in the same way that send-buffer complements load-file. --- sage-shell-mode.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sage-shell-mode.el b/sage-shell-mode.el index fe60efc..6d6abc3 100644 --- a/sage-shell-mode.el +++ b/sage-shell-mode.el @@ -4689,6 +4689,14 @@ inserted in the process buffer before executing the command." (sage-shell-edit:load-file bfn)) (t (sage-shell-edit:send--buffer))))) +(defun sage-shell-edit:attach-buffer () + "Attach the contents of the current buffer to the Sage process." + (interactive) + (let ((bfn (buffer-file-name))) + (cond ((and bfn (not (buffer-modified-p))) + (sage-shell-edit:attach-file bfn)) + (t (sage-shell-edit:send--buffer))))) + (defun sage-shell-edit:send-buffer-and-go () "Evaluate the contents of the current buffer in the Sage process." (interactive)