1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-28 10:56:57 +00:00

Implement actions tied to cursor date in agenda.

This commit is contained in:
Carsten Dominik 2008-06-16 16:26:30 +02:00
parent e8202bf861
commit be026ff5ad
7 changed files with 259 additions and 73 deletions

View File

@ -21,8 +21,8 @@ thanks for all the great ideas.
** Overview
- Use cursor position in agenda for remember, scheduling and deadlines
- New API for mapping a function over all or selected entries
- Remember templates can now use the cursor date in the agenda
- Remember templates can be filed to beginning/end of a file
- Visiting a filed remember buffer immediately
- BBDB anniversaries are now links
@ -31,7 +31,48 @@ thanks for all the great ideas.
- Direct, single key access to allowed values in column view
- New hook to hack exported iCalendar files
** Incompatible changes
*** `C-c C-x C-k' now calls `org-mark-entry-for-agenda-action'
It used to call =org-cut-special=, but that is also at bound
to the key =C-c C-x C-w=.
** Details
*** Making use of the cursor position in the agenda
The date at the cursor in the agenda (and also in the
calendar) can now be used to schedule entries, or to set the
date in a remember template correctly. It is also designed
to make it easier to move an entry to a date picked in the
agenda. Thanks to Thomas Baumann for starting the thread
that led to this development.
**** Calling remember with the cursor date in the agenda
If you want to use the date at the agenda cursor in a
remember template, start remember from the agenda with the
keys =k r=. While the template is being filled in, the
default date for all time stamps, and also for all
interactive escapes like =%^t= is now the date at the cursor
in the agenda. The exact same command can also be used from
the calendar if you prefer that.
**** Picking a date for scheduling/deadline in the agenda
You may now pick the date for scheduling an item or for
setting a deadline in the agenda, where you have the best
overview over free time slots. This is a two step process.
1. First you pick the entry that should be acted upon. In
the agenda, you use the keys =k m=. In an org-mode file,
this is on =C-c C-x C-k=.
2. Then you find the agenda date you want to apply. When the
cursor is anywhere in the block belonging to that date,
press =k s= to schedule, or =k d= to put a deadline. The
agenda is not updated immediately, press =r= if you want
it to show the affected entry in the right place.
*** New API for mapping a function over all or selected entries
Org has sophisticated mapping capabilities to find all
@ -87,12 +128,9 @@ keyword =WAITING=, in all agenda files.
*** Changes in Remember templates
**** Remember templates can now use the cursor date in the agenda
Two new escapes in remember templates, %v and %V, act like %t
and %T. The only difference is that if the remember process
is started from the agenda or from the calendar, the date at
the cursor becomes the default for the date inserted, or (in
interactive use like %^V), the default date for the date/time
prompt. Thanks to Thomas Baumann for this idea.
Thanks to Thomas Baumann for starting up a thread
that let to this idea.
**** Filing remember templates to the beginning or end of a file
You may now set the heading part of a remember template

View File

