[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org 97a235cf1c: org-clock-timestamps-change: Pr
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org 97a235cf1c: org-clock-timestamps-change: Preserve point position |
Date: |
Fri, 13 Jan 2023 04:57:59 -0500 (EST) |
branch: externals-release/org
commit 97a235cf1cd029920b0a7dbcdc300abd7215499c
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
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
---
lisp/org-clock.el | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 4e72141cdc..55372e5649 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1800,17 +1800,25 @@ Optional argument N tells to change by that many units."
(time-subtract
(org-time-string-to-time org-last-changed-timestamp)
(org-time-string-to-time ts)))
- (save-excursion
- (goto-char begts)
- (org-timestamp-change
- (round (/ (float-time tdiff)
- (pcase timestamp?
- (`minute 60)
- (`hour 3600)
- (`day (* 24 3600))
- (`month (* 24 3600 31))
- (`year (* 24 3600 365.2)))))
- timestamp? 'updown)))))))
+ ;; `save-excursion' won't work because
+ ;; `org-timestamp-change' deletes and re-inserts the
+ ;; timestamp.
+ (let ((origin (point)))
+ (save-excursion
+ (goto-char begts)
+ (org-timestamp-change
+ (round (/ (float-time tdiff)
+ (pcase timestamp?
+ (`minute 60)
+ (`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
(defun org-clock-cancel ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals-release/org 97a235cf1c: org-clock-timestamps-change: Preserve point position,
ELPA Syncer <=