在emacs org-mode 中插入截图

使用iimage-mode可以在buffer里面显示图片,改了一个lisp函数来实现截屏、保存文件并插入到buffer中的功能。参考了这个: http://dreamrunner.org/wiki/public_html/Emacs/org-mode.html#sec-2-3

安装起来很简单:

安装scrot,会用这个工具来截图

创建一个文件夹 ~/.emacs.img ,截屏产生的图片会保存到这里

把下面的lisp放到emacs的配置文件中(我把截屏的快捷键绑定到了C-p上面)

;;; image for org-mode
; 1. suspend current emacs window
; 2. call scrot to capture the screen and save as a file in $HOME/.emacs.img/
; 3. put the png file reference in current buffer, like this: [[/home/path/.emacs.img/1q2w3e.png]]

(add-hook ‘org-mode-hook ‘iimage-mode) ; enable iimage-mode for org-mode
(defun my-screenshot ()
“Take a screenshot into a unique-named file in the current buffer file
directory and insert a link to this file.”
(interactive)
(setq filename
(concat (make-temp-name
(concat (getenv “HOME”) “/.emacs.img/” ) ) “.png”))
(suspend-frame)
(call-process-shell-command “scrot” nil nil nil nil ” -s ” (concat
“\”” filename “\”” ))
(insert (concat “[[” filename “]]”))
(org-display-inline-images)
)

(global-set-key (kbd “C-p”) ‘my-screenshot)

相关代码已经提交到了github上,欢迎fork https://github.com/Chengming/org-screenshot

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值