浏览代码

Allow remember to file to a date-based outline tree

Carsten Dominik 15 年之前
父节点
当前提交
5c83f73df0
共有 3 个文件被更改,包括 28 次插入7 次删除
  1. 10 6
      doc/org.texi
  2. 7 0
      lisp/ChangeLog
  3. 11 1
      lisp/org-remember.el

+ 10 - 6
doc/org.texi

@@ -5807,12 +5807,16 @@ use:
 character specifies how to select the template.  It is useful if the
 character specifies how to select the template.  It is useful if the
 character is also the first letter of the name.  The next string specifies
 character is also the first letter of the name.  The next string specifies
 the template.  Two more (optional) strings give the file in which, and the
 the template.  Two more (optional) strings give the file in which, and the
-headline under which, the new note should be stored.  The file (if not present
-or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
-@code{org-remember-default-headline}.  If the file name is not an absolute
-path, it will be interpreted relative to @code{org-directory}.  The heading
-can also be the symbols @code{top} or @code{bottom} to send notes as level 1
-entries to the beginning or end of the file, respectively.
+headline under which, the new note should be stored.  The file (if not
+present or @code{nil}) defaults to @code{org-default-notes-file}, the heading
+to @code{org-remember-default-headline}.  If the file name is not an absolute
+path, it will be interpreted relative to @code{org-directory}.
+
+The heading can also be the symbols @code{top} or @code{bottom} to send notes
+as level 1 entries to the beginning or end of the file, respectively.  I may
+also be the symbol @code{date-tree}.  Then, a tree with year on level 1, month
+on level 2 and day on level three will be build in the file, and the entry
+will be filed into the tree under the current date.
 
 
 An optional sixth element specifies the contexts in which the user can select
 An optional sixth element specifies the contexts in which the user can select
 the template.  This element can be a list of major modes or a function.
 the template.  This element can be a list of major modes or a function.

+ 7 - 0
lisp/ChangeLog

@@ -1,5 +1,12 @@
 2009-11-08  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-11-08  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
+	* org-remember.el (org-datetree): Require.
+	(org-remember-templates): Add new positioning option.
+	(org-remember-reference-date): New variable.
+	(org-remember-apply-template): Store the reference date in a local
+	variable.
+	(org-remember-handler): Implement date tree positioning of entries.
+
 	* org-datetree.el: New file.
 	* org-datetree.el: New file.
 
 
 	* org-latex.el (org-export-latex-preprocess): Protect targets in
 	* org-latex.el (org-export-latex-preprocess): Protect targets in

+ 11 - 1
lisp/org-remember.el

@@ -34,6 +34,7 @@
 (eval-when-compile
 (eval-when-compile
   (require 'cl))
   (require 'cl))
 (require 'org)
 (require 'org)
+(require 'org-datetree)
 
 
 (declare-function remember-mode "remember" ())
 (declare-function remember-mode "remember" ())
 (declare-function remember "remember" (&optional initial))
 (declare-function remember "remember" (&optional initial))
@@ -189,7 +190,8 @@ calendar           |  %:type %:date"
 		 (function :tag "Function")
 		 (function :tag "Function")
 		 (const :tag "Use `org-remember-default-headline'" nil)
 		 (const :tag "Use `org-remember-default-headline'" nil)
 		 (const :tag "At beginning of file" top)
 		 (const :tag "At beginning of file" top)
-		 (const :tag "At end of file" bottom))
+		 (const :tag "At end of file" bottom)
+		 (const :tag "In a date tree" date-tree))
 		(choice :tag "Context"
 		(choice :tag "Context"
 		 (const :tag "Use in all contexts" nil)
 		 (const :tag "Use in all contexts" nil)
 		 (const :tag "Use in all contexts" t)
 		 (const :tag "Use in all contexts" t)
@@ -296,6 +298,7 @@ RET at beg-of-buf -> Append to file as level 2 headline
 
 
 (defvar org-jump-to-target-location nil)
 (defvar org-jump-to-target-location nil)
 (defvar org-remember-previous-location nil)
 (defvar org-remember-previous-location nil)
+(defvar org-remember-reference-date nil)
 (defvar org-force-remember-template-char) ;; dynamically scoped
 (defvar org-force-remember-template-char) ;; dynamically scoped
 
 
 ;; Save the major mode of the buffer we called remember from
 ;; Save the major mode of the buffer we called remember from
@@ -534,6 +537,8 @@ to be run from that hook to function properly."
 	    (org-set-local 'org-default-notes-file file))
 	    (org-set-local 'org-default-notes-file file))
 	(if headline
 	(if headline
 	    (org-set-local 'org-remember-default-headline headline))
 	    (org-set-local 'org-remember-default-headline headline))
+	(org-set-local 'org-remember-reference-date
+		       (list (nth 4 dct) (nth 3 dct) (nth 5 dct)))
 	;; Interactive template entries
 	;; Interactive template entries
 	(goto-char (point-min))
 	(goto-char (point-min))
 	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
 	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
@@ -851,6 +856,7 @@ See also the variable `org-reverse-note-order'."
 		     (delete-file (concat backup-file "~"))))
 		     (delete-file (concat backup-file "~"))))
 	      (set-buffer-modified-p nil)
 	      (set-buffer-modified-p nil)
 	      (throw 'quit t)))
 	      (throw 'quit t)))
+	   (reference-date org-remember-reference-date)
 	   (previousp (and (member current-prefix-arg '((16) 0))
 	   (previousp (and (member current-prefix-arg '((16) 0))
 			   org-remember-previous-location))
 			   org-remember-previous-location))
 	   (clockp (equal current-prefix-arg 2))
 	   (clockp (equal current-prefix-arg 2))
@@ -950,6 +956,10 @@ See also the variable `org-reverse-note-order'."
 		(goto-char (point-max))
 		(goto-char (point-max))
 		(or (bolp) (newline))
 		(or (bolp) (newline))
 		(setq org-goto-start-pos (point)))
 		(setq org-goto-start-pos (point)))
+	       ((eq heading 'date-tree)
+		(org-datetree-find-date-create reference-date)
+		(setq reversed nil)
+		(setq org-goto-start-pos (point)))
 	       ((and (stringp heading) (string-match "\\S-" heading))
 	       ((and (stringp heading) (string-match "\\S-" heading))
 		(goto-char (point-min))
 		(goto-char (point-min))
 		(if (re-search-forward
 		(if (re-search-forward