forked from mirrors/org-mode
Allow inserting diary entries last in date tree
* org-agenda.el (org-agenda-insert-diary-strategy): Add new value 'date-tree-last. (org-agenda-insert-diary-make-new-entry): Handle `org-agenda-insert-diary-strategy' set to 'date-tree-last. To allow for diary entries to be entered in time order in the date tree, add a new value to `org-agenda-insert-diary-strategy' that allows for this. The code for handling this value, 'date-tree-last, is a bit tricky, as we need to keep track of whether the date-tree already had one or more entries for the given date.
This commit is contained in:
parent
5bfdfc5df7
commit
1fd103293c
|
@ -9417,11 +9417,13 @@ buffer, display it in another window."
|
||||||
"Where in `org-agenda-diary-file' should new entries be added?
|
"Where in `org-agenda-diary-file' should new entries be added?
|
||||||
Valid values:
|
Valid values:
|
||||||
|
|
||||||
date-tree in the date tree, as child of the date
|
date-tree in the date tree, as first child of the date
|
||||||
|
date-tree-last in the date tree, as last child of the date
|
||||||
top-level as top-level entries at the end of the file."
|
top-level as top-level entries at the end of the file."
|
||||||
:group 'org-agenda
|
:group 'org-agenda
|
||||||
:type '(choice
|
:type '(choice
|
||||||
(const :tag "in a date tree" date-tree)
|
(const :tag "first in a date tree" date-tree)
|
||||||
|
(const :tag "last in a date tree" date-tree-last)
|
||||||
(const :tag "as top level at end of file" top-level)))
|
(const :tag "as top level at end of file" top-level)))
|
||||||
|
|
||||||
(defcustom org-agenda-insert-diary-extract-time nil
|
(defcustom org-agenda-insert-diary-extract-time nil
|
||||||
|
@ -9525,14 +9527,20 @@ a timestamp can be added there."
|
||||||
(when org-adapt-indentation (org-indent-to-column 2)))
|
(when org-adapt-indentation (org-indent-to-column 2)))
|
||||||
|
|
||||||
(defun org-agenda-insert-diary-make-new-entry (text)
|
(defun org-agenda-insert-diary-make-new-entry (text)
|
||||||
"Make a new entry with TEXT as the first child of the current subtree.
|
"Make a new entry with TEXT as a child of the current subtree.
|
||||||
Position the point in the heading's first body line so that
|
Position the point in the heading's first body line so that
|
||||||
a timestamp can be added there."
|
a timestamp can be added there."
|
||||||
|
(cond
|
||||||
|
((eq org-agenda-insert-diary-strategy 'date-tree-last)
|
||||||
|
(end-of-line)
|
||||||
|
(org-insert-heading '(4) t)
|
||||||
|
(org-do-demote))
|
||||||
|
(t
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
(org-back-over-empty-lines)
|
(org-back-over-empty-lines)
|
||||||
(unless (looking-at "[ \t]*$") (save-excursion (insert "\n")))
|
(unless (looking-at "[ \t]*$") (save-excursion (insert "\n")))
|
||||||
(org-insert-heading nil t)
|
(org-insert-heading nil t)
|
||||||
(org-do-demote)
|
(org-do-demote)))
|
||||||
(let ((col (current-column)))
|
(let ((col (current-column)))
|
||||||
(insert text)
|
(insert text)
|
||||||
(org-end-of-meta-data)
|
(org-end-of-meta-data)
|
||||||
|
|
Loading…
Reference in a new issue