0

Say you have a big big image that you can't really look at with emacs' image support, org-mode or image-mode buffer. You want to use program like gwenview or feh where you can zoom in and out easily and drag it around.

2 Answers 2

0
(defun view-remote-image (remote-path)
  (interactive "f")
  (let ((temp-file (make-temp-file "remote-image-"))
        (image-viewer-program "feh"))
    (copy-file remote-path temp-file t)
    (start-process "view-remote-image" nil image-viewer-program temp-file)))

Works with other type of file with bit modification. Big Big images (like generated UML diagram) would be a major use cases. open-with doesn't work out of box, as you'll be passing command like feh /ssh:user@host:/path/to/img.png which will fail.

1
  • file-local-copy would help. Instead of creating a temp file yourself, yust say (setq temp-file (file-local-copy remote-path)) Commented Aug 7 at 6:52
0

I personally use the open-with package (link) as follows, mostly from dired, for local images:

(use-package openwith
  :init
  (openwith-mode 1)
  
  :config
  (setq openwith-associations
        (list
         (list (openwith-make-extension-regexp
                '("png" "gif" "jpeg"))
               "feh"
               '(file))
         (list (openwith-make-extension-regexp
                '("pdf"))
               "gwenview"
               '(file)))))

where the extensions are just meant as an example. I don't use the programs you listed, and therefore the code above is not tested. It should nevertheless work with any program.

For the case of remote images, I use instead sshfs in the CLI, and treat all images as being local.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.