运行 emacs批处理时如何避免提示保存缓冲区
How to avoid prompt to save buffer when running emacs batch
我运行宁
/usr/bin/emacs -l ~/.emacs -eval '(org-icalendar-export-agenda-files)' --batch
在 cron 作业中。
Orgmode 将 uuid
添加到议程文件中的新待办事项的属性中,但随后会提示保存议程文件(仅当 运行 从命令行以批处理模式)。
Save file /home/user/gtd/work.org? (y or n)
我笨拙的解决方法是 echo y | /usr/bin/emacs...
。但由于实际上有 3 个议程文件可能被修改,这不是一个好的解决方案。必须要设置一些变量,或者会导致 org-icalendar-export-agenda-files
只保存它修改的文件。
你会得到帮助吗
函数 save-some-buffers
在 emacs 中?
喜欢
/usr/bin/emacs -l ~/.emacs -eval '(progn (org-icalendar-export-agenda-files) (save-some-buffers t))' --batch
是的,它可以被视为一种拼凑。
使用 defadvice
通常不是一个好的做法1 但是,如果您想要修复此问题并且迫不及待地想将您的修复包含在下一个中emacs 版本,试试这个:
(defadvice org-icalendar-create-uid (after org-icalendar-create-uid-after activate)
(save-buffer))
这建议 org-icalendar-create-uid
以便在创建新 UID 时保存当前缓冲区2。你需要非常小心地建议功能。我建议创建一个类似于此的 export-icalendar.el
脚本:
;; initialize org-mode
(require 'org)
;; pick your agenda files
(setq org-agenda-files '("~/org"))
;; store UIDs in properties drawer
(setq org-icalendar-store-UID t)
;; optional configuration
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
(setq org-agenda-default-appointment-duration 50)
;; avoid interactive prompts if UIDs are created
(defadvice org-icalendar-create-uid (after org-icalendar-create-uid-after activate)
(save-buffer))
(org-icalendar-combine-agenda-files)
要运行,就这样3:
emacs --batch -l export-icalendar.el
1: http://emacswiki.org/emacs/AdvisingFunctions
2:org-icalendar-create-uid
在with-current-buffer
内部调用,详见ox-icalendar.el
3:永远不要 运行 org-icalendar-combine-agenda-files
到 eval
使用 emacsclient
,如果您已经在访问议程文件,它会导致问题。
我运行宁
/usr/bin/emacs -l ~/.emacs -eval '(org-icalendar-export-agenda-files)' --batch
在 cron 作业中。
Orgmode 将 uuid
添加到议程文件中的新待办事项的属性中,但随后会提示保存议程文件(仅当 运行 从命令行以批处理模式)。
Save file /home/user/gtd/work.org? (y or n)
我笨拙的解决方法是 echo y | /usr/bin/emacs...
。但由于实际上有 3 个议程文件可能被修改,这不是一个好的解决方案。必须要设置一些变量,或者会导致 org-icalendar-export-agenda-files
只保存它修改的文件。
你会得到帮助吗 函数 save-some-buffers 在 emacs 中? 喜欢
/usr/bin/emacs -l ~/.emacs -eval '(progn (org-icalendar-export-agenda-files) (save-some-buffers t))' --batch
是的,它可以被视为一种拼凑。
使用 defadvice
通常不是一个好的做法1 但是,如果您想要修复此问题并且迫不及待地想将您的修复包含在下一个中emacs 版本,试试这个:
(defadvice org-icalendar-create-uid (after org-icalendar-create-uid-after activate)
(save-buffer))
这建议 org-icalendar-create-uid
以便在创建新 UID 时保存当前缓冲区2。你需要非常小心地建议功能。我建议创建一个类似于此的 export-icalendar.el
脚本:
;; initialize org-mode
(require 'org)
;; pick your agenda files
(setq org-agenda-files '("~/org"))
;; store UIDs in properties drawer
(setq org-icalendar-store-UID t)
;; optional configuration
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
(setq org-agenda-default-appointment-duration 50)
;; avoid interactive prompts if UIDs are created
(defadvice org-icalendar-create-uid (after org-icalendar-create-uid-after activate)
(save-buffer))
(org-icalendar-combine-agenda-files)
要运行,就这样3:
emacs --batch -l export-icalendar.el
1: http://emacswiki.org/emacs/AdvisingFunctions
2:org-icalendar-create-uid
在with-current-buffer
内部调用,详见ox-icalendar.el
3:永远不要 运行 org-icalendar-combine-agenda-files
到 eval
使用 emacsclient
,如果您已经在访问议程文件,它会导致问题。