org-capture.el: Add support for week trees

* 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.
This commit is contained in:
Rüdiger Sonderfeld 2015-12-29 17:49:20 +00:00 committed by Nicolas Goaziou
parent 316bc89c02
commit 3e252a4dea
3 changed files with 41 additions and 5 deletions

View File

@ -7176,6 +7176,13 @@ one matched.}.
@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.

View File

@ -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~.

View File

@ -151,6 +151,12 @@ target Specification of where the captured item should be placed.
(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 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i."
(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 @@ Store them in the capture property list."
(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:"