From 5b6224fa8f68a1b2e3ea083421043ab2bc76af77 Mon Sep 17 00:00:00 2001 From: cho Date: Sun, 18 Jun 2023 18:14:39 +0700 Subject: [PATCH] add doom emacs config --- home/default/.config/doom/config.el | 161 +++++++ home/default/.config/doom/init.el | 197 +++++++++ .../org-wild-notifier/org-wild-notifier.el | 406 ++++++++++++++++++ home/default/.config/doom/packages.el | 57 +++ 4 files changed, 821 insertions(+) create mode 100644 home/default/.config/doom/config.el create mode 100644 home/default/.config/doom/init.el create mode 100644 home/default/.config/doom/lisp/org-wild-notifier/org-wild-notifier.el create mode 100644 home/default/.config/doom/packages.el diff --git a/home/default/.config/doom/config.el b/home/default/.config/doom/config.el new file mode 100644 index 0000000..4bbe585 --- /dev/null +++ b/home/default/.config/doom/config.el @@ -0,0 +1,161 @@ +;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- + +;; Place your private configuration here! Remember, you do not need to run 'doom +;; sync' after modifying this file! + + +;; Some functionality uses this to identify you, e.g. GPG configuration, email +;; clients, file templates and snippets. It is optional. +(setq user-full-name "John Doe" + user-mail-address "john@doe.com") + +;; Doom exposes five (optional) variables for controlling fonts in Doom: +;; +;; - `doom-font' -- the primary font to use +;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable) +;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for +;; presentations or streaming. +;; - `doom-unicode-font' -- for unicode glyphs +;; - `doom-serif-font' -- for the `fixed-pitch-serif' face +;; +;; See 'C-h v doom-font' for documentation and more examples of what they +;; accept. For example: +;; +;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light) +;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13)) +;; +;; If you or Emacs can't find your font, use 'M-x describe-font' to look them +;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to +;; refresh your font settings. If Emacs still can't find your font, it likely +;; wasn't installed correctly. Font issues are rarely Doom issues! + +;; There are two ways to load a theme. Both assume the theme is installed and +;; available. You can either set `doom-theme' or manually load a theme with the +;; `load-theme' function. This is the default: +(setq doom-theme 'doom-one) + +;; This determines the style of line numbers in effect. If set to `nil', line +;; numbers are disabled. For relative line numbers, set this to `relative'. +(setq display-line-numbers-type t) + +;; If you use `org' and don't want your org files in the default location below, +;; change `org-directory'. It must be set before org loads! +(setq org-directory "~/notebook/") + + +;; Whenever you reconfigure a package, make sure to wrap your config in an +;; `after!' block, otherwise Doom's defaults may override your settings. E.g. +;; +;; (after! PACKAGE +;; (setq x y)) +;; +;; The exceptions to this rule: +;; +;; - Setting file/directory variables (like `org-directory') +;; - Setting variables which explicitly tell you to set them before their +;; package is loaded (see 'C-h v VARIABLE' to look up their documentation). +;; - Setting doom variables (which start with 'doom-' or '+'). +;; +;; Here are some additional functions/macros that will help you configure Doom. +;; +;; - `load!' for loading external *.el files relative to this one +;; - `use-package!' for configuring packages +;; - `after!' for running code after a package has loaded +;; - `add-load-path!' for adding directories to the `load-path', relative to +;; this file. Emacs searches the `load-path' when you load packages with +;; `require' or `use-package'. +;; - `map!' for binding new keys +;; +;; To get information about any of these functions/macros, move the cursor over +;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). +;; This will open documentation for it, including demos of how they are used. +;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces, +;; etc). +;; +;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how +;; they are implemented. + +;;; agenda files +;;(setq org-agenda-files '("~/calendar/calendar.org" +;; "~/notebook/agenda/" +;; "~/notebook/refile.org")) + + +(after! org + (setq org-log-done 'time) + + (use-package! org-journal + :init + (setq org-journal-dir "~/diary" + org-journal-date-prefix "#+TITLE: " + org-journal-time-prefix "+ " + org-journal-date-format "%a, %Y-%m-%d" + org-journal-file-format "%Y-%m-%d.org" + ) + ) + + (use-package! org-books + :init + (setq org-books-file "~/notebook/readinglist.org") + ) + + + ;; NOTIFICATIONS CONFIGURATION REFERENCE + ;;; note : it's probably better to add this after + ;;; setting org-agenda-files. + ;;; use this under (!after org ... + ;;; else it would't work + ; + ;(use-package! org-wild-notifier + ; :defer t + ; :init + ; (add-hook 'doom-post-init-hook (org-wild-notifier-mode)) + ; :config + ; (setq alert-default-style 'libnotify) + ;;; set to libnotify or notifications or osx-notifier + ; (setq org-wild-notifier-alert-time '(60 30)) + ;;; alert time defaults to '(10) if not set + ; (setq org-wild-notifier-keyword-whitelist nil)) + ; (setq org-wild-notifier-keyword-blacklist '("DONE")) + + (use-package! org-wild-notifier + :defer t + :init + (add-hook 'doom-post-init-hook (org-wild-notifier-mode)) + :config + (setq alert-default-style 'libnotify) + (setq org-wild-notifier-alert-time '(10 5)) + (setq org-wild-notifier-keyword-whitelist nil)) + (setq org-wild-notifier-keyword-blacklist '("DONE")) +) +;;; end of (!after org ... + +;;; for testing +(defun org-wild-notifier-debug () + "Collect debug information for org-wild-notifier" + (interactive) + (save-window-excursion + (let ((org-agenda-use-time-grid nil) + (org-agenda-compact-blocks t) + (org-agenda-window-setup 'current-window) + (org-agenda-buffer-name nil) + (org-agenda-buffer-tmp-name org-wild-notifier--agenda-buffer-name)) + + (org-agenda-list 2) + (message "registered events: %s \n blacklist: %s \n whitelist: %s \n" + (org-wild-notifier--retrieve-events) + org-wild-notifier-keyword-blacklist + org-wild-notifier-keyword-whitelist) + + (message "filtered events: %s" + (->> (org-wild-notifier--retrieve-events) + (-map 'org-wild-notifier--check-event))) + + + (kill-buffer)))) + +(defun org-wild-notifier-alert-test () + (interactive) + (alert "test") +) +;;; end diff --git a/home/default/.config/doom/init.el b/home/default/.config/doom/init.el new file mode 100644 index 0000000..42f033e --- /dev/null +++ b/home/default/.config/doom/init.el @@ -0,0 +1,197 @@ +;;; init.el -*- lexical-binding: t; -*- + +;; This file controls what Doom modules are enabled and what order they load +;; in. Remember to run 'doom sync' after modifying it! + +;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's +;; documentation. There you'll find a link to Doom's Module Index where all +;; of our modules are listed, including what flags they support. + +;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or +;; 'C-c c k' for non-vim users) to view its documentation. This works on +;; flags as well (those symbols that start with a plus). +;; +;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its +;; directory (for easy access to its source code). + +(doom! :input + ;;bidi ; (tfel ot) thgir etirw uoy gnipleh + ;;chinese + ;;japanese + ;;layout ; auie,ctsrnm is the superior home row + + :completion + company ; the ultimate code completion backend + ;;helm ; the *other* search engine for love and life + ;;ido ; the other *other* search engine... + ;;ivy ; a search engine for love and life + vertico ; the search engine of the future + + :ui + ;;deft ; notational velocity for Emacs + doom ; what makes DOOM look the way it does + doom-dashboard ; a nifty splash screen for Emacs + ;;doom-quit ; DOOM quit-message prompts when you quit Emacs + ;;(emoji +unicode) ; 🙂 + hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW + ;;hydra + ;;indent-guides ; highlighted indent columns + ;;ligatures ; ligatures and symbols to make your code pretty again + ;;minimap ; show a map of the code on the side + modeline ; snazzy, Atom-inspired modeline, plus API + ;;nav-flash ; blink cursor line after big motions + ;;neotree ; a project drawer, like NERDTree for vim + ophints ; highlight the region an operation acts on + (popup +defaults) ; tame sudden yet inevitable temporary windows + ;;tabs ; a tab bar for Emacs + ;;treemacs ; a project drawer, like neotree but cooler + ;;unicode ; extended unicode support for various languages + (vc-gutter +pretty) ; vcs diff in the fringe + vi-tilde-fringe ; fringe tildes to mark beyond EOB + ;;window-select ; visually switch windows + workspaces ; tab emulation, persistence & separate workspaces + ;;zen ; distraction-free coding or writing + + :editor + (evil +everywhere); come to the dark side, we have cookies + file-templates ; auto-snippets for empty files + fold ; (nigh) universal code folding + ;;(format +onsave) ; automated prettiness + ;;god ; run Emacs commands without modifier keys + ;;lispy ; vim for lisp, for people who don't like vim + ;;multiple-cursors ; editing in many places at once + ;;objed ; text object editing for the innocent + ;;parinfer ; turn lisp into python, sort of + ;;rotate-text ; cycle region at point between text candidates + snippets ; my elves. They type so I don't have to + ;;word-wrap ; soft wrapping with language-aware indent + + :emacs + dired ; making dired pretty [functional] + electric ; smarter, keyword-based electric-indent + ;;ibuffer ; interactive buffer management + undo ; persistent, smarter undo for your inevitable mistakes + vc ; version-control and Emacs, sitting in a tree + + :term + ;;eshell ; the elisp shell that works everywhere + ;;shell ; simple shell REPL for Emacs + ;;term ; basic terminal emulator for Emacs + ;;vterm ; the best terminal emulation in Emacs + + :checkers + syntax ; tasing you for every semicolon you forget + ;;(spell +flyspell) ; tasing you for misspelling mispelling + ;;grammar ; tasing grammar mistake every you make + + :tools + ;;ansible + ;;biblio ; Writes a PhD for you (citation needed) + ;;debugger ; FIXME stepping through code, to help you add bugs + ;;direnv + ;;docker + ;;editorconfig ; let someone else argue about tabs vs spaces + ;;ein ; tame Jupyter notebooks with emacs + (eval +overlay) ; run code, run (also, repls) + ;;gist ; interacting with github gists + lookup ; navigate your code and its documentation + ;;lsp ; M-x vscode + magit ; a git porcelain for Emacs + ;;make ; run make tasks from Emacs + ;;pass ; password manager for nerds + ;;pdf ; pdf enhancements + ;;prodigy ; FIXME managing external services & code builders + ;;rgb ; creating color strings + ;;taskrunner ; taskrunner for all your projects + ;;terraform ; infrastructure as code + ;;tmux ; an API for interacting with tmux + ;;tree-sitter ; syntax and parsing, sitting in a tree... + ;;upload ; map local to remote projects via ssh/ftp + + :os + (:if IS-MAC macos) ; improve compatibility with macOS + ;;tty ; improve the terminal Emacs experience + + :lang + ;;agda ; types of types of types of types... + ;;beancount ; mind the GAAP + ;;(cc +lsp) ; C > C++ == 1 + ;;clojure ; java with a lisp + ;;common-lisp ; if you've seen one lisp, you've seen them all + ;;coq ; proofs-as-programs + ;;crystal ; ruby at the speed of c + ;;csharp ; unity, .NET, and mono shenanigans + ;;data ; config/data formats + ;;(dart +flutter) ; paint ui and not much else + ;;dhall + ;;elixir ; erlang done right + ;;elm ; care for a cup of TEA? + emacs-lisp ; drown in parentheses + ;;erlang ; an elegant language for a more civilized age + ;;ess ; emacs speaks statistics + ;;factor + ;;faust ; dsp, but you get to keep your soul + ;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER) + ;;fsharp ; ML stands for Microsoft's Language + ;;fstar ; (dependent) types and (monadic) effects and Z3 + ;;gdscript ; the language you waited for + ;;(go +lsp) ; the hipster dialect + ;;(graphql +lsp) ; Give queries a REST + ;;(haskell +lsp) ; a language that's lazier than I am + ;;hy ; readability of scheme w/ speed of python + ;;idris ; a language you can depend on + ;;json ; At least it ain't XML + ;;(java +lsp) ; the poster child for carpal tunnel syndrome + ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) + ;;julia ; a better, faster MATLAB + ;;kotlin ; a better, slicker Java(Script) + ;;latex ; writing papers in Emacs has never been so fun + ;;lean ; for folks with too much to prove + ;;ledger ; be audit you can be + ;;lua ; one-based indices? one-based indices + markdown ; writing docs for people to ignore + ;;nim ; python + lisp at the speed of c + ;;nix ; I hereby declare "nix geht mehr!" + ;;ocaml ; an objective camel + (org + +journal + +habit + ) ; organize your plain life in plain text + ;;php ; perl's insecure younger brother + ;;plantuml ; diagrams for confusing people more + ;;purescript ; javascript, but functional + ;;python ; beautiful is better than ugly + ;;qt ; the 'cutest' gui framework ever + ;;racket ; a DSL for DSLs + ;;raku ; the artist formerly known as perl6 + ;;rest ; Emacs as a REST client + ;;rst ; ReST in peace + ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} + ;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() + ;;scala ; java, but good + ;;(scheme +guile) ; a fully conniving family of lisps + sh ; she sells {ba,z,fi}sh shells on the C xor + ;;sml + ;;solidity ; do you need a blockchain? No. + ;;swift ; who asked for emoji variables? + ;;terra ; Earth and Moon in alignment for performance. + ;;web ; the tubes + ;;yaml ; JSON, but readable + ;;zig ; C, but simpler + + :email + ;;(mu4e +org +gmail) + ;;notmuch + ;;(wanderlust +gmail) + + :app + ;;calendar + ;;emms + ;;everywhere ; *leave* Emacs!? You must be joking + ;;irc ; how neckbeards socialize + ;;(rss +org) ; emacs as an RSS reader + ;;twitter ; twitter client https://twitter.com/vnought + + :config + ;;literate + (default +bindings +smartparens)) diff --git a/home/default/.config/doom/lisp/org-wild-notifier/org-wild-notifier.el b/home/default/.config/doom/lisp/org-wild-notifier/org-wild-notifier.el new file mode 100644 index 0000000..9c58780 --- /dev/null +++ b/home/default/.config/doom/lisp/org-wild-notifier/org-wild-notifier.el @@ -0,0 +1,406 @@ +;;; org-wild-notifier.el --- Customizable org-agenda notifications -*- lexical-binding: t -*- + +;; Copyright (C) 2017 Artem Khramov + +;; Author: Artem Khramov +;; Created: 6 Jan 2017 +;; Version: 0.4.1 +;; Package-Requires: ((alert "1.2") (async "1.9.3") (dash "2.18.0") (emacs "24.4")) +;; Keywords: notification alert org org-agenda agenda +;; URL: https://github.com/akhramov/org-wild-notifier.el + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; This package provides notification functions for org-agenda. +;; +;; To perform a one-time check use `org-wild-notifier-check' +;; function. +;; To enable timer-based notifications please use +;;`org-wild-notifier-mode'. +;; Notification times can be customized either globally (for all org +;; entries) through `org-wild-notifier-alert-time' variable or on per +;; org entry basis using `WILD_NOTIFIER_NOTIFY_BEFORE` property, which +;; in turn is customizable via +;; `org-wild-notifier-alert-times-property' variable. +;; By default you get notifications about TODO events only. To +;; customize that behavior please use +;; `org-wild-notifier-keyword-whitelist' variable. In contrary, if +;; you don't want to receive notifications regarding certain events, +;; you can use `org-wild-notifier-keyword-blacklist' variable. + +;;; Code: + +(require 'dash) +(require 'alert) +(require 'async) +(require 'org-agenda) +(require 'cl-lib) + + +(defgroup org-wild-notifier nil + "org-wild-notifier customization options" + :group 'org) + +(defcustom org-wild-notifier-alert-time '(10) + "Time in minutes to get a notification about upcoming event. +Cannot be less than 1." + :package-version '(org-wild-notifier . "0.1.0") + :group 'org-wild-notifier + :type '(choice (integer :tag "Notify once") + (repeat integer))) + +(defcustom org-wild-notifier-alert-times-property "WILD_NOTIFIER_NOTIFY_BEFORE" + "Use this property in your agenda files to add additional notifications \ +to an event." + :package-version '(org-wild-notifier . "0.1.0") + :group 'org-wild-notifier + :type 'string) + +(defcustom org-wild-notifier-notification-title "Agenda" + "Notifications title." + :package-version '(org-wild-notifier . "0.1.0") + :group 'org-wild-notifier + :type 'string) + +(defcustom org-wild-notifier-notification-icon nil + "Path to notification icon file." + :package-version '(org-wild-notifier . "0.4.1") + :group 'org-wild-notifier + :type 'string) + +(defcustom org-wild-notifier-keyword-whitelist '("TODO") + "Receive notifications for these keywords only. +Leave this variable blank if you do not want to filter anything." + :package-version '(org-wild-notifier . "0.2.2") + :group 'org-wild-notifier + :type '(repeat string)) + +(defcustom org-wild-notifier-keyword-blacklist nil + "Never receive notifications for these keywords." + :package-version '(org-wild-notifier . "0.2.2") + :group 'org-wild-notifier + :type '(repeat string)) + +(defcustom org-wild-notifier-tags-whitelist nil + "Receive notifications for these tags only. +Leave this variable blank if you do not want to filter anything." + :package-version '(org-wild-notifier . "0.3.1") + :group 'org-wild-notifier + :type '(repeat string)) + +(defcustom org-wild-notifier-tags-blacklist nil + "Never receive notifications for these tags." + :package-version '(org-wild-notifier . "0.3.1") + :group 'org-wild-notifier + :type '(repeat string)) + +(defcustom org-wild-notifier--alert-severity 'medium + "Severity of the alert. +options: 'high 'medium 'low" + :package-version '(org-wild-notifier . "0.3.1") + :group 'org-wild-notifier + :type 'symbol + :options '(high medium low)) + +(defvar org-wild-notifier--day-wide-events nil + "If truthy, notifies about day-wide events.") + +(defvar org-wild-notifier--timer nil + "Timer value.") + +(defvar org-wild-notifier--process nil + "Currently-running async process.") + +(defvar org-wild-notifier--agenda-buffer-name "*org wild notifier affairs*" + "A name for temporary 'org-agenda' buffer.") + +(defvar org-wild-notifier--last-check-time (seconds-to-time 0) + "Last time checked for events.") + +(defun org-wild-notifier--time= (&rest list) + "Compare timestamps. +Comparison is performed by converted each element of LIST onto string +in order to ignore seconds." + (->> list + (--map (format-time-string "%d:%H:%M" it)) + (-uniq) + (length) + (= 1))) + +(defun org-wild-notifier--today () + "Get the timestamp for the beginning of current day." + (apply 'encode-time + (append '(0 0 0) (nthcdr 3 (decode-time (current-time)))))) + +(defun org-wild-notifier--always-notify-p (event) + "Check that notification for the EVENT should be done regardless of time. +For now, the only case that handled is day-wide events." + (when org-wild-notifier--day-wide-events + (let ((today (org-wild-notifier--today))) + ;; SPIKE: Org timestamps without "time" section are shorter than + ;; 16 characters. + (--any-p (and (<= (length (car it)) 16) (equal today (cdr it))) + (cadr (assoc 'times event)))))) + +(defun org-wild-notifier--timestamp-within-interval-p (timestamp interval) + "Check whether TIMESTAMP is within notification INTERVAL." + (org-wild-notifier--time= + (time-add (current-time) (seconds-to-time (* 60 interval))) + timestamp)) + +(defun org-wild-notifier--notifications (event) + "Get notifications for given EVENT. +Returns a list of notification intervals." + (if (org-wild-notifier--always-notify-p event) + '(-1) + + (->> `(,(cadr (assoc 'times event)) ,(cdr (assoc 'intervals event))) + (apply '-table-flat (lambda (ts int) `(,(cdr ts) ,int))) + (--filter (apply 'org-wild-notifier--timestamp-within-interval-p it)) + (-map 'cadr)))) + +(defun org-wild-notifier--time-left (seconds) + "Human-friendly representation for SECONDS." + (-> seconds + (pcase + ((pred (>= 0)) "right now") + ((pred (>= 3600)) "in %M") + (_ "in %H %M")) + + (format-seconds seconds))) + +(defun org-wild-notifier--get-hh-mm-from-org-time-string (time-string) + "Convert given org time-string TIME-STRING into string with 'hh:mm' format." + (if (>= (length time-string) 22) + (substring time-string 16 21) + "00:00")) + +(defun org-wild-notifier--notification-text (str-interval event) + "For given STR-INTERVAL list and EVENT get notification wording." + (format "%s at %s (%s)" + (cdr (assoc 'title event)) + (org-wild-notifier--get-hh-mm-from-org-time-string (car str-interval)) + (org-wild-notifier--time-left (* 60 (cdr str-interval))))) + +(defun org-wild-notifier--check-event (event) + "Get notifications for given EVENT. +Returns a list of notification messages" + (->> (org-wild-notifier--notifications event) + (--zip-with (cons (car it) other) (cadr (assoc 'times event))) + (--map (org-wild-notifier--notification-text it event)))) + +(defun org-wild-notifier--get-tags (marker) + "Retrieve tags of MARKER." + (-> (org-entry-get marker "TAGS") + (or "") + (org-split-string ":"))) + +(defun org-wild-notifier--whitelist-predicates () + (->> `([,org-wild-notifier-keyword-whitelist + (lambda (it) + (-contains-p org-wild-notifier-keyword-whitelist + (org-entry-get it "TODO")))] + + [,org-wild-notifier-tags-whitelist + (lambda (it) + (-intersection org-wild-notifier-tags-whitelist + (org-wild-notifier--get-tags it)))]) + (--filter (aref it 0)) + (--map (aref it 1)))) + +(defun org-wild-notifier--blacklist-predicates () + (->> `([,org-wild-notifier-keyword-blacklist + (lambda (it) + (-contains-p org-wild-notifier-keyword-blacklist + (org-entry-get it "TODO")))] + + [,org-wild-notifier-tags-blacklist + (lambda (it) + (-intersection org-wild-notifier-tags-blacklist + (org-wild-notifier--get-tags it)))]) + (--filter (aref it 0)) + (--map (aref it 1)))) + +(defun org-wild-notifier--apply-whitelist (markers) + "Apply whitelist to MARKERS." + (-if-let (whitelist-predicates (org-wild-notifier--whitelist-predicates)) + (-> (apply '-orfn whitelist-predicates) + (-filter markers)) + markers)) + +(defun org-wild-notifier--apply-blacklist (markers) + "Apply blacklist to MARKERS." + (-if-let (blacklist-predicates (org-wild-notifier--blacklist-predicates)) + (-> (apply '-orfn blacklist-predicates) + (-remove markers)) + markers)) + +(defun org-wild-notifier--retrieve-events () + "Get events from agenda view." + (let ((agenda-files (-filter 'file-exists-p (org-agenda-files))) + ;; Some package managers manipulate `load-path` variable. + (my-load-path load-path) + (todo-keywords org-todo-keywords) + (alert-time org-wild-notifier-alert-time) + (keyword-whitelist org-wild-notifier-keyword-whitelist) + (keyword-blacklist org-wild-notifier-keyword-blacklist) + (tags-whitelist org-wild-notifier-tags-whitelist) + (tags-blacklist org-wild-notifier-tags-blacklist)) + (lambda () + (setf org-agenda-use-time-grid nil) + (setf org-agenda-compact-blocks t) + (setf org-agenda-files agenda-files) + (setf load-path my-load-path) + (setf org-todo-keywords todo-keywords) + (setf org-wild-notifier-alert-time alert-time) + (setf org-wild-notifier-keyword-whitelist keyword-whitelist) + (setf org-wild-notifier-keyword-blacklist keyword-blacklist) + (setf org-wild-notifier-tags-whitelist tags-whitelist) + (setf org-wild-notifier-tags-blacklist tags-blacklist) + + (package-initialize) + (require 'org-wild-notifier) + + (org-agenda-list 2 + (org-read-date nil nil "today")) + + (->> (org-split-string (buffer-string) "\n") + (--map (plist-get + (org-fix-agenda-info (text-properties-at 0 it)) + 'org-marker)) + (-non-nil) + (org-wild-notifier--apply-whitelist) + (org-wild-notifier--apply-blacklist) + (-map 'org-wild-notifier--gather-info))))) + +(defun org-wild-notifier--notify (event-msg) + "Notify about an event using `alert' library. +EVENT-MSG is a string representation of the event." + (alert event-msg + :icon org-wild-notifier-notification-icon + :title org-wild-notifier-notification-title + :severity org-wild-notifier--alert-severity)) + +(defun org-wild-notifier--timestamp-parse (timestamp) + (let ((parsed (org-parse-time-string timestamp)) + (today (org-format-time-string "<%Y-%m-%d>"))) + ;; seconds-to-time returns also milliseconds and nanoseconds so we + ;; have to "trim" the list + (butlast + (seconds-to-time + (org-time-add + ;; we get the cycled absolute day (not hour and minutes) + (org-time-from-absolute (org-closest-date timestamp today 'past)) + ;; so we have to add the minutes too + (+ (* (decoded-time-hour parsed) 3600) + (* (decoded-time-minute parsed) 60)))) + 2) +)) + +(defun org-wild-notifier--extract-time (marker) + "Extract timestamps from MARKER. +Timestamps are extracted as cons cells. car holds org-formatted +string, cdr holds time in list-of-integer format." + (-non-nil + (--map + (let ((org-timestamp (org-entry-get marker it))) + (and org-timestamp + (cons org-timestamp + (org-wild-notifier--timestamp-parse org-timestamp)))) + '("DEADLINE" "SCHEDULED" "TIMESTAMP")))) + +(defun org-wild-notifier--extract-title (marker) + "Extract event title from MARKER. +MARKER acts like the event's identifier." + (org-with-point-at marker + (-let (((_lvl _reduced-lvl _todo _priority title _tags) + (org-heading-components))) + title))) + +(defun org-wild-notifier--extract-notication-intervals (marker) + "Extract notification intervals from the event's properties. +MARKER acts like the event's identifier. Resulting list also contains +standard notification interval (`org-wild-notifier-alert-time')." + `(,@(-flatten (list org-wild-notifier-alert-time)) + ,@(-map 'string-to-number + (org-entry-get-multivalued-property + marker + org-wild-notifier-alert-times-property)))) + +(defun org-wild-notifier--gather-info (marker) + "Collect information about an event. +MARKER acts like event's identifier." + `((times . (,(org-wild-notifier--extract-time marker))) + (title . ,(org-wild-notifier--extract-title marker)) + (intervals . ,(org-wild-notifier--extract-notication-intervals marker)))) + +(defun org-wild-notifier--stop () + "Stops the notification timer and cancel any in-progress checks." + (-some-> org-wild-notifier--timer (cancel-timer)) + (when org-wild-notifier--process + (interrupt-process org-wild-notifier--process) + (setq org-wild-notifier--process nil))) + +(defun org-wild-notifier--start () + "Start the notification timer. Cancel old one, if any. +Timer is scheduled on the beginning of every minute, so for +smoother experience this function also runs a check without timer." + (org-wild-notifier--stop) + + (let ((org-wild-notifier--day-wide-events t)) + (org-wild-notifier-check)) + + (--> (format-time-string "%H:%M" (time-add (current-time) 60)) + (run-at-time it 60 'org-wild-notifier-check) + (setf org-wild-notifier--timer it))) + +;;;###autoload +(defun org-wild-notifier-check () + "Parse agenda view and notify about upcoming events. + +Do nothing if a check is already in progress in the background." + (interactive) + + (unless (and org-wild-notifier--process + (process-live-p org-wild-notifier--process)) + (setq org-wild-notifier--process + (let ((default-directory user-emacs-directory)) + (async-start + (org-wild-notifier--retrieve-events) + (lambda (events) + (setq org-wild-notifier--process nil) + (-each + (->> events + (-map 'org-wild-notifier--check-event) + (-flatten) + (-uniq)) + 'org-wild-notifier--notify) + (setq org-wild-notifier--last-check-time (current-time)))))))) + +;;;###autoload +(define-minor-mode org-wild-notifier-mode + "Toggle org notifications globally. +When enabled parses your agenda once a minute and emits notifications +if needed." + :global + :lighter "Org Wild Notifier" + (if org-wild-notifier-mode + (org-wild-notifier--start) + (org-wild-notifier--stop))) + +(provide 'org-wild-notifier) + +;;; org-wild-notifier.el ends here diff --git a/home/default/.config/doom/packages.el b/home/default/.config/doom/packages.el new file mode 100644 index 0000000..270b31b --- /dev/null +++ b/home/default/.config/doom/packages.el @@ -0,0 +1,57 @@ +;; -*- no-byte-compile: t; -*- +;;; $DOOMDIR/packages.el + +;; To install a package with Doom you must declare them here and run 'doom sync' +;; on the command line, then restart Emacs for the changes to take effect -- or +;; use 'M-x doom/reload'. + + +;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: +;(package! some-package) + +;; To install a package directly from a remote git repo, you must specify a +;; `:recipe'. You'll find documentation on what `:recipe' accepts here: +;; https://github.com/radian-software/straight.el#the-recipe-format +;(package! another-package +; :recipe (:host github :repo "username/repo")) + +;; If the package you are trying to install does not contain a PACKAGENAME.el +;; file, or is located in a subdirectory of the repo, you'll need to specify +;; `:files' in the `:recipe': +;(package! this-package +; :recipe (:host github :repo "username/repo" +; :files ("some-file.el" "src/lisp/*.el"))) + +;; If you'd like to disable a package included with Doom, you can do so here +;; with the `:disable' property: +;(package! builtin-package :disable t) + +;; You can override the recipe of a built in package without having to specify +;; all the properties for `:recipe'. These will inherit the rest of its recipe +;; from Doom or MELPA/ELPA/Emacsmirror: +;(package! builtin-package :recipe (:nonrecursive t)) +;(package! builtin-package-2 :recipe (:repo "myfork/package")) + +;; Specify a `:branch' to install a package from a particular branch or tag. +;; This is required for some packages whose default branch isn't 'master' (which +;; our package manager can't deal with; see radian-software/straight.el#279) +;(package! builtin-package :recipe (:branch "develop")) + +;; Use `:pin' to specify a particular commit to install. +;(package! builtin-package :pin "1a2b3c4d5e") + + +;; Doom's packages are pinned to a specific commit and updated from release to +;; release. The `unpin!' macro allows you to unpin single packages... +;(unpin! pinned-package) +;; ...or multiple packages +;(unpin! pinned-package another-pinned-package) +;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) +;(unpin! t) + +;(package! org-wild-notifier :disable t) ;; currently using a customized version loaded locally +(package! org-books) + +;;; customized to support repeated tasks, see https://github.com/akhramov/org-wild-notifier.el/issues/41 +(package! org-wild-notifier + :recipe (:local-repo "$DOOMDIR/lisp/org-wild-notifier"))