From a472043b74991edebf02a5bfc967801ab390fd83 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 10 Aug 2015 22:31:31 +0200 Subject: [PATCH 1/2] Fix ambiguous docstrings * lisp/org.el (org-at-date-range-p): (org-at-timestamp-p): Make match data explicit when returning a non-nil value. --- lisp/org.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b9fed4f4c..5817cac15 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -13147,7 +13147,14 @@ Returns the new TODO keyword, or nil if no state change should occur." (match-string 2)))) (defun org-at-date-range-p (&optional inactive-ok) - "Is the cursor inside a date range?" + "Non-nil if point is inside a date range. + +When optional argument INACTIVE-OK is non-nil, also consider +inactive time ranges. + +When this function returns a non-nil value, match data is set +according to `org-tr-regexp-both' or `org-tr-regexp', depending +on INACTIVE-OK." (interactive) (save-excursion (catch 'exit @@ -17864,7 +17871,14 @@ With prefix ARG, change that many days." (org-timestamp-change (- (prefix-numeric-value arg)) 'day) 'updown)) (defun org-at-timestamp-p (&optional inactive-ok) - "Determine if the cursor is in or at a timestamp." + "Non-nil if point is inside a timestamp. + +When optional argument INACTIVE-OK is non-nil, also consider +inactive timestamps. + +When this function returns a non-nil value, match data is set +according to `org-ts-regexp3' or `org-ts-regexp2', depending on +INACTIVE-OK." (interactive) (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2)) (pos (point)) From aa98f7c79a958da8adfc3788f564a1b387d3550d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 10 Aug 2015 22:32:24 +0200 Subject: [PATCH 2/2] Edit proper timestamp when on a time range * lisp/org.el (org-time-stamp): Offer appropriate default value depending on position of point in a time range. Reported-by: Christoph LANGE --- lisp/org.el | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5817cac15..cbc9f9b37 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -16638,13 +16638,10 @@ with the current time without prompting the user. When called from lisp, the timestamp is inactive if INACTIVE is non-nil." (interactive "P") - (let* ((ts - (cond ((org-at-date-range-p t) - (save-excursion - (goto-char (match-beginning 0)) - (looking-at (if inactive org-ts-regexp-both org-ts-regexp))) - (match-string 0)) - ((org-at-timestamp-p t) (match-string 0)))) + (let* ((ts (cond + ((org-at-date-range-p t) + (match-string (if (< (point) (- (match-beginning 2) 2)) 1 2))) + ((org-at-timestamp-p t) (match-string 0)))) ;; Default time is either the timestamp at point or today. ;; When entering a range, only the range start is considered. (default-time (if (not ts) (current-time)