I had to patch together some various emacs from around the web to get inline images with iimage.el working in emacs exactly the way I wanted. Here’s some info:
- Load and displays images in org files on initial load
- Provides a function that allows you to toggle images on and off
- Specify images you would like to load with the [[file://file.png]] org link type
Here’s the code, you can add it anywhere in your .emacs
;; -- Display images in org mode
;; enable image mode first
(iimage-mode)
;; add the org file link format to the iimage mode regex
(add-to-list 'iimage-mode-image-regex-alist
(cons (concat "\\[\\[file:\\(~?" iimage-mode-image-filename-regex "\\)\\]") 1))
;; add a hook so we can display images on load
(add-hook 'org-mode-hook '(lambda () (org-turn-on-iimage-in-org)))
;; function to setup images for display on load
(defun org-turn-on-iimage-in-org ()
"display images in your org file"
(interactive)
(turn-on-iimage-mode)
(set-face-underline-p 'org-link nil))
;; function to toggle images in a org bugger
(defun org-toggle-iimage-in-org ()
"display images in your org file"
(interactive)
(if (face-underline-p 'org-link)
(set-face-underline-p 'org-link nil)
(set-face-underline-p 'org-link t))
(call-interactively 'iimage-mode))
I have this function bound to C-l with a call like this:
(define-key org-mode-map (kbd "C-S-a") 'org-archive-subtree)
本文介绍了如何通过自定义代码片段将内联图片整合到Emacs Org Mode文件中,实现自动加载和切换显示功能。通过添加特定的Emacs配置,可以轻松地在Org文件中插入图片链接,并在打开文件时自动加载这些图片。同时提供了功能,允许用户在需要时关闭图片显示,灵活控制视觉效果。

478

被折叠的 条评论
为什么被折叠?



