Lionel Henry <lionel....@gmail.com> writes: > Thanks for looking into this. I think you're right it's probably > caused by ESS now setting the width on startup. In that case you could > fix your tests by setting `options(width = )` to some hardcoded value. > You could do it via `ess-r-post-run-hook`.
I tried using `ess-r-post-run-hook', but it fails for some reason. See the attached patch. With the patch, the tests fail with Test ob-session-async-R-value-drawer condition: (user-error "ESS process not ready. Finish your command before trying again") In contrast, directly editing `ess-r-initialize' like ;; (ess-execute-screen-options t) (ess-command (ess-calculate-width 9999)) does not fail and make all the tests pass. Is there anything I am missing about `ess-r-post-run-hook'?
>From 07407519d2e8de0f2925a9d2971b855fd0be86b4 Mon Sep 17 00:00:00 2001 Message-Id: <07407519d2e8de0f2925a9d2971b855fd0be86b4.1681814636.git.yanta...@posteo.net> From: Ihor Radchenko <yanta...@posteo.net> Date: Tue, 18 Apr 2023 12:42:29 +0200 Subject: [PATCH] ob-R: Fix regression after ESS commit 536b5b914a7 * lisp/ob-R.el (org-babel-R--set-wide-screen-width): New function setting fill column to large value in ESS interactive shell. (org-babel-R-initiate-session): Override the default ESS truncation settings. Reported-by: Ihor Radchenko <yanta...@posteo.net> Link: https://orgmode.org/list/87ilduqrem.fsf@localhost --- lisp/ob-R.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 7ea137197..9ad878370 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -39,6 +39,10 @@ (declare-function orgtbl-to-tsv "org-table" (table params)) (declare-function run-ess-r "ext:ess-r-mode" (&optional start-args)) (declare-function inferior-ess-send-input "ext:ess-inf" ()) (declare-function ess-make-buffer-current "ext:ess-inf" ()) +(declare-function + ess-command "ext:ess-inf" + (cmd &optional out-buffer sleep no-prompt-check wait proc proc force-redisplay timeout)) +(declare-function ess-calculate-width "ext:ess-inf" (opt)) (declare-function ess-eval-buffer "ext:ess-inf" (vis)) (declare-function ess-wait-for-process "ext:ess-inf" (&optional proc sec-prompt wait force-redisplay)) @@ -261,7 +265,13 @@ (defun org-babel-R-assign-elisp (name value colnames-p rownames-p) (t (format "%s <- %S" name (prin1-to-string value)))))) +(defun org-babel-R--set-wide-screen-width () + "Set large screen width in current R buffer." + (org-require-package 'ess-inf "ESS") + (ess-command (ess-calculate-width 9999))) + (defvar ess-ask-for-ess-directory) ; dynamically scoped +(defvar ess-r-post-run-hook) (defun org-babel-R-initiate-session (session params) "If there is not a current R process then create one." (unless (string= session "none") @@ -277,7 +287,10 @@ (defun org-babel-R-initiate-session (session params) ;; Session buffer exists, but with dead process (set-buffer session)) (org-require-package 'ess-r-mode "ESS") - (set-buffer (run-ess-r)) + (let ((ess-r-post-run-hook + (cons #'org-babel-R--set-wide-screen-width + ess-r-post-run-hook))) + (set-buffer (run-ess-r))) (let ((R-proc (get-process (or ess-local-process-name ess-current-process-name)))) (while (process-get R-proc 'callbacks) -- 2.40.0
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>