Преглед на файлове

Use agenda/calendar date as default for remember templates.

This applies only when the remember process gets started in the
agenda or calendar buffer.
Carsten Dominik преди 17 години
родител
ревизия
2003d83370
променени са 3 файла, в които са добавени 28 реда и са изтрити 1 реда
  1. 7 0
      lisp/ChangeLog
  2. 2 1
      lisp/org-remember.el
  3. 19 0
      lisp/org.el

+ 7 - 0
lisp/ChangeLog

@@ -1,3 +1,10 @@
+2008-06-15  Carsten Dominik  <dominik@science.uva.nl>
+
+	* 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.
+
 2008-06-15  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org.el (org-beginning-of-line): Cater for the case when there

+ 2 - 1
lisp/org-remember.el

@@ -314,6 +314,7 @@ to be run from that hook to function properly."
       (let* ((entry (org-select-remember-template use-char))
 	     (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)
@@ -469,7 +470,7 @@ to be run from that hook to function properly."
 	   (char
 	    (setq org-time-was-given (equal (upcase char) char))
 	    (setq time (org-read-date (equal (upcase char) "U") t nil
-				      prompt))
+				      prompt default-time))
 	    (org-insert-time-stamp time org-time-was-given
 				   (member char '("u" "U"))
 				   nil nil (list org-end-time-was-given)))

+ 19 - 0
lisp/org.el

@@ -6524,6 +6524,7 @@ 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
 
@@ -6658,6 +6659,24 @@ 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."
+  (cond
+   ((eq major-mode 'calendar-mode)
+    (let ((date (calendar-cursor-to-date)) day defd)
+      (setq defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))))
+   ((eq major-mode 'org-agenda-mode)
+    (let* ((day (get-text-property (point) 'day))
+	   date)
+      (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