tzc icon indicating copy to clipboard operation
tzc copied to clipboard

When there is no selection, convert time or timestamp at point

Open gambhiro opened this issue 10 months ago • 1 comments

When using the package commands to convert times, it took me a few tries until I realized I have to select the time or timestamp.

It would be a helpful convenience if the conversion commands could work "at-point", I think other packages have trained us to expect that behaviour.

gambhiro avatar Apr 03 '24 06:04 gambhiro

Agreed, that'd be great. I was expecting tzc-convert-org-time-stamp-at-mark to work that way.

It's possible to get the timestamp at point with

(let* ((element (org-element-context))
         (type (org-element-type element)))
    (if (eq type 'timestamp)
        (org-element-property :raw-value element) ; this will return e.g. "<2024-09-05 to. 11:30-12:00 +1w>"
      (message "No timestamp at point")))

You can also use :begin and :end instead of :raw-value if you prefer to work with buffer positions.

unhammer avatar Sep 04 '24 07:09 unhammer