* As always I much agree with Nick, looks like a great patch

** Meanwhile, this will read your R output and stick it at the end of the
line & and show it all-at-once

elisp:(progn (shell-command "rsync -a BlahRemoteHost:/blah-R-output.png
/tmp")(sleep-for 3)(iimage-mode))]] /tmp/blah-R-output.png <-[The .png file
showed up right here--no brackets necessary--but name of the file is]

*** RSync may be replaced by SCP for sure


On Mon, Dec 2, 2019 at 3:29 PM Nick Dokos <ndo...@gmail.com> wrote:

> Jack Kamm <jackk...@gmail.com> writes:
>
> > I've attached a patch which implements displaying remote images.
> >
> >> This is a longstanding problem, and there was an attempt to patch it in
> >> 2014, but the patch was never accepted:
> >> https://lists.gnu.org/archive/html/emacs-orgmode/2014-11/msg00583.html
> >
> > Compared to the previous attempt from 2014, I think my patch is simpler
> > -- it doesn't require creating any temp files.
> >
> >> The fault might be with image.el rather than with org-mode itself --
> >> for example, when I execute the following elisp, I get the same blank
> >> box:
> >
> > After doing some reading, I learned that image.el doesn't really create
> > the image. Instead, create-image simply creates a blank string with a
> > text property pointing to the image file location, and the rendering of
> > the image gets handled later by the C code (for example, png_load_body()
> > in image.c), which doesn't know how to read remote image files.
> >
> > Since I wasn't comfortable trying to get the C code to read the remote
> > file, I instead took the approach used by image-mode.el, which reads the
> > remote image file and passes its contents directly to create-image,
> > instead of just passing the filename.
> >
> > From 47120666dad6eb0b6ca716325d7de86924e1d28e Mon Sep 17 00:00:00 2001
> > From: Jack Kamm <jackk...@gmail.com>
> > Date: Thu, 28 Nov 2019 17:45:56 -0800
> > Subject: [PATCH] org: display remote images
> >
> > ---
> >  lisp/org.el | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/lisp/org.el b/lisp/org.el
> > index 90f222c8b..dc7bcc7aa 100644
> > --- a/lisp/org.el
> > +++ b/lisp/org.el
> > @@ -16754,13 +16754,20 @@ buffer boundaries with possible narrowing."
> >                           (t nil)))
> >                         (old (get-char-property-and-overlay
> >                               (org-element-property :begin link)
> > -                             'org-image-overlay)))
> > +                             'org-image-overlay))
> > +                       (remote-p (file-remote-p file)))
> >                     (if (and (car-safe old) refresh)
> >                         (image-refresh (overlay-get (cdr old) 'display))
> > -                     (let ((image (create-image file
> > +                     (let ((image (create-image (if (not remote-p)
> > +                                                    file
> > +                                                  (with-temp-buffer
> > +
> (insert-file-contents file)
> > +                                                    (string-make-unibyte
> > +
>  (buffer-substring-no-properties
> > +                                                      (point-min)
> (point-max)))))
> >                                                  (and
> (image-type-available-p 'imagemagick)
> >                                                       width 'imagemagick)
> > -                                                nil
> > +                                                remote-p
> >                                                  :width width)))
> >                         (when image
> >                           (let ((ov (make-overlay
>
> FWIW, looks good to me, but I've only (carefully) read the patch: I have
> not actually ran it.
>
> --
> Nick
>
> "There are only two hard problems in computer science: cache
> invalidation, naming things, and off-by-one errors." -Martin Fowler
>
>
>

Reply via email to