diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2009-11-20 13:56:23 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2009-11-20 13:56:23 +0100 |
commit | 858dfb51f65133d04a6226b6498f9746ace07ebb (patch) | |
tree | 626042e6980579a81daa64105263bc83faac4c5f | |
parent | 24a49967f19dd186197a991b25355a6ce46a2234 (diff) | |
download | org-mode-858dfb51f65133d04a6226b6498f9746ace07ebb.tar.gz |
Agenda: Still safer diary insertion
Bernt Hansen reported a bug when the cursor is on the first line in
the agenda.
-rwxr-xr-x | lisp/ChangeLog | 2 | ||||
-rw-r--r-- | lisp/org-agenda.el | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e5d7420..a4053dd 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,8 @@ * org-agenda.el (org-agenda-diary-entry-in-org-file): Make sure hat checking for the mark does not throw an error. + (org-agenda-diary-entry-in-org-file): Catch the case that there is + not `day' text property in the cursor line. * org.el (org-sort-entries-or-items): Make sure that the final entry has a newline before doing the sorting. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 3bc164d..81e03fe 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6661,17 +6661,18 @@ The cursor may be at a date in the calendar, or in the Org agenda." (defun org-agenda-diary-entry-in-org-file () "Make a diary entry in the file `org-agenda-diary-file'." - (let (d1 d2 char (text "") dp) + (let (d1 d2 char (text "") dp1 dp2) (if (equal (buffer-name) "*Calendar*") (setq d1 (calendar-cursor-to-date t) d2 (car calendar-mark-ring)) - (setq d1 (calendar-gregorian-from-absolute - (get-text-property (point-at-bol) 'day)) + (setq dp1 (get-text-property (point-at-bol) 'day)) + (unless dp1 (error "No date defined in current line")) + (setq d1 (calendar-gregorian-from-absolute dp1) d2 (and (ignore-errors (mark)) (save-excursion (goto-char (mark)) - (setq dp (get-text-property (point-at-bol) 'day))) - (calendar-gregorian-from-absolute dp)))) + (setq dp2 (get-text-property (point-at-bol) 'day))) + (calendar-gregorian-from-absolute dp2)))) (message "Diary entry: [d]ay [a]nniversary [b]lock [j]ump to date tree") (setq char (read-char-exclusive)) (cond |