0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-07-20 08:26:29 +00:00

Fixed timestamp editing.

Timestamp editing did not work correctly.  The deadline warning days
could not be edited, and editing the end of a time range did
not respect the new granularity.  Seems to work now.
This commit is contained in:
Carsten Dominik 2008-03-06 20:10:54 +01:00
parent f494bf736a
commit 1affe117d2
2 changed files with 22 additions and 9 deletions

View file

@ -1,8 +1,13 @@
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>
* org.el "htmlize"): Removed hack to fix face problem with
htmlize, it no longer seem necessary.
2008-03-05 Bastien Guerry <bzg@altern.org>
* org.el (org-follow-link-hook): New hook.

24
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\\}\\)\\)?\\)"
"Regular expression matching time strings for analysis.
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.")
(defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
"Regular expression matching time stamps, with groups.")
@ -18631,7 +18631,7 @@ in the timestamp determines what will be changed."
ts (match-string 0))
(replace-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)
(setq extra (match-string 1 ts)))
(if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
@ -18652,7 +18652,7 @@ in the timestamp determines what will be changed."
(+ (if (eq org-ts-what 'year) n 0) (nth 5 time0))
(nthcdr 6 time0)))
(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)
(let ((cal-date (org-get-date-from-calendar)))
(setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
@ -18673,11 +18673,11 @@ in the timestamp determines what will be changed."
(org-recenter-calendar (time-to-days time))))))
;; 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."
(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
((or (org-pos-in-match-range pos 2)
(org-pos-in-match-range pos 3))
@ -18685,6 +18685,9 @@ in the timestamp determines what will be changed."
h (string-to-number (match-string 2 s)))
(if (org-pos-in-match-range pos 2)
(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)))
(if (< m 0) (setq m (+ m 60) h (1- h)))
(if (> m 59) (setq m (- m 60) h (1+ h)))
@ -18693,8 +18696,13 @@ in the timestamp determines what will be changed."
((org-pos-in-match-range pos 6)
(setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
((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
(setq s (concat
(substring s 0 (match-beginning ng))