瀏覽代碼

Merge branch 'fix-time-stamp-editing'

Conflicts:

	ChangeLog
Carsten Dominik 18 年之前
父節點
當前提交
8017cc33d2
共有 2 個文件被更改,包括 23 次插入9 次删除
  1. 7 1
      ChangeLog
  2. 16 8
      org.el

+ 7 - 1
ChangeLog

@@ -1,12 +1,18 @@
+
 2008-03-06  Bastien Guerry  <bzg@altern.org>
 2008-03-06  Bastien Guerry  <bzg@altern.org>
 
 
 	* org.el (org-get-legal-level): Aliased to `org-get-valid-level'.
 	* org.el (org-get-legal-level): Aliased to `org-get-valid-level'.
 
 
+2008-03-06  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-timestamp-change, org-modify-ts-extra)
+	(org-ts-regexp1): Fix timestamp editing.
+
 2008-03-05  Carsten Dominik  <dominik@science.uva.nl>
 2008-03-05  Carsten Dominik  <dominik@science.uva.nl>
 
 
 	* org.el "htmlize"): Removed hack to fix face problem with
 	* org.el "htmlize"): Removed hack to fix face problem with
 	htmlize, it no longer seem necessary.
 	htmlize, it no longer seem necessary.
-	
+
 2008-03-05  Bastien Guerry  <bzg@altern.org>
 2008-03-05  Bastien Guerry  <bzg@altern.org>
 
 
 	* org.el (org-follow-link-hook): New hook.
 	* org.el (org-follow-link-hook): New hook.

+ 16 - 8
org.el

@@ -5225,7 +5225,7 @@ This should be called after the variable `org-link-types' has changed."
 (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.")
 This one does not require the space 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.")
@@ -18634,7 +18634,7 @@ in the timestamp determines what will be changed."
 	    ts (match-string 0))
 	    ts (match-string 0))
       (replace-match "")
       (replace-match "")
       (if (string-match
       (if (string-match
-	   "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( [-+][0-9]+[dwmy]\\)*\\)[]>]"
+	   "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[-+][0-9]+[dwmy]\\)*\\)[]>]"
 	   ts)
 	   ts)
 	  (setq extra (match-string 1 ts)))
 	  (setq extra (match-string 1 ts)))
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
@@ -18655,7 +18655,7 @@ in the timestamp determines what will be changed."
 			 (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
 			 (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
 			 (nthcdr 6 time0)))
 			 (nthcdr 6 time0)))
       (when (integerp org-ts-what)
       (when (integerp org-ts-what)
-	(setq extra (org-modify-ts-extra extra org-ts-what n)))
+	(setq extra (org-modify-ts-extra extra org-ts-what n dm)))
       (if (eq what 'calendar)
       (if (eq what 'calendar)
 	  (let ((cal-date (org-get-date-from-calendar)))
 	  (let ((cal-date (org-get-date-from-calendar)))
 	    (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
 	    (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
@@ -18676,11 +18676,11 @@ in the timestamp determines what will be changed."
 	  (org-recenter-calendar (time-to-days time))))))
 	  (org-recenter-calendar (time-to-days time))))))
 
 
 ;; FIXME: does not yet work for lead times
 ;; FIXME: does not yet work for lead times
-(defun org-modify-ts-extra (s pos n)
+(defun org-modify-ts-extra (s pos n dm)
   "Change the different parts of the lead-time and repeat fields in timestamp."
   "Change the different parts of the lead-time and repeat fields in timestamp."
   (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
   (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
-	ng h m new)
-    (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( \\+\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
+	ng h m new rem)
+    (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([dmwy]\\)\\)?\\( +-\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
       (cond
       (cond
        ((or (org-pos-in-match-range pos 2)
        ((or (org-pos-in-match-range pos 2)
 	    (org-pos-in-match-range pos 3))
 	    (org-pos-in-match-range pos 3))
@@ -18688,6 +18688,9 @@ in the timestamp determines what will be changed."
 	      h (string-to-number (match-string 2 s)))
 	      h (string-to-number (match-string 2 s)))
 	(if (org-pos-in-match-range pos 2)
 	(if (org-pos-in-match-range pos 2)
 	    (setq h (+ h n))
 	    (setq h (+ h n))
+	  (setq n (* dm (org-no-warnings (signum n))))
+	  (when (not (= 0 (setq rem (% m dm))))
+	    (setq m (+ m (if (> n 0) (- rem) (- dm rem)))))
 	  (setq m (+ m n)))
 	  (setq m (+ m n)))
 	(if (< m 0) (setq m (+ m 60) h (1- h)))
 	(if (< m 0) (setq m (+ m 60) h (1- h)))
 	(if (> m 59) (setq m (- m 60) h (1+ h)))
 	(if (> m 59) (setq m (- m 60) h (1+ h)))
@@ -18696,8 +18699,13 @@ in the timestamp determines what will be changed."
        ((org-pos-in-match-range pos 6)
        ((org-pos-in-match-range pos 6)
 	(setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
 	(setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
        ((org-pos-in-match-range pos 5)
        ((org-pos-in-match-range pos 5)
-	(setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s))))))))
-
+	(setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))
+       
+       ((org-pos-in-match-range pos 9)
+	(setq ng 9 new (car (rassoc (+ n (cdr (assoc (match-string 9 s) idx))) idx))))
+       ((org-pos-in-match-range pos 8)
+	(setq ng 8 new (format "%d" (max 0 (+ n (string-to-number (match-string 8 s))))))))
+      
       (when ng
       (when ng
 	(setq s (concat
 	(setq s (concat
 		 (substring s 0 (match-beginning ng))
 		 (substring s 0 (match-beginning ng))