Paste an image on clipboard to Emacs Org mode file without saving it

后端 未结 8 1079
慢半拍i
慢半拍i 2021-01-30 09:21

As I\'m using the Emacs Org mode as a research log, sometime I want to keep track of something via screenshot images, and I definitely don\'t want to save them. So I\'m wonderin

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 09:44

    The answers here focus on initiating the process within emacs. An alternative, on macos, is to place a screenshot image on the system clipboard using cmd-ctl-shift-4, and then to return to Emacs and use emacs lisp to call pngpaste to write the image from clipboard to file, and do whatever you need to with the image file (insert into org, LaTeX, or as a native Emacs inline image etc).

    For example, to insert into org:

    (defun org-insert-clipboard-image (&optional file)
      (interactive "F")
      (shell-command (concat "pngpaste " file))
      (insert (concat "[[" file "]]"))
      (org-display-inline-images))
    

提交回复
热议问题