Browse Source

Add fortnight view to agenda

* doc/org.texi (Agenda commands): Document fortnight view.
* lisp/org-agenda.el (org-agenda-custom-commands-local-options):
(org-agenda-span): Add support for fortnight view.
(org-agenda-menu): Add fortnight view command.
(org-agenda-list):
(org-agenda-ndays-to-span): Add support for fortnight view.
(org-agenda-span-to-ndays): Add support for fortnight view.
(org-agenda-later): Add support for fortnight view.
(org-agenda-fortnight-view): New command.
(org-agenda-change-time-span): Add support for fortnight view.
(org-agenda-compute-starting-span): Add support for fortnight view.

This is a patch by Michael Gauland.
Carsten Dominik 11 years ago
parent
commit
a7448b0c12
2 changed files with 27 additions and 6 deletions
  1. 1 0
      doc/org.texi
  2. 26 6
      lisp/org-agenda.el

+ 1 - 0
doc/org.texi

@@ -8642,6 +8642,7 @@ Delete other windows.
 @c
 @c
 @orgcmdkskc{v d,d,org-agenda-day-view}
 @orgcmdkskc{v d,d,org-agenda-day-view}
 @xorgcmdkskc{v w,w,org-agenda-week-view}
 @xorgcmdkskc{v w,w,org-agenda-week-view}
+@xorgcmd{v t,org-agenda-fortnight-view}
 @xorgcmd{v m,org-agenda-month-view}
 @xorgcmd{v m,org-agenda-month-view}
 @xorgcmd{v y,org-agenda-year-view}
 @xorgcmd{v y,org-agenda-year-view}
 @xorgcmd{v SPC,org-agenda-reset-view}
 @xorgcmd{v SPC,org-agenda-reset-view}

+ 26 - 6
lisp/org-agenda.el

