Org-Agenda: Show Weekend Days (only)

时光怂恿深爱的人放手 提交于 2019-12-04 20:45:01

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.

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.

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