|
@@ -3550,100 +3550,97 @@ Assume point is at the beginning of the timestamp."
|
|
|
(defun org-element-timestamp-interpreter (timestamp contents)
|
|
|
"Interpret TIMESTAMP object as Org syntax.
|
|
|
CONTENTS is nil."
|
|
|
- ;; Use `:raw-value' if specified.
|
|
|
- (or (org-element-property :raw-value timestamp)
|
|
|
- ;; Otherwise, build timestamp string.
|
|
|
- (let* ((repeat-string
|
|
|
- (concat
|
|
|
- (case (org-element-property :repeater-type timestamp)
|
|
|
- (cumulate "+") (catch-up "++") (restart ".+"))
|
|
|
- (let ((val (org-element-property :repeater-value timestamp)))
|
|
|
- (and val (number-to-string val)))
|
|
|
- (case (org-element-property :repeater-unit timestamp)
|
|
|
- (hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
|
|
- (warning-string
|
|
|
- (concat
|
|
|
- (case (org-element-property :warning-type timestamp)
|
|
|
- (first "--")
|
|
|
- (all "-"))
|
|
|
- (let ((val (org-element-property :warning-value timestamp)))
|
|
|
- (and val (number-to-string val)))
|
|
|
- (case (org-element-property :warning-unit timestamp)
|
|
|
- (hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
|
|
- (build-ts-string
|
|
|
- ;; Build an Org timestamp string from TIME. ACTIVEP is
|
|
|
- ;; non-nil when time stamp is active. If WITH-TIME-P is
|
|
|
- ;; non-nil, add a time part. HOUR-END and MINUTE-END
|
|
|
- ;; specify a time range in the timestamp. REPEAT-STRING
|
|
|
- ;; is the repeater string, if any.
|
|
|
- (lambda (time activep &optional with-time-p hour-end minute-end)
|
|
|
- (let ((ts (format-time-string
|
|
|
- (funcall (if with-time-p 'cdr 'car)
|
|
|
- org-time-stamp-formats)
|
|
|
- time)))
|
|
|
- (when (and hour-end minute-end)
|
|
|
- (string-match "[012]?[0-9]:[0-5][0-9]" ts)
|
|
|
- (setq ts
|
|
|
- (replace-match
|
|
|
- (format "\\&-%02d:%02d" hour-end minute-end)
|
|
|
- nil nil ts)))
|
|
|
- (unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
|
|
|
- (dolist (s (list repeat-string warning-string))
|
|
|
- (when (org-string-nw-p s)
|
|
|
- (setq ts (concat (substring ts 0 -1)
|
|
|
- " "
|
|
|
- s
|
|
|
- (substring ts -1)))))
|
|
|
- ;; Return value.
|
|
|
- ts)))
|
|
|
- (type (org-element-property :type timestamp)))
|
|
|
- (case type
|
|
|
- ((active inactive)
|
|
|
- (let* ((minute-start (org-element-property :minute-start timestamp))
|
|
|
- (minute-end (org-element-property :minute-end timestamp))
|
|
|
- (hour-start (org-element-property :hour-start timestamp))
|
|
|
- (hour-end (org-element-property :hour-end timestamp))
|
|
|
- (time-range-p (and hour-start hour-end minute-start minute-end
|
|
|
- (or (/= hour-start hour-end)
|
|
|
- (/= minute-start minute-end)))))
|
|
|
- (funcall
|
|
|
- build-ts-string
|
|
|
- (encode-time 0
|
|
|
- (or minute-start 0)
|
|
|
- (or hour-start 0)
|
|
|
- (org-element-property :day-start timestamp)
|
|
|
- (org-element-property :month-start timestamp)
|
|
|
- (org-element-property :year-start timestamp))
|
|
|
- (eq type 'active)
|
|
|
- (and hour-start minute-start)
|
|
|
- (and time-range-p hour-end)
|
|
|
- (and time-range-p minute-end))))
|
|
|
- ((active-range inactive-range)
|
|
|
- (let ((minute-start (org-element-property :minute-start timestamp))
|
|
|
- (minute-end (org-element-property :minute-end timestamp))
|
|
|
- (hour-start (org-element-property :hour-start timestamp))
|
|
|
- (hour-end (org-element-property :hour-end timestamp)))
|
|
|
- (concat
|
|
|
- (funcall
|
|
|
- build-ts-string (encode-time
|
|
|
- 0
|
|
|
- (or minute-start 0)
|
|
|
- (or hour-start 0)
|
|
|
- (org-element-property :day-start timestamp)
|
|
|
- (org-element-property :month-start timestamp)
|
|
|
- (org-element-property :year-start timestamp))
|
|
|
- (eq type 'active-range)
|
|
|
- (and hour-start minute-start))
|
|
|
- "--"
|
|
|
- (funcall build-ts-string
|
|
|
- (encode-time 0
|
|
|
- (or minute-end 0)
|
|
|
- (or hour-end 0)
|
|
|
- (org-element-property :day-end timestamp)
|
|
|
- (org-element-property :month-end timestamp)
|
|
|
- (org-element-property :year-end timestamp))
|
|
|
- (eq type 'active-range)
|
|
|
- (and hour-end minute-end)))))))))
|
|
|
+ (let* ((repeat-string
|
|
|
+ (concat
|
|
|
+ (case (org-element-property :repeater-type timestamp)
|
|
|
+ (cumulate "+") (catch-up "++") (restart ".+"))
|
|
|
+ (let ((val (org-element-property :repeater-value timestamp)))
|
|
|
+ (and val (number-to-string val)))
|
|
|
+ (case (org-element-property :repeater-unit timestamp)
|
|
|
+ (hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
|
|
+ (warning-string
|
|
|
+ (concat
|
|
|
+ (case (org-element-property :warning-type timestamp)
|
|
|
+ (first "--")
|
|
|
+ (all "-"))
|
|
|
+ (let ((val (org-element-property :warning-value timestamp)))
|
|
|
+ (and val (number-to-string val)))
|
|
|
+ (case (org-element-property :warning-unit timestamp)
|
|
|
+ (hour "h") (day "d") (week "w") (month "m") (year "y"))))
|
|
|
+ (build-ts-string
|
|
|
+ ;; Build an Org timestamp string from TIME. ACTIVEP is
|
|
|
+ ;; non-nil when time stamp is active. If WITH-TIME-P is
|
|
|
+ ;; non-nil, add a time part. HOUR-END and MINUTE-END
|
|
|
+ ;; specify a time range in the timestamp. REPEAT-STRING is
|
|
|
+ ;; the repeater string, if any.
|
|
|
+ (lambda (time activep &optional with-time-p hour-end minute-end)
|
|
|
+ (let ((ts (format-time-string
|
|
|
+ (funcall (if with-time-p 'cdr 'car)
|
|
|
+ org-time-stamp-formats)
|
|
|
+ time)))
|
|
|
+ (when (and hour-end minute-end)
|
|
|
+ (string-match "[012]?[0-9]:[0-5][0-9]" ts)
|
|
|
+ (setq ts
|
|
|
+ (replace-match
|
|
|
+ (format "\\&-%02d:%02d" hour-end minute-end)
|
|
|
+ nil nil ts)))
|
|
|
+ (unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
|
|
|
+ (dolist (s (list repeat-string warning-string))
|
|
|
+ (when (org-string-nw-p s)
|
|
|
+ (setq ts (concat (substring ts 0 -1)
|
|
|
+ " "
|
|
|
+ s
|
|
|
+ (substring ts -1)))))
|
|
|
+ ;; Return value.
|
|
|
+ ts)))
|
|
|
+ (type (org-element-property :type timestamp)))
|
|
|
+ (case type
|
|
|
+ ((active inactive)
|
|
|
+ (let* ((minute-start (org-element-property :minute-start timestamp))
|
|
|
+ (minute-end (org-element-property :minute-end timestamp))
|
|
|
+ (hour-start (org-element-property :hour-start timestamp))
|
|
|
+ (hour-end (org-element-property :hour-end timestamp))
|
|
|
+ (time-range-p (and hour-start hour-end minute-start minute-end
|
|
|
+ (or (/= hour-start hour-end)
|
|
|
+ (/= minute-start minute-end)))))
|
|
|
+ (funcall
|
|
|
+ build-ts-string
|
|
|
+ (encode-time 0
|
|
|
+ (or minute-start 0)
|
|
|
+ (or hour-start 0)
|
|
|
+ (org-element-property :day-start timestamp)
|
|
|
+ (org-element-property :month-start timestamp)
|
|
|
+ (org-element-property :year-start timestamp))
|
|
|
+ (eq type 'active)
|
|
|
+ (and hour-start minute-start)
|
|
|
+ (and time-range-p hour-end)
|
|
|
+ (and time-range-p minute-end))))
|
|
|
+ ((active-range inactive-range)
|
|
|
+ (let ((minute-start (org-element-property :minute-start timestamp))
|
|
|
+ (minute-end (org-element-property :minute-end timestamp))
|
|
|
+ (hour-start (org-element-property :hour-start timestamp))
|
|
|
+ (hour-end (org-element-property :hour-end timestamp)))
|
|
|
+ (concat
|
|
|
+ (funcall
|
|
|
+ build-ts-string (encode-time
|
|
|
+ 0
|
|
|
+ (or minute-start 0)
|
|
|
+ (or hour-start 0)
|
|
|
+ (org-element-property :day-start timestamp)
|
|
|
+ (org-element-property :month-start timestamp)
|
|
|
+ (org-element-property :year-start timestamp))
|
|
|
+ (eq type 'active-range)
|
|
|
+ (and hour-start minute-start))
|
|
|
+ "--"
|
|
|
+ (funcall build-ts-string
|
|
|
+ (encode-time 0
|
|
|
+ (or minute-end 0)
|
|
|
+ (or hour-end 0)
|
|
|
+ (org-element-property :day-end timestamp)
|
|
|
+ (org-element-property :month-end timestamp)
|
|
|
+ (org-element-property :year-end timestamp))
|
|
|
+ (eq type 'active-range)
|
|
|
+ (and hour-end minute-end))))))))
|
|
|
|
|
|
(defun org-element-timestamp-successor ()
|
|
|
"Search for the next timestamp object.
|