@@ -330,6 +330,7 @@ the daily/weekly agenda, see `org-agenda-skip-function'.")
 			 (const org-agenda-span)
 			 (const org-agenda-span)
 			 (choice (const :tag "Day" 'day)
 			 (choice (const :tag "Day" 'day)
 				 (const :tag "Week" 'week)
 				 (const :tag "Week" 'week)
+				 (const :tag "Fortnight" 'fortnight)
 				 (const :tag "Month" 'month)
 				 (const :tag "Month" 'month)
 				 (const :tag "Year" 'year)
 				 (const :tag "Year" 'year)
 				 (integer :tag "Custom")))
 				 (integer :tag "Custom")))
@@ -1138,6 +1139,7 @@ Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
   :group 'org-agenda-daily/weekly
   :type '(choice (const :tag "Day" day)
   :type '(choice (const :tag "Day" day)
 		 (const :tag "Week" week)
 		 (const :tag "Week" week)
+		 (const :tag "Fortnight" fortnight)
 		 (const :tag "Month" month)
 		 (const :tag "Month" month)
 		 (const :tag "Year" year)
 		 (const :tag "Year" year)
 		 (integer :tag "Custom")))
 		 (integer :tag "Custom")))
@@ -2335,7 +2337,11 @@ The following commands are available:
      ["Week View" org-agenda-week-view
      ["Week View" org-agenda-week-view
       :active (org-agenda-check-type nil 'agenda)
       :active (org-agenda-check-type nil 'agenda)
       :style radio :selected (eq org-agenda-current-span 'week)
       :style radio :selected (eq org-agenda-current-span 'week)
-      :keys "v w  (or just w)"]
+      :keys "v w"]
+     ["Fortnight View" org-agenda-fortnight-view
+      :active (org-agenda-check-type nil 'agenda)
+      :style radio :selected (eq org-agenda-current-span 'fortnight)
+      :keys "v f"]
      ["Month View" org-agenda-month-view
      ["Month View" org-agenda-month-view
       :active (org-agenda-check-type nil 'agenda)
       :active (org-agenda-check-type nil 'agenda)
       :style radio :selected (eq org-agenda-current-span 'month)
       :style radio :selected (eq org-agenda-current-span 'month)
@@ -4172,7 +4178,7 @@ items if they have an hour specification like [h]h:mm."
 	   (sd (or start-day today))
 	   (sd (or start-day today))
 	   (ndays (org-agenda-span-to-ndays span sd))
 	   (ndays (org-agenda-span-to-ndays span sd))
 	   (org-agenda-start-on-weekday
 	   (org-agenda-start-on-weekday
-	    (if (eq ndays 7)
+	    (if (or (eq ndays 7) (eq ndays 14))
 		org-agenda-start-on-weekday))
 		org-agenda-start-on-weekday))
 	   (thefiles (org-agenda-files nil 'ifmode))
 	   (thefiles (org-agenda-files nil 'ifmode))
 	   (files thefiles)
 	   (files thefiles)
@@ -4341,6 +4347,7 @@ items if they have an hour specification like [h]h:mm."
   (cond ((symbolp n) n)
   (cond ((symbolp n) n)
 	((= n 1) 'day)
 	((= n 1) 'day)
 	((= n 7) 'week)
 	((= n 7) 'week)
+	((= n 14) 'fortnight)
 	(t n)))
 	(t n)))
 
 
 (defun org-agenda-span-to-ndays (span &optional start-day)
 (defun org-agenda-span-to-ndays (span &optional start-day)
@@ -4349,6 +4356,7 @@ START-DAY is an absolute time value."
   (cond ((numberp span) span)
   (cond ((numberp span) span)
 	((eq span 'day) 1)
 	((eq span 'day) 1)
 	((eq span 'week) 7)
 	((eq span 'week) 7)
+	((eq span 'fortnight) 14)
 	((eq span 'month)
 	((eq span 'month)
 	 (let ((date (calendar-gregorian-from-absolute start-day)))
 	 (let ((date (calendar-gregorian-from-absolute start-day)))
 	   (calendar-last-day-of-month (car date) (caddr date))))
 	   (calendar-last-day-of-month (car date) (caddr date))))
@@ -7830,6 +7838,8 @@ With prefix ARG, go forward that many times the current span."
       (setq sd (+ arg sd)))
       (setq sd (+ arg sd)))
      ((eq span 'week)
      ((eq span 'week)
       (setq sd (+ (* 7 arg) sd)))
       (setq sd (+ (* 7 arg) sd)))
+     ((eq span 'fortnight)
+      (setq sd (+ (* 14 arg) sd)))
      ((eq span 'month)
      ((eq span 'month)
       (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
       (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
 	    sd (calendar-absolute-from-gregorian greg2))
 	    sd (calendar-absolute-from-gregorian greg2))
@@ -7859,7 +7869,7 @@ With prefix ARG, go backward that many times the current span."
 (defun org-agenda-view-mode-dispatch ()
 (defun org-agenda-view-mode-dispatch ()
   "Call one of the view mode commands."
   "Call one of the view mode commands."
   (interactive)
   (interactive)
-  (message "View: [d]ay        [w]eek       [m]onth       [y]ear   [SPC]reset  [q]uit/abort
+  (message "View: [d]ay  [w]eek  for[t]night  [m]onth  [y]ear  [SPC]reset  [q]uit/abort
       time[G]rid   [[]inactive  [f]ollow      [l]og    [L]og-all   [c]lockcheck
       time[G]rid   [[]inactive  [f]ollow      [l]og    [L]og-all   [c]lockcheck
       [a]rch-trees [A]rch-files clock[R]eport include[D]iary       [E]ntryText")
       [a]rch-trees [A]rch-files clock[R]eport include[D]iary       [E]ntryText")
   (let ((a (read-char-exclusive)))
   (let ((a (read-char-exclusive)))
@@ -7867,6 +7877,7 @@ With prefix ARG, go backward that many times the current span."
       (?\  (call-interactively 'org-agenda-reset-view))
       (?\  (call-interactively 'org-agenda-reset-view))
       (?d (call-interactively 'org-agenda-day-view))
       (?d (call-interactively 'org-agenda-day-view))
       (?w (call-interactively 'org-agenda-week-view))
       (?w (call-interactively 'org-agenda-week-view))
+      (?t (call-interactively 'org-agenda-fortnight-view))
       (?m (call-interactively 'org-agenda-month-view))
       (?m (call-interactively 'org-agenda-month-view))
       (?y (call-interactively 'org-agenda-year-view))
       (?y (call-interactively 'org-agenda-year-view))
       (?l (call-interactively 'org-agenda-log-mode))
       (?l (call-interactively 'org-agenda-log-mode))
@@ -7905,6 +7916,15 @@ week 12 of year 2007.  Years in the range 1938-2037 can also be
 written as 2-digit years."
 written as 2-digit years."
   (interactive "P")
   (interactive "P")
   (org-agenda-change-time-span 'week iso-week))
   (org-agenda-change-time-span 'week iso-week))
+(defun org-agenda-fortnight-view (&optional iso-week)
+  "Switch to daily view for agenda.
+With argument ISO-WEEK, switch to the corresponding ISO week.
+If ISO-WEEK has more then 2 digits, only the last two encode the
+week.  Any digits before this encode a year.  So 200712 means
+week 12 of year 2007.  Years in the range 1938-2037 can also be
+written as 2-digit years."
+  (interactive "P")
+  (org-agenda-change-time-span 'fortnight iso-week))
 (defun org-agenda-month-view (&optional month)
 (defun org-agenda-month-view (&optional month)
   "Switch to monthly view for agenda.
   "Switch to monthly view for agenda.
 With argument MONTH, switch to that month."
 With argument MONTH, switch to that month."
@@ -7926,7 +7946,7 @@ written as 2-digit years."
 
 
 (defun org-agenda-change-time-span (span &optional n)
 (defun org-agenda-change-time-span (span &optional n)
   "Change the agenda view to SPAN.
   "Change the agenda view to SPAN.
-SPAN may be `day', `week', `month', `year'."
+SPAN may be `day', `week', `fortnight', `month', `year'."
   (org-agenda-check-type t 'agenda)
   (org-agenda-check-type t 'agenda)
   (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
   (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (curspan (nth 2 args)))
 	 (curspan (nth 2 args)))
@@ -7947,7 +7967,7 @@ SPAN may be `day', `week', `month', `year'."
 
 
 (defun org-agenda-compute-starting-span (sd span &optional n)
 (defun org-agenda-compute-starting-span (sd span &optional n)
   "Compute starting date for agenda.
   "Compute starting date for agenda.
-SPAN may be `day', `week', `month', `year'.  The return value
+SPAN may be `day', `week', `fortnight', `month', `year'.  The return value
 is a cons cell with the starting date and the number of days,
 is a cons cell with the starting date and the number of days,
 so that the date SD will be in that range."
 so that the date SD will be in that range."
   (let* ((greg (calendar-gregorian-from-absolute sd))
   (let* ((greg (calendar-gregorian-from-absolute sd))
@@ -7960,7 +7980,7 @@ so that the date SD will be in that range."
 	(setq sd (+ (calendar-absolute-from-gregorian
 	(setq sd (+ (calendar-absolute-from-gregorian
 		     (list mg 1 yg))
 		     (list mg 1 yg))
 		    n -1))))
 		    n -1))))
-     ((eq span 'week)
+     ((or (eq span 'week) (eq span 'fortnight))
       (let* ((nt (calendar-day-of-week
       (let* ((nt (calendar-day-of-week
 		  (calendar-gregorian-from-absolute sd)))
 		  (calendar-gregorian-from-absolute sd)))
 	     (d (if org-agenda-start-on-weekday
 	     (d (if org-agenda-start-on-weekday