In a previous post, we looked at a way to jump to a timestamp (post ). A limitation of that post was that our definition of "most recent" included timestamps in the future. Here we further constrain the definition to mean the most recent that is not in the future.
We will do that by getting the list of timestamps, then filtering out future ones.
Here is a list of time-stamps
Here is the code that filters out future timestamps. As I write this it is.
(let ((now (with-temp-buffer ;; sachac suggested this way to get a timestamp of "now" (org-insert-time-stamp (org-read-date t t ".") t) (buffer-string)))) (remove-if (lambda (entry) (org-time> (car entry) now)) (cl-sort (org-element-map (org-element-parse-buffer) 'timestamp (lambda (timestamp) (cons (org-element-property :raw-value timestamp) (org-element-property :begin timestamp)))) 'org-time> :key 'car)))
((. 811) ( . 613) ( . 593) ( . 712))
You can see that only past timestamps show up in the list, and they are sorted with the most recent timestamp. The
remove-if function is in 'cl, which is loaded in my init files. You may have to require that if you don't load it in your init files.
Copyright (C) 2014 by John Kitchin. See the License for information about copying.
Org-mode version = 8.2.7c