branch: externals/ess commit 536b5b914a75afa37ee05aa8ba0aecd0f9c9eb33 Author: Lionel Henry <lionel....@gmail.com> Commit: Lionel Henry <lionel....@gmail.com>
Move `ess-r` startup commands out of `ess-r-post-run-hook` They are blocking commands and the user might have added streaming commands to the hook. Also document why users should be careful when mixing blocking and streaming commands. --- lisp/ess-custom.el | 6 +++++- lisp/ess-r-mode.el | 16 ++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/ess-custom.el b/lisp/ess-custom.el index 9574f5fd5a..8f61588dac 100644 --- a/lisp/ess-custom.el +++ b/lisp/ess-custom.el @@ -1400,7 +1400,11 @@ Good for setting up your directory." (defcustom ess-post-run-hook nil "Hook to call just after the ESS process starts up. -Good for evaluating ESS code." +Currently this should not be used to interact with the inferior +process because this hook runs too early, before the inferior +mode had a chance to properly start up the process. To interact +with the process, you must use a mode-specific hook like +'ess-r-post-run-hook'." :group 'ess-hooks :type 'hook) diff --git a/lisp/ess-r-mode.el b/lisp/ess-r-mode.el index 16e5d1a02b..8643924b03 100644 --- a/lisp/ess-r-mode.el +++ b/lisp/ess-r-mode.el @@ -544,10 +544,12 @@ fill=TRUE); try(traceback(), silent=TRUE)})\n") ;; send "run". So this is no longer generic and inferior modes need ;; to call this manually. One way to fix this would be to make ;; `inferior-ess' a `cl-defgeneric'. -(defvar ess-r-post-run-hook '((lambda () - (ess-execute-screen-options t) - (ess-set-working-directory default-directory))) - "Functions run in process buffer after the initialization of R process.") +(defvar ess-r-post-run-hook nil + "Functions run in process buffer after the initialization of R process. +Make sure to call blocking commands (e.g. based on `ess-command') +first. Streaming commands (e.g. based on `ess-send-string') +should come last, otherwise they will make R busy and the +blocking commands will throw an error.") ;;;###autoload (defun run-ess-r (&optional start-args) @@ -648,10 +650,12 @@ Executed in process buffer." (ess-command (format "if (identical(getOption('pager'), file.path(R.home(), 'bin', 'pager'))) options(pager = '%s')\n" - inferior-ess-pager))) - (ess-r-load-ESSR) + inferior-ess-pager)) + (ess-r-load-ESSR)) (when inferior-ess-language-start (ess-command (concat inferior-ess-language-start "\n"))) + (ess-execute-screen-options t) + (ess-set-working-directory default-directory) (when ess-use-tracebug (ess-tracebug 1)) (add-hook 'ess-presend-filter-functions 'ess-R-scan-for-library-call nil 'local)