dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6da0bde10d70dc533ee948e48aa3436e8b9f0567
parent 69877b98f57839d85cbcbc0e4e992efdded440c6
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Sun, 16 Jan 2022 17:34:13 +0100

emacs: custom function to see time elapsed from timestamp at point

Diffstat:
Memacs/config.org | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/emacs/config.org b/emacs/config.org @@ -1018,6 +1018,36 @@ I want column view to look like this: (setq org-columns-default-format "%7TODO (To Do) %32ITEM(Task) %TAGS(Tags) %6CLOCKSUM(Clock) %8Effort(Effort){:}") #+end_src +*** Calculate time since timestamp +#+begin_src emacs-lisp + (defun my-org-time-since () + "Print the amount of time between the timestamp at point and the current date and time." + (interactive) + (unless (org-at-timestamp-p 'lax) + (user-error "Not at timestamp")) + + ;; We want to return to current location after the function runs + (save-mark-and-excursion + ;; find the end of the timestamp + (unless (member (char-before) '(?\] ?>)) + (re-search-forward "[\]>]")) + ;; save it + (push-mark) + ;; find the start of the timestamp + (re-search-backward "[\[<]") + ;; save the whole thing to the kill ring + (kill-ring-save (point) (mark)) + + ;; use a temp buffer to avoid corrupting current buffer + (with-temp-buffer + (insert (current-kill 0)) ; the timestamp that was yanked + (insert "--") ; range separator + (org-time-stamp '(16)) ; two prefix arguments insert current timestamp without prompting + (org-evaluate-time-range)) ; figure out the range between two timestamps + + ;; restore the previous kill-ring state + (rotate-yank-pointer 1))) +#+end_src ** Tempo expansions #+begin_src emacs-lisp