From 6bbf74279c1e4f8c246bedb737318f02ddde75bd Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Sat, 18 Feb 2023 17:33:11 +0300 Subject: [PATCH] feat(emacs): org-mode alerts --- .emacs.d/init.el | 93 +++++++++++++++++++++++++++++++++++- Emacs.org | 120 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 211 insertions(+), 2 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 2b6b179..98c31e4 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -2172,6 +2172,7 @@ Returns ( . ) or nil." :after (lsp) :init (setq lsp-ltex-version "15.2.0") + :config (setq lsp-ltex-check-frequency "save")) (defun my/ltex-lang () @@ -2188,6 +2189,7 @@ Returns ( . ) or nil." ((string-match-p (rx "/home/pavel/" (+ alnum) ".org" eos) file-name) nil) ((string-match-p (rx (literal org-directory) "/" (or "roam" "inbox-notes" "literature-notes" "journal")) file-name) t) ((string-match-p (rx (literal org-directory)) file-name) nil) + ((string-match-p (rx (literal (expand-file-name user-emacs-directory))) file-name) nil) (t t)))) (defun my/text-mode-lsp-maybe () @@ -3057,7 +3059,12 @@ Returns ( . ) or nil." :if (not my/remote-server) :straight (:fetcher github :repo "alphapapa/org-ql" - :files (:defaults (:exclude "helm-org-ql.el")))) + :files (:defaults (:exclude "helm-org-ql.el"))) + :init + ;; See https://github.com/alphapapa/org-ql/pull/237 + (setq org-ql-regexp-part-ts-time + (rx " " (repeat 1 2 digit) ":" (repeat 2 digit) + (optional "-" (repeat 1 2 digit) ":" (repeat 2 digit))))) (use-package org-habit-stats :straight (:host github :repo "ml729/org-habit-stats") @@ -3125,6 +3132,90 @@ skip exactly those headlines that do not match." (org-agenda-prefix-format " %i %-12:c") (org-agenda-hide-tags-regexp "."))))))) +(setq my/org-alert-notify-times '(600 60)) + +(setq my/org-alert--alerts (make-hash-table :test #'equal)) + +(defun my/org-alert--is-scheduled (label time) + "Check if LABEL is scheduled to be shown an TIME." + (gethash (cons label time) + my/org-alert--alerts nil)) + +(defun my/org-alert--schedule (label time) + "Schedule LABEL to be shown at TIME, unless it's already scheduled." + (unless (my/org-alert--is-scheduled label time) + (puthash (cons label time) + (run-at-time time + nil + (lambda () + (alert label + :title "PROXIMITY ALERT"))) + my/org-alert--alerts))) + +(defun my/org-alert-cleanup (&optional keys) + "Unschedule items that do not appear in KEYS. + +KEYS is a list of cons cells like (