6

I write my weekly report on Wednesdays. As such I need to see what I've done starting last Wednesday until now. (usually a Wednesday).

I would like to create an Agenda view for this, so I can quickly flick between the weeks, but I cannot find a way of specifying '-7' days.

I tried customizing org-agenad-custom-commands and setting the days to '-7' but that only shows the current day.

At present I generate a report for this:

#+BEGIN: clocktable :tstart "<-6d>" :tend "<now>" :scope agenda-with-archives :narrow 70 :formatter my-org-clocktable-notodo :maxlevel 3 :fileskip0

But I can't find a way to transpose this to an Agenda custom view. Is this possible?

[Edit solution]
As per lawlist's advise in the comment I got it to work.

1) I customized org-agenad-custom-commands, added an agenda view that shows "Number of days in agenda" = 8. I assigned "W" to this agenda view.

 '(org-agenda-custom-commands
   ....
     ("W" "Last 8 days." agenda ""
      ((org-agenda-span 8)
  ...

2) I then defined a function that temporarily defines the variable:

(defun my/agenda-last-week () 
  (interactive)
  (let ((org-agenda-start-day "-7d"))
       (org-agenda nil "W"))
)

I then assign a hotkey to that function.

Now I can view my last week Wednesday to Wednesday, (inc time-report). I am happy.

  • 1
    The second argument to org-agenda-list is start-day, and the third argument is span. M-x describe-function RET org-agenda-list RET. See: gnu.org/software/emacs/manual/html_node/org/… E.g., You can also set the start date using a date shift: (setq org-agenda-start-day "+10d") will start the agenda ten days from today in the future. Presumably you can go the opposite direction with a negative argument. In a custom command situation, the setq is omitted because it takes on a let-bound value. – lawlist Jun 10 '15 at 16:11
  • 1
    See also, M-x describe-variable RET org-agenda-start-day RET Here is a link to a thread that deals with what appears to be the same issue, entitled A weekly review in org-mode: stackoverflow.com/questions/17422781/… – lawlist Jun 10 '15 at 16:13
  • @lawlist Negative values for org-agenda-start-day do work exactly the way you suspect. I think your comment is really an answer. – erikstokes Jun 11 '15 at 0:09
  • @lawlist, that actually solves it :-). If you post an answer, I'll happily accept. – Leo Ufimtsev Jun 15 '15 at 18:38
5

The variable org-agenda-start-day can be used to achieve the behavior desired by the original poster. The doc-string provides as follows:

Start day for the agenda view.
Custom commands can set this variable in the options section.
This is usually a string like "2007-11-01", "+2d" or any other
input allowed when reading a date through the Org calendar.
See the docstring of `org-read-date' for details.

The manual -- https://www.gnu.org/software/emacs/manual/html_node/org/Weekly_002fdaily-agenda.html -- contains the following example: You can also set the start date using a date shift: (setq org-agenda-start-day "+10d") will start the agenda ten days from today in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.