From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?R=FCdiger?= Sonderfeld Subject: [PATCH v3 3/3] org-capture.el: Add support for week trees. Date: Tue, 29 Dec 2015 17:49:20 +0000 Message-ID: <3576029.rPdA1VFfFu@descartes> References: <87h9n4hpql.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDyOl-0006cU-Gj for emacs-orgmode@gnu.org; Tue, 29 Dec 2015 12:49:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDyOi-0006l5-9b for emacs-orgmode@gnu.org; Tue, 29 Dec 2015 12:49:27 -0500 Received: from ptmx.org ([178.63.28.110]:47546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDyOh-0006kx-W4 for emacs-orgmode@gnu.org; Tue, 29 Dec 2015 12:49:24 -0500 In-Reply-To: <87h9n4hpql.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: mail@nicolasgoaziou.fr * lisp/org-capture.el (org-capture-templates): Add file+weektree(+prompt) options. (org-capture-set-target-location): Add support for week trees. * doc/org.texi (Template elements): Document file+weektree(+prompt) options. --- doc/org.texi | 7 +++++++ etc/ORG-NEWS | 13 +++++++++++++ lisp/org-capture.el | 26 +++++++++++++++++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 8f3e248..dfa989a 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -7176,6 +7176,13 @@ @item (file+datetree+prompt "path/to/file") Will create a heading in a date tree, but will prompt for the date. +@item (file+weektree "path/to/file") +Will create a heading in a week tree for today's date. Week trees are sorted +by week and not by month unlike datetrees. + +@item (file+weektree+prompt "path/to/file") +Will create a heading in a week tree, but will prompt for the date. + @item (file+function "path/to/file" function-finding-location) A function to find the right location in the file. diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 4ab48c4..b56add3 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -167,6 +167,19 @@ for details. *** org-bbdb-anniversaries-future Used like org-bbdb-anniversaries, it provides a few days warning for upcoming anniversaries (default: 7 days). +*** Support for ISO week trees +ISO week trees are an alternative date tree format that orders entries +by ISO week and not by month. + +For example: + +: * 2015 +: ** 2015-W35 +: ** 2015-W36 +: *** 2015-08-31 Monday + +They are supported in org-capture via ~file+weektree~ and +~file+weektree+prompt~ target specifications. ** New functions *** ~org-show-children~ It is a faster implementation of ~outline-show-children~. diff --git a/lisp/org-capture.el b/lisp/org-capture.el index f92ea35..13cbe9b 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -151,6 +151,12 @@ (defcustom org-capture-templates nil (file+datetree+prompt \"path/to/file\") Will create a heading in a date tree, prompts for date + (file+weektree \"path/to/file\") + Will create a heading in a week tree for today's date + + (file+weektree+prompt \"path/to/file\") + Will create a heading in a week tree, prompts for date + (file+function \"path/to/file\" function-finding-location) A function to find the right location in the file @@ -331,6 +337,12 @@ (defcustom org-capture-templates nil (list :tag "File & Date tree, prompt for date" (const :format "" file+datetree+prompt) (file :tag " File")) + (list :tag "File & Week tree" + (const :format "" file+weektree) + (file :tag " File")) + (list :tag "File & Week tree, prompt for date" + (const :format "" file+weektree+prompt) + (file :tag " File")) (list :tag "File & function" (const :format "" file+function) (file :tag " File ") @@ -908,21 +920,25 @@ (defun org-capture-set-target-location (&optional target) (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) (error "No match for target regexp in file %s" (nth 1 target)))) - ((memq (car target) '(file+datetree file+datetree+prompt)) + ((memq (car target) '(file+datetree file+datetree+prompt file+weektree file+weektree+prompt)) (require 'org-datetree) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) - ;; Make a date tree entry, with the current date (or yesterday, - ;; if we are extending dates for a couple of hours) - (org-datetree-find-date-create + ;; Make a date/week tree entry, with the current date (or + ;; yesterday, if we are extending dates for a couple of hours) + (funcall + (cond + ((memq (car target) '(file+weektree file+weektree+prompt)) + #'org-datetree-find-iso-week-create) + (t #'org-datetree-find-date-create)) (calendar-gregorian-from-absolute (cond (org-overriding-default-time ;; use the overriding default time (time-to-days org-overriding-default-time)) - ((eq (car target) 'file+datetree+prompt) + ((memq (car target) '(file+datetree+prompt file+weektree+prompt)) ;; prompt for date (let ((prompt-time (org-read-date nil t nil "Date for tree entry:" -- 2.6.4