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?
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.
来源:https://stackoverflow.com/questions/29696756/org-agenda-show-weekend-days-only