emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rüdiger Sonderfeld" <ruediger@c-plusplus.net>
To: emacs-orgmode@gnu.org
Cc: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: [PATCH v2 3/3] org-capture.el: Add support for week trees.
Date: Mon, 07 Sep 2015 23:24:47 +0100	[thread overview]
Message-ID: <1641158.JnX1LqEbs2@descartes> (raw)
In-Reply-To: <87fv2w82tf.fsf@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 +++++++
 lisp/org-capture.el | 26 +++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index ed808be..d894f91 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7187,6 +7187,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/lisp/org-capture.el b/lisp/org-capture.el
index 93a7f2a..320954e 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -149,6 +149,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
 
@@ -321,6 +327,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    ")
@@ -895,21 +907,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.5.1

  parent reply	other threads:[~2015-09-07 22:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1441180730.git.ruediger@c-plusplus.net>
2015-09-02  8:06 ` [PATCH 1/3] org-datetree.el: Code cleanup Rüdiger Sonderfeld
2015-09-02 19:48   ` Nicolas Goaziou
2015-09-02  8:06 ` [PATCH 2/3] org-datetree.el: Add support for ISO week trees Rüdiger Sonderfeld
2015-09-02 19:58   ` Nicolas Goaziou
2015-09-03  0:14     ` Rüdiger Sonderfeld
2015-09-03  5:55       ` Nicolas Goaziou
2015-09-07 22:24         ` [PATCH v2 1/3] org-datetree.el: Code cleanup Rüdiger Sonderfeld
2015-09-07 22:24         ` [PATCH v2 2/3] org-datetree.el: Add support for ISO week trees Rüdiger Sonderfeld
2015-09-07 22:24         ` Rüdiger Sonderfeld [this message]
2015-09-07 22:27         ` [PATCH " Rüdiger Sonderfeld
2015-09-08 15:53           ` Nicolas Goaziou
2015-12-29 17:48             ` [PATCH v3 1/3] org-datetree.el: Code cleanup Rüdiger Sonderfeld
2015-12-29 20:58               ` Nicolas Goaziou
2015-12-29 17:49             ` [PATCH v3 2/3] org-datetree.el: Add support for ISO week trees Rüdiger Sonderfeld
2015-12-29 20:59               ` Nicolas Goaziou
2015-12-29 17:49             ` [PATCH v3 3/3] org-capture.el: Add support for " Rüdiger Sonderfeld
2015-12-29 20:59               ` Nicolas Goaziou
2015-09-02  8:06 ` [PATCH " Rüdiger Sonderfeld
2015-09-02 19:59   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1641158.JnX1LqEbs2@descartes \
    --to=ruediger@c-plusplus.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).