Can python.el be set up in a way that it will automatically save the current buffer when python-shell-send-buffer is called (e.g. by C-c C-c)?
It sure can be!
First, create a function that saves the buffer before calling
(defun my-python-shell-send-buffer () "Save the current buffer before calling `python-shell-send-buffer'." (interactive) (save-buffer) (python-shell-send-buffer))
interactive line allows you to call the function using
M-x. I suspect the other lines are self-explanatory. If not, read about them using
C-c C-c in
python-mode with the new function:
(define-key python-mode-map (kbd "C-c C-c") 'my-python-shell-send-buffer)
After executing each of these lines, when you reload
C-c C-c will work as you desire. Put these lines in
init.el and this will be the new behavior for