浏览代码

Use [...] in the `org-read-date' overlay when inserting inactive timestamps.

* org.el (org-read-date): New parameter `inactive' when
reading for insertion of inactive timestamps.
(org-time-stamp, org-read-date-display): Use the new
parameter.

Thanks to François Pinard for this suggestion.
Bastien Guerry 13 年之前
父节点
当前提交
9b299af837
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      lisp/org.el

+ 9 - 5
lisp/org.el

@@ -14786,11 +14786,11 @@ at the cursor, it will be modified."
       (insert "--")
       (insert "--")
       (setq time (let ((this-command this-command))
       (setq time (let ((this-command this-command))
 		  (org-read-date arg 'totime nil nil
 		  (org-read-date arg 'totime nil nil
-				 default-time default-input)))
+				 default-time default-input inactive)))
       (org-insert-time-stamp time (or org-time-was-given arg) inactive))
       (org-insert-time-stamp time (or org-time-was-given arg) inactive))
      ((org-at-timestamp-p t)
      ((org-at-timestamp-p t)
       (setq time (let ((this-command this-command))
       (setq time (let ((this-command this-command))
-		   (org-read-date arg 'totime nil nil default-time default-input)))
+		   (org-read-date arg 'totime nil nil default-time default-input inactive)))
       (when (org-at-timestamp-p t) ; just to get the match data
       (when (org-at-timestamp-p t) ; just to get the match data
 ;	(setq inactive (eq (char-after (match-beginning 0)) ?\[))
 ;	(setq inactive (eq (char-after (match-beginning 0)) ?\[))
 	(replace-match "")
 	(replace-match "")
@@ -14805,7 +14805,7 @@ at the cursor, it will be modified."
       (message "Timestamp updated"))
       (message "Timestamp updated"))
      (t
      (t
       (setq time (let ((this-command this-command))
       (setq time (let ((this-command this-command))
-		   (org-read-date arg 'totime nil nil default-time default-input)))
+		   (org-read-date arg 'totime nil nil default-time default-input inactive)))
       (org-insert-time-stamp time (or org-time-was-given arg) inactive
       (org-insert-time-stamp time (or org-time-was-given arg) inactive
 			     nil nil (list org-end-time-was-given))))))
 			     nil nil (list org-end-time-was-given))))))
 
 
@@ -14853,7 +14853,7 @@ So these are more for recording a certain time/date."
 (defvar org-read-date-analyze-forced-year nil)
 (defvar org-read-date-analyze-forced-year nil)
 
 
 (defun org-read-date (&optional with-time to-time from-string prompt
 (defun org-read-date (&optional with-time to-time from-string prompt
-				default-time default-input)
+				default-time default-input inactive)
   "Read a date, possibly a time, and make things smooth for the user.
   "Read a date, possibly a time, and make things smooth for the user.
 The prompt will suggest to enter an ISO date, but you can also enter anything
 The prompt will suggest to enter an ISO date, but you can also enter anything
 which will at least partially be understood by `parse-time-string'.
 which will at least partially be understood by `parse-time-string'.
@@ -15002,6 +15002,7 @@ user."
 		  (unwind-protect
 		  (unwind-protect
 		      (progn
 		      (progn
 			(use-local-map map)
 			(use-local-map map)
+			(setq org-read-date-inactive inactive)
 			(add-hook 'post-command-hook 'org-read-date-display)
 			(add-hook 'post-command-hook 'org-read-date-display)
 			(setq org-ans0 (read-string prompt default-input
 			(setq org-ans0 (read-string prompt default-input
 						    'org-read-date-history nil))
 						    'org-read-date-history nil))
@@ -15049,6 +15050,7 @@ user."
 (defvar def)
 (defvar def)
 (defvar defdecode)
 (defvar defdecode)
 (defvar with-time)
 (defvar with-time)
+(defvar org-read-date-inactive)
 (defun org-read-date-display ()
 (defun org-read-date-display ()
   "Display the current date prompt interpretation in the minibuffer."
   "Display the current date prompt interpretation in the minibuffer."
   (when org-read-date-display-live
   (when org-read-date-display-live
@@ -15072,7 +15074,9 @@ user."
 			(and (boundp 'org-time-was-given) org-time-was-given))
 			(and (boundp 'org-time-was-given) org-time-was-given))
 		    (cdr fmts)
 		    (cdr fmts)
 		  (car fmts)))
 		  (car fmts)))
-	   (txt (concat "=> " (format-time-string fmt (apply 'encode-time f)))))
+	   (txt (format-time-string fmt (apply 'encode-time f)))
+	   (txt (if org-read-date-inactive (concat "[" (substring txt 1 -1) "]") txt))
+	   (txt (concat "=> " txt)))
       (when (and org-end-time-was-given
       (when (and org-end-time-was-given
 		 (string-match org-plain-time-of-day-regexp txt))
 		 (string-match org-plain-time-of-day-regexp txt))
 	(setq txt (concat (substring txt 0 (match-end 0)) "-"
 	(setq txt (concat (substring txt 0 (match-end 0)) "-"