保存组织议程

发布于 2024-08-01 12:49:08 字数 133 浏览 3 评论 0原文

每次计算组织议程时,我想将组织议程的输出保存到文本文件中。 这样,我可以使用外部程序(例如 Windows 上的 ATNotes 或 Linux 上的 conky)来获取此文本文件并将其显示在我的桌面上。

我怎样才能做到这一点?

I'd like to save the output of org-agenda to a text file, every time that the org-agenda is calculated. This way, I can use an external program (like ATNotes on windows or conky on linux), to pick up this text file and display it on my desktop.

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你げ笑在眉眼 2024-08-08 12:49:08

所以我最终决定打开 emacs lisp 手册并自己解决这个问题。 我写了这段代码,看起来运行得很好! :)

;; Save the org-agenda for display with conky
(defadvice org-todo-list (after saveorgagenda activate)
  "save this output to my todo file"
  (get-buffer-create "todo")
  (with-current-buffer "todo"
    (set-buffer-modified-p nil))
  (kill-buffer "todo")
  (write-file "~/todo"))

编辑原因:

1)如果没有kill-buffer,defadvice会在每次执行org-todo-list时创建一个新的todo缓冲区。 这让人非常恼火。

2) 如果没有 get-buffer-create 函数,kill-buffers 第一次会失败,因为当时没有名为 todo 的缓冲区。

3)如果没有set-buffer-modified-p,该函数将不断告诉您“todo缓冲区已修改。真的杀死它吗?(y或n)”这确实会破坏整个目的。

哇! 我很高兴我真的花了时间和精力来解决这个问题! :D

So I finally decided to open the emacs lisp manual and figure this out myself. I wrote this bit of code, which seems to be working just fine! :)

;; Save the org-agenda for display with conky
(defadvice org-todo-list (after saveorgagenda activate)
  "save this output to my todo file"
  (get-buffer-create "todo")
  (with-current-buffer "todo"
    (set-buffer-modified-p nil))
  (kill-buffer "todo")
  (write-file "~/todo"))

EDIT REASONS:

1) Without kill-buffer, the defadvice creates a new todo buffer on every execution of org-todo-list. This gets pretty irritating.

2) Without the get-buffer-create function, kill-buffers fails the first time since there is no buffer named todo at that time.

3) Without set-buffer-modified-p, the function will keep telling you "todo buffer is modified. Really kill it? (y or n)" which would defeat the whole purpose really.

Whew! I'm so happy I actually took the time and effort to figure this out! :D

离鸿 2024-08-08 12:49:08

如果您想在 emacs 打开时执行此操作,只需通过 Mx save-buffer*Agenda* 缓冲区上调用 save-buffer > (因为 orgmode 将 Cx Cs 绑定到 org-save-all-org-buffer。 您可以将 save-buffer 绑定到org-mode-map 如果你

想通过 cron 来完成,你应该能够使用 组织模式邮件列表上的这个线程将输出通过管道传输到文件。我过去使用过这个:

    emacs -batch -eval '(org-batch-agenda "a" org-agenda-ndays 7 org-agenda-include-diary nil org-agenda-files (quote ("~/org/todo.org")))' > agenda.txt

If you want to do it while you have emacs open, you can just call save-buffer on the *Agenda* buffer via M-x save-buffer (since orgmode binds C-x C-s to org-save-all-org-buffer. You could bind save-buffer to something else in the org-mode-map if you wanted.

If you want to do it via a cron, you should be able to use the snippet in this thread on the org-mode mailing list to pipe the output to a file. I've used this in the past:

    emacs -batch -eval '(org-batch-agenda "a" org-agenda-ndays 7 org-agenda-include-diary nil org-agenda-files (quote ("~/org/todo.org")))' > agenda.txt
冰之心 2024-08-08 12:49:08

在你费尽心思编写这段代码(并且还使用了一些周围的建议!)之后,我觉得我对你的游行感到很高兴,但实际上这个功能已经融入了组织模式,并记录在手动的。 您需要的命令是 org-write-agenda(议程缓冲区中的 Cx Cw)。 请参阅组织模式信息中标题为“导出议程视图”的部分。

I feel like I'm raining on your parade after you went to the trouble to write this code snipped (and used a piece of around advice, too!), but actually this feature is already baked into org-mode, and documented in the manual. The command you want is org-write-agenda (C-x C-w in an agenda buffer). See the section of the org-mode info entitled "Exporting Agenda Views."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文