Browse Source

Allow time stampes without day name

* lisp/org-clock.el (org-clock-in):
(org-clock-find-position): Make space after date optional.
* lisp/org.el (org-set-regexps-and-options):
(org-ts-regexp):
(org-ts-regexp-both):
(org-ts-regexp1):
(org-ctrl-c-ctrl-c): Make `C-c C-c' on date fix the time stamp

* doc/org.texi (Creating timestamps): Document the effect of `C-c C-c'
on a timestamp.
Carsten Dominik 13 years ago
parent
commit
278d5afa2f
3 changed files with 22 additions and 13 deletions
  1. 14 7
      doc/org.texi
  2. 2 2
      lisp/org-clock.el
  3. 6 4
      lisp/org.el

+ 14 - 7
doc/org.texi

@@ -5267,13 +5267,15 @@ is used in a much wider sense.
 @cindex scheduling
 @cindex scheduling
 
 
 A timestamp is a specification of a date (possibly with a time or a range of
 A timestamp is a specification of a date (possibly with a time or a range of
-times) in a special format, either @samp{<2003-09-16 Tue>} or
-@samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
-12:00-12:30>}@footnote{This is inspired by the standard ISO 8601 date/time
-format.  To use an alternative format, see @ref{Custom time format}.}.  A
-timestamp can appear anywhere in the headline or body of an Org tree entry.
-Its presence causes entries to be shown on specific dates in the agenda
-(@pxref{Weekly/daily agenda}).  We distinguish:
+times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
+simplest form, the day name is optional when you type the date yourself.
+However, any dates inserted or modified by Org will add that day name, for
+reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
+Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
+date/time format.  To use an alternative format, see @ref{Custom time
+format}.}.  A timestamp can appear anywhere in the headline or body of an Org
+tree entry.  Its presence causes entries to be shown on specific dates in the
+agenda (@pxref{Weekly/daily agenda}).  We distinguish:
 
 
 @table @var
 @table @var
 @item Plain timestamp; Event; Appointment
 @item Plain timestamp; Event; Appointment
@@ -5374,6 +5376,9 @@ Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
 contains date and time.  The default time can be rounded to multiples of 5
 contains date and time.  The default time can be rounded to multiples of 5
 minutes, see the option @code{org-time-stamp-rounding-minutes}.
 minutes, see the option @code{org-time-stamp-rounding-minutes}.
 @c
 @c
+@orgkey{C-c C-c}
+Normalize timestamp, insert/fix day name if missing or wrong.
+@c
 @orgcmd{C-c <,org-date-from-calendar}
 @orgcmd{C-c <,org-date-from-calendar}
 Insert a timestamp corresponding to the cursor date in the Calendar.
 Insert a timestamp corresponding to the cursor date in the Calendar.
 @c
 @c
@@ -13770,6 +13775,8 @@ ordered list.
 @item
 @item
 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
 block is updated.
 block is updated.
+@item
+If the cursor is at a timestamp, fix the day name in the timestamp.
 @end itemize
 @end itemize
 
 
 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous

+ 2 - 2
lisp/org-clock.el

@@ -1117,7 +1117,7 @@ the clocking selection, associated with the letter `d'."
 		   (looking-at
 		   (looking-at
 		    (concat "^[ \t]* " org-clock-string
 		    (concat "^[ \t]* " org-clock-string
 			    " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
 			    " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-			    " +\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
+			    " *\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
 	      (message "Matched %s" (match-string 1))
 	      (message "Matched %s" (match-string 1))
 	      (setq ts (concat "[" (match-string 1) "]"))
 	      (setq ts (concat "[" (match-string 1) "]"))
 	      (goto-char (match-end 1))
 	      (goto-char (match-end 1))
@@ -1249,7 +1249,7 @@ line and position cursor in that line."
 		 (re-search-forward
 		 (re-search-forward
 		  (concat "^[ \t]* " org-clock-string
 		  (concat "^[ \t]* " org-clock-string
 			  " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
 			  " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-			  " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
+			  " *\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
 		  end t))
 		  end t))
 	(beginning-of-line 1)
 	(beginning-of-line 1)
 	(throw 'exit t))
 	(throw 'exit t))

+ 6 - 4
lisp/org.el

@@ -4724,7 +4724,7 @@ means to push this value onto the list in the variable.")
 		    "\\|" org-deadline-string
 		    "\\|" org-deadline-string
 		    "\\|" org-closed-string
 		    "\\|" org-closed-string
 		    "\\|" org-clock-string "\\)\\)?"
 		    "\\|" org-clock-string "\\)\\)?"
-		    " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
+		    " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
 	    org-planning-or-clock-line-re
 	    org-planning-or-clock-line-re
 	    (concat "\\(?:^[ \t]*\\(" org-scheduled-string
 	    (concat "\\(?:^[ \t]*\\(" org-scheduled-string
 		    "\\|" org-deadline-string
 		    "\\|" org-deadline-string
@@ -5189,15 +5189,15 @@ This should be called after the variable `org-link-types' has changed."
 
 
 (org-make-link-regexps)
 (org-make-link-regexps)
 
 
-(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)>"
+(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)>"
   "Regular expression for fast time stamp matching.")
   "Regular expression for fast time stamp matching.")
-(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?\\)[]>]"
+(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
   "Regular expression for fast time stamp matching.")
   "Regular expression for fast time stamp matching.")
 (defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
 (defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.
   "Regular expression matching time strings for analysis.
 This one does not require the space after the date, so it can be used
 This one does not require the space after the date, so it can be used
 on a string that terminates immediately after the date.")
 on a string that terminates immediately after the date.")
-(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) +\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.")
   "Regular expression matching time strings for analysis.")
 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
   "Regular expression matching time stamps, with groups.")
   "Regular expression matching time stamps, with groups.")
@@ -18236,6 +18236,8 @@ This command does many different things, depending on context:
 	   (fboundp org-finish-function))
 	   (fboundp org-finish-function))
       (funcall org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
+     ((org-in-regexp org-ts-regexp-both)
+      (org-timestamp-change 0 'day))
      ((or (looking-at org-property-start-re)
      ((or (looking-at org-property-start-re)
 	  (org-at-property-p))
 	  (org-at-property-p))
       (call-interactively 'org-property-action))
       (call-interactively 'org-property-action))