Org-Agenda: Show Weekend Days (only)

匿名 (未验证) 提交于 2019-12-03 08:30:34

问题:

I would like to have a custom agenda view in my org agenda, that shows only weekend days.

For example, when I open [m]onth view (M-x org-agenda a v m), I see the current month. I would like to hide the work days and show weekend days only. How can I do that?

回答1:

Here is an interactive function that shows the agenda for the current or upcoming weekend:

(defun org-next-weekend-agenda ()   "Produce an agenda view for the current or upcoming weekend from all files in variable `org-agenda-files'."   (interactive)   (let*       ((day (string-to-number (format-time-string "%w")))        (offset     (cond ((zerop day) -1)      ; it's Sunday           (t (- 6 day))))       ; any other day        (offset-string     (cond ((>= offset 0) (concat "+" (number-to-string offset)))           (t (number-to-string offset)))))     (org-agenda-list nil offset-string 2))) 

There may be a way to do this as a custom agenda... but I didn't see it.



回答2:

Possibly the best route it to extend the main org-agenda dispatch rather than the view dispatch which is less powerful. This will allow you to add more commands to the main org-agenda menu. This dispatch is quite customizable through the org-agenda-custom-commands variable, which you can customize or set. This will allow you to add custom commands. For example for a view of next weekend:

(add-to-list 'org-agenda-custom-commands            '("W" "Weekend"              ((agenda "" ))              (               (org-agenda-overriding-header "WEEKEND")               (org-agenda-span 2)               (org-agenda-start-day "saturday")                   )) t) 

So then

M-x org-agenda S-w

gives you next weekend. It is quite typical to bind org-agenda to C-ca. So this becomes C-caW.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!