@ -49,8 +49,9 @@ has been posted [[http://www.philfam.co.uk/pete/GTD/org-mode/update-org.sh][here
**** Get the development version
You can check out the latest Org development version by using git.
More information on this page: http://repo.or.cz/w/org-mode.git
You can check out the latest Org development version (along with every
release we ever had) by using git. More information on this page:
http://repo.or.cz/w/org-mode.git
* Documentation
** Manual and Reference card
@ -64,6 +65,11 @@ More information on this page: http://repo.or.cz/w/org-mode.git
produced by Takeshi Okano.
- The [[file:faq.org][FAQ]] is not very up-to-date, but may still answer some of your
questions. Please have a look before posting to emacs-orgmode@gnu.org.
- The Org manual is a GNU Manual released under the GFDL. If you
want to redistribute Org with a distribution that does not allow
the GFDL to be used, and if you see no other way to resolve this
licensing conflict, you must use the special [[file:org_dual_license.texi][dual-license version]]
of the manual.
* Links

View File

@ -42,9 +42,9 @@ Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below. A copy of the
license is included in the section entitled ``GNU Free Documentation
License.
and with the Back-Cover Texts as in (a) below. You should have received a
copy of the ``GNU Free Documentation License'' with GNU Emacs. If not, see
@url{http://www.gnu.org/licenses/}.
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free
@ -4502,6 +4502,15 @@ Insert @samp{SCHEDULED} keyword along with a stamp. The insertion will
happen in the line directly following the headline. Any CLOSED
timestamp will be removed. When called with a prefix argument, remove
the scheduling date from the entry.
@c
@kindex C-c C-x C-k
@kindex k a
@kindex k s
@item C-c C-x C-k
Mark the current entry for agenda action. After you have marked the entry
like this, you can open the agenda or the calendar to find an appropriate
date. With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
schedule the marked item.
@end table
@node Repeated tasks, , Inserting deadline/schedule, Deadlines and scheduling
@ -4797,6 +4806,11 @@ stored: Just call @code{org-remember} with a prefix argument. If you
use two prefix arguments, Org jumps to the location where the last
remember note was stored.
You can also call @code{org-remember} in a special way from the agenda,
using the @kbd{k r} key combination. With this access, any time stamps
inserted by the selected remember template (see below) will default to
the cursor date in the agenda, rather than to the current date.
@node Remember templates, Storing notes, Setting up Remember, Remember
@section Remember templates
@cindex templates, for remember
@ -4870,8 +4884,6 @@ insertion of content:
%t @r{time stamp, date only}
%T @r{time stamp with date and time}
%u, %U @r{like the above, but inactive time stamps}
%v, %V @r{like %t,%T, but when called from agenda or calendar, use the}
@r{cursor date as the default date.}
%^t @r{like @code{%t}, but prompt for date. Similarly @code{%^T}, @code{%^u}, @code{%^U}}
@r{You may define a prompt like @code{%^@{Birthday@}t}}
%n @r{user name (taken from @code{user-full-name})}
@ -5853,6 +5865,21 @@ Schedule this item
@item C-c C-d
Set a deadline for this item.
@c
@kindex k
@item k
Agenda actions, to set dates for selected items to the cursor date.
This command also works in the calendar! The command prompts for an
additonal key:
@example
m @r{Mark the entry at point for action. You can also make entries}
@r{in Org files with @kbd{C-c C-x C-k}.}
d @r{Set the deadline of the marked entry to the date at point.}
s @r{Schedule the marked entry at the date at point.}
r @r{Call @code{org-remember} with the cursor date as default date.}
@end example
Press @kbd{r} afterwards to refresh the agenda and see the effect of the
command.
@c
@kindex S-@key{right}
@item S-@key{right}
Change the time stamp associated with the current line by one day into the
@ -9377,6 +9404,9 @@ let me know.
@item
@i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
@item
@i{Christophe Bataillon} created the great unicorn logo that we use on the
Org-mode website.
@item
@i{Alex Bochannek} provided a patch for rounding time stamps.
@item
@i{Charles Cave}'s suggestion sparked the implementation of templates
@ -9512,11 +9542,12 @@ keyword.
system.
@item
@i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
@file{muse.el}, which have similar goals as Org. Initially the development
of Org was fully independent because I was not aware of the existence of
these packages. But with time I have accasionally looked at John's code and
learned a lot from it. John has also contributed a number of great ideas and
patches directly to Org, including the file @code{org-mac-message.el}'
@file{muse.el}, which have similar goals as Org. Initially the
development of Org was fully independent because I was not aware of the
existence of these packages. But with time I have accasionally looked
at John's code and learned a lot from it. John has also contributed a
number of great ideas and patches directly to Org, including the file
@code{org-mac-message.el}'
@item
@i{Carsten Wimmer} suggested some changes and helped fix a bug in
linking to Gnus.

View File

@ -1,18 +1,28 @@
2008-06-16 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-calendar-agenda-action-key): New option.
(org-get-cursor-date): New function.
(org-mark-entry-for-agenda-action): New command.
(org-overriding-default-time): New variable.
(org-read-date): Respect `org-overriding-default-time'.
* org-remember.el (org-remember-apply-template): Respect the
ovverriding default time.
* org-agenda.el (org-agenda-action-marker): New variable.
(org-agenda-action): New command.
(org-agenda-do-action): New function.
2008-06-15 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-schedule, org-deadline): Protect scheduled and
deadline tasks against changes that accidently remove the
repeater.
* org-remember.el (org-remember-apply-template): Access the
default time stored by `org-store-link'.
* org.el (org-store-link-set-default-date): New function.
repeater. Also show a message with the new date when done.
2008-06-15 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-beginning-of-line): Cater for the case when there
are toags but no headline text.
are tags but no headline text.
(org-align-tags-here): Convert to tabs only when indent-tabs-mode
it set.

View File

@ -1087,6 +1087,8 @@ The following commands are available:
(org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
(org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
(org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
(org-defkey org-agenda-mode-map "k" 'org-agenda-action)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later)
@ -1193,6 +1195,11 @@ The following commands are available:
["Schedule" org-agenda-schedule t]
["Set Deadline" org-agenda-deadline t]
"--"
["Mark item" org-agenda-action :active t :keys "k m"]
["Show mark item" org-agenda-action :active t :keys "k v"]
["Schedule marked item" org-agenda-action :active t :keys "k s"]
["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
"--"
["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
@ -4166,12 +4173,12 @@ written as 2-digit years."
(setq org-agenda-ndays 7)
(org-agenda-change-time-span 'week iso-week))
(defun org-agenda-month-view (&optional month)
"Switch to daily view for agenda.
"Switch to monthly view for agenda.
With argument MONTH, switch to that month."
(interactive "P")
(org-agenda-change-time-span 'month month))
(defun org-agenda-year-view (&optional year)
"Switch to daily view for agenda.
"Switch to yearly view for agenda.
With argument YEAR, switch to that year.
If MONTH has more then 2 digits, only the last two encode the
month. Any digits before this encode a year. So 200712 means
@ -4922,6 +4929,69 @@ be used to request time specification in the time stamp."
(org-agenda-show-new-time marker ts "S"))
(message "Deadline for this item set to %s" ts)))
(defun org-agenda-action ()
"Select entry for agenda action, or execute an agenda action.
This command prompts for another letter. Valid inputs are:
m Mark the entry at point for an agenda action
s Schedule the marked entry to the date at the cursor
d Set the deadline of the marked entry to the date at the cursor
r Call `org-remember' with cursor date as the default date
SPC Show marked entry in other window
TAB Visit marked entry in other window
The cursor may be at a date in the calendar, or in the Org agenda."
(interactive)
(let (pos ans)
(message "Select action: [m]ark | [s]chedule [d]eadline [r]emember [ ]show")
(setq ans (read-char-exclusive))
(cond
((equal ans ?m)
;; Mark this entry
(if (eq major-mode 'org-agenda-mode)
(let ((m (or (get-text-property (point) 'org-hd-marker)
(get-text-property (point) 'org-marker))))
(if m
(progn
(move-marker org-agenda-action-marker
(marker-position m) (marker-buffer m))
(message "Entry marked for action; press `k' at desired date in agenda or calendar"))
(error "Don't know which entry to mark")))
(error "This command works only in the agenda")))
((equal ans ?s)
(org-agenda-do-action '(org-schedule nil org-overriding-default-time)))
((equal ans ?d)
(org-agenda-do-action '(org-deadline nil org-overriding-default-time)))
((equal ans ?r)
(org-agenda-do-action '(org-remember) t))
((equal ans ?\ )
(let ((cw (selected-window)))
(org-switch-to-buffer-other-window
(marker-buffer org-agenda-action-marker))
(goto-char org-agenda-action-marker)
(org-show-context 'agenda)
(select-window cw)))
((equal ans ?\C-i)
(org-switch-to-buffer-other-window
(marker-buffer org-agenda-action-marker))
(goto-char org-agenda-action-marker)
(org-show-context 'agenda))
(t (error "Invalid agenda action %c" ans)))))
(defun org-agenda-do-action (form &optional current-buffer)
"Evaluate FORM at the entry pointed to by `org-agenda-action-marker'."
(let ((org-overriding-default-time (org-get-cursor-date)))
(if current-buffer
(eval form)
(if (not (marker-buffer org-agenda-action-marker))
(error "No entry has bee selected for agenda action")
(with-current-buffer (marker-buffer org-agenda-action-marker)
(save-excursion
(save-restriction
(widen)
(goto-char org-agenda-action-marker)
(eval form))))))))
(defun org-agenda-clock-in (&optional arg)
"Start the clock on the currently selected item."
(interactive "P")
@ -5184,3 +5254,5 @@ belonging to the \"Work\" category."
;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
;;; org-agenda.el ends here

View File

@ -123,14 +123,16 @@ Furthermore, the following %-escapes will be replaced with content:
%t time stamp, date only
%T time stamp with date and time
%u, %U like the above, but inactive time stamps
%v, %V like %t,%T, but use agenda/calendar date as default.
%^t like %t, but prompt for date. Similarly %^T, %^u, %^U, %^v %^V
You may define a prompt like %^{Please specify birthday}t
%^t like %t, but prompt for date. Similarly %^T, %^u, %^U.
You may define a prompt like %^{Please specify birthday
%n user name (taken from `user-full-name')
%a annotation, normally the link created with org-store-link
%i initial content, the region active. If %i is indented,
the entire inserted text will be indented as well.
%c content of the clipboard, or current kill ring head
%c current kill ring head
%x content of the X clipboard
%^C Interactive selection of which kill or clip to use
%^L Like %^C, but insert as link
%^g prompt for tags, with completion on tags in target file
%^G prompt for tags, with completion all tags in all agenda files
%:keyword specific information for certain link types, see below
@ -313,9 +315,9 @@ This function should be placed into `remember-mode-hook' and in fact requires
to be run from that hook to function properly."
(if org-remember-templates
(let* ((entry (org-select-remember-template use-char))
(ct (or org-overriding-default-time (org-current-time)))
(tpl (car entry))
(plist-p (if org-store-link-plist t nil))
(default-time (plist-get org-store-link-plist :default-time))
(file (if (and (nth 1 entry) (stringp (nth 1 entry))
(string-match "\\S-" (nth 1 entry)))
(nth 1 entry)
@ -325,10 +327,8 @@ to be run from that hook to function properly."
(v-x (or (org-get-x-clipboard 'PRIMARY)
(org-get-x-clipboard 'CLIPBOARD)
(org-get-x-clipboard 'SECONDARY)))
(v-t (format-time-string (car org-time-stamp-formats) (org-current-time)))
(v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time)))
(v-v (format-time-string (car org-time-stamp-formats) (or default-time (org-current-time))))
(v-V (format-time-string (cdr org-time-stamp-formats) (or default-time (org-current-time))))
(v-t (format-time-string (car org-time-stamp-formats) ct))
(v-T (format-time-string (cdr org-time-stamp-formats) ct))
(v-u (concat "[" (substring v-t 1 -1) "]"))
(v-U (concat "[" (substring v-T 1 -1) "]"))
;; `initial' and `annotation' are bound in `remember'
@ -371,7 +371,7 @@ to be run from that hook to function properly."
(or (cdr org-remember-previous-location) "???"))))
(insert tpl) (goto-char (point-min))
;; Simple %-escapes
(while (re-search-forward "%\\([tTuUvVaiAcx]\\)" nil t)
(while (re-search-forward "%\\([tTuUaiAcx]\\)" nil t)
(when (and initial (equal (match-string 0) "%i"))
(save-match-data
(let* ((lead (buffer-substring
@ -425,7 +425,7 @@ to be run from that hook to function properly."
(org-set-local 'org-remember-default-headline headline))
;; Interactive template entries
(goto-char (point-min))
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGuUtTvVCL]\\)?" nil t)
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
(setq char (if (match-end 3) (match-string 3))
prompt (if (match-end 2) (match-string 2)))
(goto-char (match-beginning 0))
@ -471,12 +471,10 @@ to be run from that hook to function properly."
'(clipboards . 1)
(car clipboards))))))
(char
;; These are the date/time related ones
(setq org-time-was-given (equal (upcase char) char))
(setq time (org-read-date (equal (upcase char) "U") t nil
prompt
(if (equal (upcase char) "V")
default-time
nil)))
prompt))
(org-insert-time-stamp time org-time-was-given
(member char '("u" "U"))
nil nil (list org-end-time-was-given)))

View File

@ -2000,9 +2000,19 @@ forth between agenda and calendar."
:group 'org-agenda
:type 'sexp)
(defcustom org-calendar-agenda-action-key [?k]
"The key to be installed in `calendar-mode-map' for agenda-action.
The command `org-agenda-action' will be bound to this key. The
default is the character `k' because we use the same key in the agenda."
:group 'org-agenda
:type 'sexp)
(eval-after-load "calendar"
'(org-defkey calendar-mode-map org-calendar-to-agenda-key
'org-calendar-goto-agenda))
'(progn
(org-defkey calendar-mode-map org-calendar-to-agenda-key
'org-calendar-goto-agenda)
(org-defkey calendar-mode-map org-calendar-agenda-action-key
'org-agenda-action)))
(defgroup org-latex nil
"Options for embedding LaTeX code into Org-mode."
@ -6524,7 +6534,6 @@ For file links, arg negates `org-context-in-file-links'."
(interactive "P")
(org-load-modules-maybe)
(setq org-store-link-plist nil) ; reset
(org-store-link-set-default-date)
(let (link cpltxt desc description search txt)
(cond
@ -6659,24 +6668,6 @@ For file links, arg negates `org-context-in-file-links'."
(setq org-store-link-plist
(plist-put org-store-link-plist key value)))))
(defun org-store-link-set-default-date ()
"Store the date at the cursor so that remember templates can access it.
This works in the calendar, and in the Org Agenda. It is a no-op in
any other modes."
(let (date day defd)
(cond
((eq major-mode 'calendar-mode)
(setq date (calendar-cursor-to-date)
defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
((eq major-mode 'org-agenda-mode)
(setq day (get-text-property (point) 'day))
(if day
(setq date (calendar-gregorian-from-absolute day)
defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
(nth 2 date))))))
(when defd
(org-store-link-props :default-time defd))))
(defun org-email-link-description (&optional fmt)
"Return the description part of an email link.
This takes information from `org-store-link-plist' and formats it
@ -8704,9 +8695,11 @@ of `org-todo-keywords-1'."
(message "%d TODO entries found"
(org-occur (concat "^" outline-regexp " *" kwd-re )))))
(defun org-deadline (&optional remove)
(defun org-deadline (&optional remove time)
"Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
With argument REMOVE, remove any deadline from the item."
With argument REMOVE, remove any deadline from the item.
When TIME is set, it should be an internal time specification, and the
scheduling will use the corresponding date."
(interactive "P")
(if remove
(progn
@ -8714,11 +8707,14 @@ With argument REMOVE, remove any deadline from the item."
(message "Item no longer has a deadline."))
(if (org-get-repeat)
(error "Cannot change deadline on task with repeater, please do that by hand")
(org-add-planning-info 'deadline nil 'closed))))
(org-add-planning-info 'deadline time 'closed)
(message "Deadline on %s" org-last-inserted-timestamp))))
(defun org-schedule (&optional remove)
(defun org-schedule (&optional remove time)
"Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
With argument REMOVE, remove any scheduling date from the item."
With argument REMOVE, remove any scheduling date from the item.
When TIME is set, it should be an internal time specification, and the
scheduling will use the corresponding date."
(interactive "P")
(if remove
(progn
@ -8726,7 +8722,8 @@ With argument REMOVE, remove any scheduling date from the item."
(message "Item is no longer scheduled."))
(if (org-get-repeat)
(error "Cannot reschedule task with repeater, please do that by hand")
(org-add-planning-info 'scheduled nil 'closed))))
(org-add-planning-info 'scheduled time 'closed)
(message "Scheduled to %s" org-last-inserted-timestamp))))
(defun org-remove-timestamp-with-keyword (keyword)
"Remove all time stamps with KEYWORD in the current entry."
@ -10600,6 +10597,8 @@ Return the position where this entry starts, or nil if there is no such entry."
;;;; Timestamps
(defvar org-last-changed-timestamp nil)
(defvar org-last-inserted-timestamp nil
"The last time stamp inserted with `org-insert-time-stamp'.")
(defvar org-time-was-given) ; dynamically scoped parameter
(defvar org-end-time-was-given) ; dynamically scoped parameter
(defvar org-ts-what) ; dynamically scoped parameter
@ -10689,6 +10688,7 @@ So these are more for recording a certain time/date."
(defvar org-plain-time-of-day-regexp) ; defined below
(defvar org-overriding-default-time nil) ; dynamically scoped
(defvar org-read-date-overlay nil)
(defvar org-dcst nil) ; dynamically scoped
@ -10746,7 +10746,7 @@ user."
(if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
(org-dcst org-display-custom-times)
(ct (org-current-time))
(def (or default-time ct))
(def (or org-overriding-default-time default-time ct))
(defdecode (decode-time def))
(dummy (progn
(when (< (nth 2 defdecode) org-extend-today-until)
@ -11110,7 +11110,7 @@ The command returns the inserted time stamp."
(insert-before-markers extra)
(forward-char 1))
(insert-before-markers (or post ""))
stamp))
(setq org-last-inserted-timestamp stamp)))
(defun org-toggle-time-stamp-overlays ()
"Toggle the use of custom time stamp formats."
@ -12488,7 +12488,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
(org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
(org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action)
(org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
(org-defkey org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
(org-defkey org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
@ -13856,6 +13856,37 @@ not an indirect buffer."
(save-match-data
(string-match (org-image-file-name-regexp) file)))
(defun org-get-cursor-date ()
"Return the date at cursor in as a time.
This works in the calendar and in the agenda, anywhere else it just
returns the current time."
(let (date day defd)
(cond
((eq major-mode 'calendar-mode)
(setq date (calendar-cursor-to-date)
defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
((eq major-mode 'org-agenda-mode)
(setq day (get-text-property (point) 'day))
(if day
(setq date (calendar-gregorian-from-absolute day)
defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
(nth 2 date))))))
(or defd (current-time))))
(defvar org-agenda-action-marker (make-marker)
"Marker pointing to the entry for the next agenda action.")
(defun org-mark-entry-for-agenda-action ()
"Mark the current entry as target of an agenda action.
Agenda actions are actions executed from the agenda with the key `k',
which make use of the date at the cursor."
(interactive)
(move-marker org-agenda-action-marker
(save-excursion (org-back-to-heading t) (point))
(current-buffer))
(message
"Entry marked for action; press `k' at desired date in agenda or calendar"))
;;; Paragraph filling stuff.
;; We want this to be just right, so use the full arsenal.