Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gambhiro opened this issue Apr 3, 2024 · 1 comment
Open

Comments

@gambhiro
Copy link

gambhiro commented Apr 3, 2024

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.

@unhammer
Copy link

unhammer commented Sep 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants