[ESS] Thoughts on auto-saving all file buffers before any eval?
Vitalie Spinu
spinuvit at gmail.com
Sat Apr 12 18:28:31 CEST 2014
Hi Grant,
You don't need to advice all ESS eval functions. Use
ess-presend-filter-functions or comint-input-filter-functions. They are
called before each evaluation.
Vitalie
>>> Grant Rettke on Sat, 12 Apr 2014 11:12:33 -0500 wrote:
> Hi,
> The ESS manual communicates the philosophy that file-artifacts are
> the ultimate definition of the system and I agree. My first time
> using ESS, I found that the setting 'ess-mode-silently-save' was
> critical. Still wanting to have interactive evaluation, even used
> primarily from persistent file buffers, I wanted the file always to
> be in sync with what I'm doing in the system itself. With that goal
> in mind I added some advice.
> ; ------- SNIP --------- SNIP ---------
> (defun gcr/save-all-file-buffers ()
> "Saves every buffer associated with a file."
> (interactive)
> (dolist (buf (buffer-list))
> (with-current-buffer buf
> (when (and (buffer-file-name) (buffer-modified-p))
> (save-buffer)))))
> (defadvice ess-eval-region-or-line-and-step (before
> before-ess-eval-region-or-line-and-step activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-region-or-function-or-paragraph (before
> before-ess-eval-region-or-function-or-paragraph activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-region-or-function-or-paragraph-and-step (before
> before-ess-eval-region-or-function-or-paragraph-and-step activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-line (before before-ess-eval-line activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-line-and-go (before before-ess-eval-line-and-go
> activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-function (before before-ess-eval-function activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-function-and-go (before before-ess-eval-function-and-go
> activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-region (before before-ess-eval-region activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-region-and-go (before before-ess-eval-region-and-go
> activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-buffer (before before-ess-eval-buffer activate)
> (gcr/save-all-file-buffers))
> (defadvice ess-eval-buffer-and-go (before before-ess-eval-buffer-and-go
> activate)
> (gcr/save-all-file-buffers))
> ; ------- SNIP --------- SNIP ---------
> Question: is there a setting to do this already? How are other people
> achieving the same thing?
> Regards,
> Grant Rettke | AAAS, ACM, AMA, COG, FSF, IEEE, Sigma Xi
More information about the ESS-help
mailing list