[英]emacs > org mode > agenda - always use current buffer
I am using many different org mode files for various projects, and I rev them by adding the date to the filename eg filename-2020-09-17.org.我为各种项目使用了许多不同的组织模式文件,我通过在文件名中添加日期来修改它们,例如 filename-2020-09-17.org。 I realize I could use version control but in this case that is not possible, due to needing to share the file with others who are not using VC.
我意识到我可以使用版本控制,但在这种情况下这是不可能的,因为需要与不使用 VC 的其他人共享文件。
I would like the Agenda to always show just the items for the current file/buffer.我希望议程始终只显示当前文件/缓冲区的项目。
When I save eg the file with filename-2020-09-16.org to filename-2020-09-17.org, then the agenda still shows the old file name unless I remove it from the agenda file list and add the new file.例如,当我将带有 filename-2020-09-16.org 的文件保存到 filename-2020-09-17.org 时,议程仍会显示旧文件名,除非我将其从议程文件列表中删除并添加新文件.
I realize that I can use Cc a < a but I am lazy and would rather not have to type S-, each time to get the <.我意识到我可以使用 Cc a < a 但我很懒惰,宁愿不必每次都输入 S- 来获取 <。
I looked at Agenda view of the current buffer我查看了当前缓冲区的议程视图
And the OP says the solution was simple but he/she/they did not provide the solution - at least I don't see it and I tried the posted code but it no works. OP 说解决方案很简单,但他/她/他们没有提供解决方案 - 至少我没有看到它,我尝试了发布的代码,但没有用。
I also found https://www.reddit.com/r/orgmode/comments/bxwovd/agenda_for_current_buffer/ but that did not seem to meet my need.我还找到了https://www.reddit.com/r/orgmode/comments/bxwovd/agenda_for_current_buffer/但这似乎不能满足我的需要。
Specifically I would like to put something in .emacs so that this would apply to all files all the time.具体来说,我想在 .emacs 中放一些东西,以便这将始终适用于所有文件。
I also looked into a keystroke macro programs but this does not seem ideal.我还研究了击键宏程序,但这似乎并不理想。
Any help is appreciated.任何帮助表示赞赏。
Thanks ahead of time.提前致谢。
Here's a simple function to do what you want, but there is no error checking to make sure eg that you are invoking it from a buffer that is visiting an Org mode file.这是一个简单的函数来做你想做的事,但没有错误检查来确保例如你是从访问 Org 模式文件的缓冲区调用它。 The idea is that you set the
org-agenda-files
list to contain just the file which the buffer is visiting and then you call the regular org-agenda
function.这个想法是您将
org-agenda-files
列表设置为仅包含缓冲区正在访问的文件,然后您调用常规的org-agenda
函数。 Binding the modified function to the Cc a
key may or may not be what you want to do, but you can try and decide for yourself:将修改后的函数绑定到
Cc a
键可能是也可能不是您想要做的,但您可以尝试自己决定:
(defun org-agenda-current-buffer ()
(interactive)
(let ((org-agenda-files (list (buffer-file-name (current-buffer)))))
(org-agenda)))
(define-key global-map (kbd "C-c a") #'org-agenda-current-buffer)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.