summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-11-19 15:34:43 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2009-11-19 15:34:43 +0100
commit1bb0df05119affe89e042befba7b5233258b116c (patch)
tree554d9423f9719ba5c1e460c465d9f3d4193b1302
parenta8397d62c531e1893bb5e7c42c3b3b598cacf471 (diff)
downloadorg-mode-1bb0df05119affe89e042befba7b5233258b116c.tar.gz
Allow diary entry insertion at top-level
Matt Lundin writes: > The new org-agenda-diary-entry looks quite convenient. > > Would it be possible to add an option to bypass the date tree so as to > add each new appointment as a simple first level heading? I prefer to > keep my appointments organized by project and/or category and have no > real use for the date tree. Ideally, new appointments would appear as > first level headlines in the org-agenda-diary-file (i.e., my inbox), > ready to be refiled.
-rwxr-xr-xlisp/ChangeLog5
-rw-r--r--lisp/org-agenda.el37
2 files changed, 36 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fdf702d..8d4249d 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2009-11-19 Carsten Dominik <carsten.dominik@gmail.com>
+ * org-agenda.el (org-agenda-insert-diary-strategy): New variable.
+ (org-agenda-insert-diary-as-top-level): New function.
+ (org-agenda-add-entry-to-org-agenda-diary-file): Call
+ `org-agenda-insert-diary-as-top-level'.
+
* org.el (org-occur-in-agenda-files): Make sure none of the
buffers is narrowed.
(org-activate-plain-links): Add the face property here.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1e3b3f5..8e65a4b 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6694,6 +6694,17 @@ The cursor may be at a date in the calendar, or in the Org agenda."
(org-reveal t))
(t (error "Invalid selection character `%c'" char)))))
+(defcustom org-agenda-insert-diary-strategy 'date-tree
+ "Where in `org-agenda-diary-file' should new entries be added?
+Valid values:
+
+date-tree in the date tree, as child of the date
+top-level as top-level entries at the end of the file."
+ :group 'org-agenda
+ :type '(choice
+ (const :tag "in a date tree" date-tree)
+ (const :tag "as top level at end of file" top-level)))
+
(defun org-agenda-add-entry-to-org-agenda-diary-file (type text &optional d1 d2)
"Add a diary entry with TYPE to `org-agenda-diary-file'.
If TEXT is not empty, it will become the headline of the new entry, and
@@ -6728,9 +6739,11 @@ the resulting entry will not be shown. When TEXT is empty, switch to
(insert (format "%%%%(diary-anniversary %s) %s"
(calendar-date-string d1 nil t) text))))
((eq type 'day)
- (require 'org-datetree)
- (org-datetree-find-date-create d1)
- (org-agenda-insert-diary-make-new-entry text)
+ (if (eq org-agenda-insert-diary-strategy 'top-level)
+ (org-agenda-insert-diary-as-top-level text)
+ (require 'org-datetree)
+ (org-datetree-find-date-create d1)
+ (org-agenda-insert-diary-make-new-entry text))
(org-insert-time-stamp (org-time-from-absolute
(calendar-absolute-from-gregorian d1)))
(end-of-line 0))
@@ -6738,9 +6751,11 @@ the resulting entry will not be shown. When TEXT is empty, switch to
(if (> (calendar-absolute-from-gregorian d1)
(calendar-absolute-from-gregorian d2))
(setq d1 (prog1 d2 (setq d2 d1))))
- (require 'org-datetree)
- (org-datetree-find-date-create d1)
- (org-agenda-insert-diary-make-new-entry text)
+ (if (eq org-agenda-insert-diary-strategy 'top-level)
+ (org-agenda-insert-diary-as-top-level text)
+ (require 'org-datetree)
+ (org-datetree-find-date-create d1)
+ (org-agenda-insert-diary-make-new-entry text))
(org-insert-time-stamp (org-time-from-absolute
(calendar-absolute-from-gregorian d1)))
(insert "--")
@@ -6756,6 +6771,16 @@ the resulting entry will not be shown. When TEXT is empty, switch to
(org-reveal t)
(message "Please finish entry here"))))
+(defun org-agenda-insert-diary-as-top-level (text)
+ "Make new entry as a top-level entry at the end of the file.
+Add TEXT as headline, and position the cursor in the second line so that
+a timestamp can be added there."
+ (widen)
+ (goto-char (point-max))
+ (or (bolp) (insert "\n"))
+ (insert "* " text "\n")
+ (if org-adapt-indentation (org-indent-to-column 2)))
+
(defun org-agenda-insert-diary-make-new-entry (text)
"Make new entry as last child of current entry.
Add TEXT as headline, and position the cursor in the second line so that