org-clock-timestamps-change: Preserve point position
* lisp/org-clock.el (org-clock-timestamps-change): Try harder to preserve point position. `save-excursion' is not sufficient here, when the timestamp gets deleted in the process. Reported-by: Johannes Dahl <muusik@gmail.com> Link: https://orgmode.org/list/CAHuokSbJxM4kqjdT94aHmjnKqzOvpJpq3tJqOEqdswaBC=JnfA@mail.gmail.com
This commit is contained in:
parent
cd967ce006
commit
97a235cf1c
|
@ -1800,17 +1800,25 @@ Optional argument N tells to change by that many units."
|
||||||
(time-subtract
|
(time-subtract
|
||||||
(org-time-string-to-time org-last-changed-timestamp)
|
(org-time-string-to-time org-last-changed-timestamp)
|
||||||
(org-time-string-to-time ts)))
|
(org-time-string-to-time ts)))
|
||||||
(save-excursion
|
;; `save-excursion' won't work because
|
||||||
(goto-char begts)
|
;; `org-timestamp-change' deletes and re-inserts the
|
||||||
(org-timestamp-change
|
;; timestamp.
|
||||||
(round (/ (float-time tdiff)
|
(let ((origin (point)))
|
||||||
(pcase timestamp?
|
(save-excursion
|
||||||
(`minute 60)
|
(goto-char begts)
|
||||||
(`hour 3600)
|
(org-timestamp-change
|
||||||
(`day (* 24 3600))
|
(round (/ (float-time tdiff)
|
||||||
(`month (* 24 3600 31))
|
(pcase timestamp?
|
||||||
(`year (* 24 3600 365.2)))))
|
(`minute 60)
|
||||||
timestamp? 'updown)))))))
|
(`hour 3600)
|
||||||
|
(`day (* 24 3600))
|
||||||
|
(`month (* 24 3600 31))
|
||||||
|
(`year (* 24 3600 365.2)))))
|
||||||
|
timestamp? 'updown))
|
||||||
|
;; Move back to initial position, but never beyond updated
|
||||||
|
;; clock.
|
||||||
|
(unless (< (point) origin)
|
||||||
|
(goto-char origin))))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-clock-cancel ()
|
(defun org-clock-cancel ()
|
||||||
|
|
Loading…
Reference in New Issue