emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Lionel Henry <lionel.hry@gmail.com>
Cc: emacs-orgmode@gnu.org, ESS-core@r-project.org
Subject: Re: [BUG] ob-R tests fail on Emacs 27 since ESS commit 536b5b914a7 [9.7-pre (release_9.6.4-318-gcfe5e0.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
Date: Tue, 18 Apr 2023 10:46:06 +0000	[thread overview]
Message-ID: <87mt35h3ip.fsf@localhost> (raw)
In-Reply-To: <CAAkLcbspUEO12VRe6kOchu833FV1VTe+bjo0N1T5s85CYzqPyw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

Lionel Henry <lionel.hry@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'?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-R-Fix-regression-after-ESS-commit-536b5b914a7.patch --]
[-- Type: text/x-patch, Size: 2621 bytes --]

From 07407519d2e8de0f2925a9d2971b855fd0be86b4 Mon Sep 17 00:00:00 2001
Message-Id: <07407519d2e8de0f2925a9d2971b855fd0be86b4.1681814636.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@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 <yantar92@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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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>

  reply	other threads:[~2023-04-18 10:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 18:45 [BUG] ob-R tests fail on Emacs 27 since ESS commit 536b5b914a7 [9.7-pre (release_9.6.4-318-gcfe5e0.dirty @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
2023-04-17 20:26 ` Lionel Henry
2023-04-18 10:46   ` Ihor Radchenko [this message]
2023-04-18 12:30     ` Lionel Henry
2023-04-18 13:11       ` Ihor Radchenko
2023-04-18 13:14         ` Lionel Henry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt35h3ip.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=ESS-core@r-project.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=lionel.hry@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).