Date tree ca be filed under entry. And reveal after jump.

This commit is contained in:
Carsten Dominik 2009-11-09 15:24:11 +01:00
parent 453f8ef626
commit cba8527897
3 changed files with 35 additions and 15 deletions

View File

@ -5813,10 +5813,12 @@ 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.
as level 1 entries to the beginning or end of the file, respectively. It 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@footnote{If the file
contains an entry with a @code{DATE_TREE} property, the entire date tree will
be build under that entry.}
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.
@ -7635,20 +7637,22 @@ date at the cursor.
@item i
@vindex org-agenda-diary-file
Insert a new entry into the diary, using the date at the cursor and (for
clock entries) the date at the mark. This will add to the Emacs diary
block entries) the date at the mark. This will add to the Emacs diary
file@footnote{This file is parsed for the agenda when
@code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
command in the calendar. The diary file will pop up in another window, where
you can add the entry.
If you configure @code{org-agenda-diary-file} to point to an Org-mode file
instead, Org will create entries in that file. Most entries will be stored
in a date-based outline tree that will later make it easy to archive
appointments from previous months/years. Emacs will prompt you for the entry
text - if you specify it, the entry will be created in
@code{org-agenda-diary-file} without further interaction. If you directly
press @key{RET} at the prompt without typing text, the target file will be
shown in another window for you to finish the entry there.
If you configure @code{org-agenda-diary-file} to point to an Org-mode file,
Org will create entries (in org-mode syntax) in that file instead. Most
entries will be stored in a date-based outline tree that will later make it
easy to archive appointments from previous months/years. The tree will be
build under an entry with a @code{DATE_TREE} property, or else with years as
top-level entries. Emacs will prompt you for the entry text - if you specify
it, the entry will be created in @code{org-agenda-diary-file} without further
interaction. If you directly press @key{RET} at the prompt without typing
text, the target file will be shown in another window for you to finish the
entry there. See also the @kbd{k r} command.
@c
@kindex M
@item M

View File

@ -6675,7 +6675,8 @@ The cursor may be at a date in the calendar, or in the Org agenda."
((equal char ?j)
(org-switch-to-buffer-other-window
(find-file-noselect org-agenda-diary-file))
(org-datetree-find-date-create d1))
(org-datetree-find-date-create d1)
(org-reveal t))
(t (error "Invalid selection character `%c'" char)))))
(defun org-agenda-add-entry-to-org-agenda-diary-file (type text &optional d1 d2)

View File

@ -33,11 +33,26 @@
(require 'org)
(defvar org-datetree-base-level 1
"The level at which years should be placed in the date tree.
This is normally one, but if the buffer has an entry with a DATE_TREE
property, the date tree will become a subtree under that entry, so the
base level will be properly adjusted.")
(defun org-datetree-find-date-create (date)
"Find or create an entry for DATE."
(let ((year (nth 2 date))
(month (car date))
(day (nth 1 date)))
(org-set-local 'org-datetree-base-level 1)
(widen)
(goto-char (point-min))
(when (re-search-forward "^[ \t]*:DATE_TREE:[ \t]+\\S-" nil t)
(org-back-to-heading t)
(org-set-local 'org-datetree-base-level
(org-get-valid-level (funcall outline-level) 1))
(org-narrow-to-subtree))
(goto-char (point-min))
(org-datetree-find-year-create year)
(org-datetree-find-month-create year month)
(org-datetree-find-day-create year month day)
@ -103,7 +118,7 @@
(let ((pos (point)))
(skip-chars-backward " \t\n")
(delete-region (point) pos)
(insert "\n* \n")
(insert "\n" (make-string org-datetree-base-level ?*) " \n")
(backward-char 1)
(if month (org-do-demote))
(if day (org-do-demote))