2

I'd like to advise the inferior-ess-send-input interactive function to call my function which refreshes the *R dired* buffer automatically. I've tried using after and around as classes. For example:

(defadvice inferior-ess-send-input (around ess-revert-rdired-after-send activate)
    ad-do-it
    (call-interactively 'ess-revert-rdired-buffer))

I've also tried using after and even changed the source code of ESS to create a post-run hook. All of them had the same issue. I've even defined a new function which calls one after the other.

But I keep getting the message:

ess-error: ESS process not ready. Finish your command before trying again.

comming from ess-command. For some reason, adding this advice makes sprocess busy. Any ideas?

P.S.

Here the function is (work in progress):

(defun ess-revert-rdired-buffer ()
  "If the buffer is live, update it. If it isn't start it."
  (interactive)
  (save-selected-window
     (if (buffer-live-p (get-buffer "*R dired*"))
    (save-excursion
      (with-current-buffer "*R dired*"
        (revert-buffer)))
      (ess-rdired))))
wdkrnls
  • 4,548
  • 7
  • 36
  • 64

1 Answers1

1

I discovered that waiting 0.05 seconds was enough time for the process to get ready.

wdkrnls
  • 4,548
  • 7
  • 36
  • 64
  • did you solve this? I think in general its quite hard to do as the *R* buffer would have no way in general to signal its finished back to Emacs. We could try something that would use a timer to refresh the *dired* buffer every 10 s or so, but before trying to update, it would first check that the *R* process is not busy. Would that work for you? – Stephen Eglen Aug 15 '14 at 16:31
  • Yeah, I couldn't call my solution a general one. I didn't test it for long scripts for example. But the 0.5 second wait period worked for assigning simple variables. – wdkrnls Aug 17 '14 at 14:33
  • It turns out my solution breaks multi-line function definitions. So, having a better way to do it would be great, but I'm leery of a timer based method. What prevents Emacs from solving it the way RStudio does? – wdkrnls Aug 17 '14 at 14:47