You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to use multiple essgd buffers, so that if we have displayed, say, three different plots, we can see more than one at the same time. This should work, as httpgd allows multiple clienst to have different plots of the history (nx10/httpgd#7 (comment)). And it works, but the code below can be improved a lot, I think (elisp ignorant here).
This is the code:
;; A one-line modification of essgd-start
(defunessgd-start-another ()
"Start an *essgd* buffer to plot R output.Must be called from a buffer that is either an *R* process, or attached to one.The initial size of the plot is half the current window."
(interactive)
(let ((buf (get-buffer-create essgd-buffer))
(r-proc ess-local-process-name)
start-output)
(set-buffer buf)
(essgd-mode)
(if r-proc
(setq ess-local-process-name r-proc)
(user-error"No r process to communicate with"))
;; RDU: do not start the hgd() device here but use existing one
(setq start-output (ess-string-command "message(httpgd::hgd_url())"))
;; if minibuffer changes size, then we might get a dynamic resize!
(setq-local resize-mini-windows nil)
(string-match"\\(http://[0-9.:]+\\)/live\\?token=\\(.+\\)" start-output)
;; TODO - check case when token is missing.;; TODO - error check if URL ccannot be found.
(setq essgd-url (match-string1 start-output))
(setq essgd-token (match-string2 start-output))
(if (> (length essgd-token) 0)
(setq essgd-token (format"token=%s" essgd-token)))
(setq essgd-plot-nums (essgd-get-plot-nums))
(setq essgd-cur-plot
(length essgd-plot-nums))
(setq essgd-latest (make-temp-file"essgd"nil".svg"))
(display-buffer buf)
(setq-local window-size-change-functions '(essgd-window-size-change))
(when (> essgd-cur-plot 0)
(essgd-show-plot-n essgd-cur-plot))
(essgd-start-websocket)
(setq cursor-type nil)
(read-only-mode1)))
(defunnew-essgd (num)
"Create a new *essgdnum* buffer for plotting."
(interactive"P")
(setq essgd-buffer (format"*essgd%d*" num))
(essgd-start-another))
Now:
Start R and essgd
Plot a bunch of things
C-u 2 M-x new-essgd
Right after creation, you can move back and forth independently in each essgd buffer. But if you keep creating plots, the old essgd buffer no longer shows the newer plots (this is in contrast to the behavior with EAF ---below---, where adding plots allows you to move back and forth over all plots in the EAF and essgd buffers). They all get updated, though, if you resize or manually trigger refresh (r).
I'd like to be able to use multiple essgd buffers, so that if we have displayed, say, three different plots, we can see more than one at the same time. This should work, as httpgd allows multiple clienst to have different plots of the history (nx10/httpgd#7 (comment)). And it works, but the code below can be improved a lot, I think (elisp ignorant here).
This is the code:
Now:
C-u 2 M-x new-essgd
Right after creation, you can move back and forth independently in each essgd buffer. But if you keep creating plots, the old essgd buffer no longer shows the newer plots (this is in contrast to the behavior with EAF ---below---, where adding plots allows you to move back and forth over all plots in the EAF and essgd buffers). They all get updated, though, if you resize or manually trigger refresh (r).
For the sake of completeness (and because that was my first try) this also works if we combine essgd with EAF, Emacs Application Framework (https://github.com/emacs-eaf/emacs-application-framework).
This is a reproducible example
Launch R
Start essgd
Create two different plots
Get the URL via
httpgd::hgd_url()
Place point on the URL and do
M-: (eaf-open-browser (thing-at-point 'url))
One now has the essgd and the EAF buffers. And one can move back and forth in each independently, as one keeps adding plots.
The text was updated successfully, but these errors were encountered: