Merge branch 'fix-time-stamp-editing'

Conflicts:

	ChangeLog
This commit is contained in:
Carsten Dominik 2008-03-06 20:12:43 +01:00
commit 8017cc33d2
2 changed files with 23 additions and 9 deletions

View File

@ -1,7 +1,13 @@
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

22
org.el
View File

@ -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) ng h m new rem)
(when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( \\+\\([0-9]+\\)\\([dmwy]\\)\\)?" s) (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,7 +18699,12 @@ 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