reddit / emacs

Is there an addon that can open images in org-mode with the system image viewer?

Joey_Green · 2022-04-23 15:43
I want to open images in org-mode files using the system image viewer (like Eye of Gnome in Linux), is there such an addon that can do this with a command?
Joey_Green · 2022-04-24 01:19
I figured out a way to do this, just add the following code to the configuration: ```lisp (defun get-open-image-template () (cond ((eq system-type 'darwin) "open %s") ((eq system-type 'gnu/linux) "eog %s") ((eq system-type 'windows-nt) "start %s") (t (error (format "Unsupported operating system: %s" system-type))))) (defun open-image () (interactive) (let ((image-path (org-element-property :path (org-element-context)))) (shell-command (format (get-open-image-template) image-path)))) ``` Restart emacs to make it take effect. When you want to open an image using the system image viewer, just put the cursor on the image, and run `M-x open-image`. P.S. The above code assumes that you've installed `Eye of Gnome` if you are in Linux. If you want to use other image viewers in Linux, change `eog` to the one you want.
h-m-b-tu · 2022-04-24 10:31
There is the `org-file-apps` variable which takes care of this inside orgmode.