dotfiles

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

commit 44c8346640e0e7310f9a6f5dd6361d3b42092749
parent f2d565b62000a91cb3d3a8edb7d909a09b27cf38
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Mon, 16 May 2022 14:56:09 +0200

emacs: org some jumping through hoops for completion at specific time

I want to be able to complete a task at a specific time if I did it
but I forgot to mark it as done. So I do a bit of function fuckery to
make that work.

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

diff --git a/emacs/config.org b/emacs/config.org @@ -759,6 +759,68 @@ Fix column alignment in agenda. (interactive) (kill-new (org-element-property :raw-link (org-element-context)))) #+end_src +**** Manipulating time +Sometimes I want to be able to close a TODO at a different time than /right now/. +So we'll have a buffer-local variable that controls whether we use /right now/ (if nil), or some other time (if set). + +***** The variable that controls it +#+begin_src emacs-lisp + (defvar-local za/org-current-time-effective nil) +#+end_src + +And a function to manipulate the variable: + +#+begin_src emacs-lisp + (defun za/set-org-current-time-effective () + "Set `current-time' in the current buffer for `org-todo'. + Use `keyboard-quit' to unset it." + (interactive) + (setq za/org-current-time-effective + (condition-case nil + (org-read-date t 'totime) + (quit nil)))) +#+end_src + +And a binding for that function: + +#+begin_src emacs-lisp + (za/global-set-key (kbd "C-c q t") #'za/set-org-current-time-effective) +#+end_src + +Now we have to modify the functions that get the date. + +***** Repeater in todo (e.g. .+1d) +For the repeater: + +#+begin_src emacs-lisp + (defun za/org-today-effective (old-org-today) + (if za/org-current-time-effective + (time-to-days za/org-current-time-effective) + (funcall old-org-today))) + + (advice-add 'org-today :around #'za/org-today-effective) +#+end_src + +***** Logging (e.g. logrepeat, with note -- the timestamp you see in the logbook) +#+begin_src emacs-lisp + (defun za/org-current-time-effective (old-org-current-time &rest args) + "Return the manually set effective time, or call the original function to get it." + (or za/org-current-time-effective + (funcall old-org-current-time args))) + + (advice-add 'org-current-time :around #'za/org-current-time-effective) + +#+end_src + +***** last_repeat property +#+begin_src emacs-lisp + (defun za/org-time-stamp-format-effective (old-org-time-stamp-format &rest args) + (if za/org-current-time-effective + (format-time-string (funcall old-org-time-stamp-format args) za/org-current-time-effective) + (funcall old-org-time-stamp-format args))) + (advice-add 'org-time-stamp-format :around #'za/org-time-stamp-format-effective) +#+end_src + *** Tempo expansions #+begin_src emacs-lisp