我想加concat, 但是不知道怎么加,我对代码不熟。我加的concat,emacs识别不了,所以来向你们求助了。
shell-command 不需要引号吧?
因为不是很了解 windows, 我只能建议你先弄明白用 cmd 或者别的什么需要输入什么命令,再确保传递给 shell-command 的字符串就是需要的命令。
至于 format 之类的用法,结合文档多试几次就可以学会了。
上面的代码可以运行,没有问题。就是不知道怎么简化,试了好多次了,我对lisp不了解,写的代码全都参考别人来的。没有在google上搜到类似的代码。
(setq lxeg0429-capture-path "C:/Total Commander/Software/Emacs/Files/Images" )
(defun lxeg0429/capture ()
"Take a screenshot into a unique-named file in the current buffer file
directory and insert a link to this file."
(interactive)
(lower-frame) ;; 把emacs最小化
(let ((filename
(concat (make-temp-name "img-") ".png"))
(filepath lxeg0429-capture-path))
(shell-command (concat " \"C:/Total Commander/Software/IrfanView/i_view32.exe\" /capture=4 /convert="
"\"" filepath (format "\\%s\"" filename))) ;; IrfanView 截图
(insert (concat "[[" filepath filename "][capture]]")))
)
差不多就这样。
哦,好的,谢谢了。又学了不少东西。
i_view32.exe /capture=2 /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg
在 i_options.txt 选项文件中看到这一段, 我想用日期时间格式来生成截图的文件名, elisp 不会, 试了几次都不行, 请教!
有个format-time-string
可以用
示例:
(format-time-string "%Y%m%d%H%M%S")
==> "20170308195653"
emacs-lisp最基本的用法可以参考:
如果不怎么会lisp的话,把我的示例里面(make-temp-name "img-")
用这个换掉就可以了。
谢谢! 我试试, 你说的叶文彬的前段时间是有在学,但只看了点就放下了, 因最近工作忙(本人非 IT人士)。
非IT人士+1 不见得一定要集中学习,要用到的时候看一看就可以了。
感觉这里应该是 user 居多,developer 占少数吧?我也是 user 一枚:stuck_out_tongue_closed_eyes:
非IT人士+1
很奇怪这段代码在我的spacemacs上运行不了,调试显示是shell-command这一行出问题编译是总把i_view.exe变成i_view.exe,应该是此处的正则表达式出了问题,不知道是不是网页格式引起的,调试了两天都没解决,请问能发一个txt纯文本附件么?
Win7截图软件的话,可以试试一个叫Snipaste
的软件,我觉得挺好的。
现在 org-download 已经支持 IrfanView 截图了(我提的 PR),不需要用上述代码。
snipaste 好像只有付费版才支持命令行,命令行截图目前 Windows 上我用的最好的也还是 IrfanView
在spacemacs中怎么配置呢? 这样配置好像不行。
(org :variables
org-download-screenshot-method "IrfanView")
抄楼上的,可以用:
(defun screen-capture ()
"Take a screenshot into a unique-named file in the current buffer file
directory and insert a link to this file."
(interactive)
(lower-frame)
(let ((capture-name (concat
(format-time-string "%Y%m%d%H%M%S") ".png"))
(capture-save-path (concat
(file-name-directory buffer-file-name) "images/")))
(setq capture-file (concat capture-save-path capture-name))
(shell-command (concat
"i_view64 /capture=4 /dpi=(150,150) /convert="
(replace-regexp-in-string "/" "\\\\" capture-file)))
(insert (concat
"[[file:./images/" capture-name "][Capture-" capture-name "]]")))
)
(define-key org-mode-map (kbd "C-c o s") 'screen-capture)
先安装IrfanView,把i_view64命令 加到环境变量中,然后spacemacs配置如下
(org :variables
org-download-screenshot-method "i_view64 /clippaste /convert=\"%s\"")
效果如下
我一般不喜欢直接在buffer中显示图片,我使用 posframe 弹出图片3秒后,确定效果
IrfanView支持截图期间变换窗口嘛?比如上图中不想截屏Emacs,但是需要截屏Chrome。WIN下哪些命令行截屏工具支持在截图期间变换窗口?
QQ、微信、系统自带截图工具任意地方截屏都可以。