Browse Source

New remember escapes hat use calendar date as default.

When calling a remember template from the agenda or from the
calendar, the cursor date becomes the default for %v and %V.
Carsten Dominik 17 years ago
parent
commit
2c3ac24e03
3 changed files with 26 additions and 18 deletions
  1. 6 4
      doc/org.texi
  2. 10 4
      lisp/org-remember.el
  3. 10 10
      lisp/org.el

+ 6 - 4
doc/org.texi

@@ -4863,16 +4863,18 @@ insertion of content:
             @r{You may specify a default value and a completion table with}
             @r{%^@{prompt|default|completion2|completion3...@}}
             @r{The arrow keys access a prompt-specific history.}
+%a          @r{annotation, normally the link created with @code{org-store-link}}
+%A          @r{like @code{%a}, but prompt for the description part}
+%i          @r{initial content, the region when remember is called with C-u.}
+            @r{The entire text will be indented like @code{%i} itself.}
 %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})}
-%a          @r{annotation, normally the link created with @code{org-store-link}}
-%A          @r{like @code{%a}, but prompt for the description part}
-%i          @r{initial content, the region when remember is called with C-u.}
-            @r{The entire text will be indented like @code{%i} itself.}
 %c          @r{Current kill ring head.}
 %x          @r{Content of the X clipboard.}
 %^C         @r{Interactive selection of which kill or clip to use.}

+ 10 - 4
lisp/org-remember.el

@@ -123,7 +123,8 @@ 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
-  %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U
+  %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
   %n          user name (taken from `user-full-name')
   %a          annotation, normally the link created with org-store-link
@@ -326,6 +327,8 @@ to be run from that hook to function properly."
 		      (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-u (concat "[" (substring v-t 1 -1) "]"))
 	     (v-U (concat "[" (substring v-T 1 -1) "]"))
 	     ;; `initial' and `annotation' are bound in `remember'
@@ -368,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 "%\\([tTuUaiAcx]\\)" nil t)
+	(while (re-search-forward "%\\([tTuUvVaiAcx]\\)" nil t)
 	  (when (and initial (equal (match-string 0) "%i"))
 	    (save-match-data
 	      (let* ((lead (buffer-substring
@@ -422,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 "%^\\({\\([^}]*\\)}\\)?\\([gGuUtTCL]\\)?" nil t)
+	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGuUtTvVCL]\\)?" nil t)
 	  (setq char (if (match-end 3) (match-string 3))
 		prompt (if (match-end 2) (match-string 2)))
 	  (goto-char (match-beginning 0))
@@ -470,7 +473,10 @@ 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 default-time))
+				      prompt
+				      (if (equal (upcase char) "V")
+					  default-time
+					nil)))
 	    (org-insert-time-stamp time org-time-was-given
 				   (member char '("u" "U"))
 				   nil nil (list org-end-time-was-given)))

+ 10 - 10
lisp/org.el

@@ -6663,19 +6663,19 @@ For file links, arg negates `org-context-in-file-links'."
   "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)
+  (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)))
+				  (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.