diff options
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/.config/emacs/emacs-custom.el | 2 | ||||
-rw-r--r-- | emacs/.config/emacs/init.el | 76 |
2 files changed, 74 insertions, 4 deletions
diff --git a/emacs/.config/emacs/emacs-custom.el b/emacs/.config/emacs/emacs-custom.el index 5aebc18..33f17ba 100644 --- a/emacs/.config/emacs/emacs-custom.el +++ b/emacs/.config/emacs/emacs-custom.el @@ -6,7 +6,7 @@ '(custom-safe-themes '("0340489fa0ccbfa05661bc5c8c19ee0ff95ab1d727e4cc28089b282d30df8fc8" "e3999eba4f25d912d7d61cbaaed1b551957e61da047279da89499d3bd1f1d007" "8d412c0ed46b865312d6df5c1dfd1821d349dd3cba00049cf88c4ad34403597e" "88267200889975d801f6c667128301af0bc183f3450c4b86138bfb23e8a78fb1" default)) '(package-selected-packages - '(anki-editor yasnippet org-pomodoro eshell-syntax-highlighting esh-help pcmpl-args exercism tidal haskell-mode diff-hl dts-mode clojure-mode unobtrusive-magit-theme ledger-mode nix-mode rustic tempel puni magit gcmh smudge helpful pdf-tools pcre2el repeat-help selected ace-mc expand-region idle-highlight-mode diredfl anzu direnv ob-async mixed-pitch deadgrep wgrep coterm doom-themes with-editor zenburn-theme yasnippet-snippets yaml-mode which-key undo-tree tabbar session rust-mode puppet-mode pod-mode notmuch muttrc-mode mutt-alias lsp-mode initsplit ido-completing-read+ htmlize graphviz-dot-mode goto-chg gitignore-mode gitconfig-mode gitattributes-mode git-modes folding flycheck ess eproject editorconfig diminish csv-mode color-theme-modern browse-kill-ring boxquote bm bar-cursor apache-mode projectile embark-consult)) + '(org-download anki-editor yasnippet org-pomodoro eshell-syntax-highlighting esh-help pcmpl-args exercism tidal haskell-mode diff-hl dts-mode clojure-mode unobtrusive-magit-theme ledger-mode nix-mode rustic tempel puni magit gcmh smudge helpful pdf-tools pcre2el repeat-help selected ace-mc expand-region idle-highlight-mode diredfl anzu direnv ob-async mixed-pitch deadgrep wgrep coterm doom-themes with-editor zenburn-theme yasnippet-snippets yaml-mode which-key undo-tree tabbar session rust-mode puppet-mode pod-mode notmuch muttrc-mode mutt-alias lsp-mode initsplit ido-completing-read+ htmlize graphviz-dot-mode goto-chg gitignore-mode gitconfig-mode gitattributes-mode git-modes folding flycheck ess eproject editorconfig diminish csv-mode color-theme-modern browse-kill-ring boxquote bm bar-cursor apache-mode projectile embark-consult)) '(safe-local-variable-values '((eval outline-hide-sublevels 2) (Package . CL-WHO) diff --git a/emacs/.config/emacs/init.el b/emacs/.config/emacs/init.el index 740481b..d33b8fd 100644 --- a/emacs/.config/emacs/init.el +++ b/emacs/.config/emacs/init.el @@ -65,6 +65,9 @@ (load custom-file :noerror t) +;; This should be on by default, but it doesn't work until reloaded for some reason. +(auto-compression-mode 1) + ;; Disable annoying warnings. (setq warning-minimum-level :error) @@ -518,7 +521,40 @@ ;;;;; Anki ;; (package-vc-install ;; '(anki-editor . (:url "https://github.com/anki-editor/anki-editor"))) -(use-package anki-editor :ensure nil) +(use-package anki-editor :ensure nil + :after org + :bind (:map org-mode-map + ("<f12>" . anki-editor-cloze-region-auto-incr) + ("<f11>" . anki-editor-cloze-region-dont-incr) + ("<f6>" . anki-editor-push-tree)) + :hook (org-capture-after-finalize . anki-editor-reset-cloze-number) ; Reset cloze-number after each capture. + :config + (setq anki-editor-create-decks t ;; Allow anki-editor to create a new deck if it doesn't exist + anki-editor-org-tags-as-anki-tags t) + + (defun anki-editor-cloze-region-auto-incr (&optional arg) + "Cloze region without hint and increase card number." + (interactive) + (anki-editor-cloze-region my-anki-editor-cloze-number "") + (setq my-anki-editor-cloze-number (1+ my-anki-editor-cloze-number)) + (forward-sexp)) + (defun anki-editor-cloze-region-dont-incr (&optional arg) + "Cloze region without hint using the previous card number." + (interactive) + (anki-editor-cloze-region (1- my-anki-editor-cloze-number) "") + (forward-sexp)) + (defun anki-editor-reset-cloze-number (&optional arg) + "Reset cloze number to ARG or 1" + (interactive) + (setq my-anki-editor-cloze-number (or arg 1))) + (defun anki-editor-push-tree () + "Push all notes under a tree." + (interactive) + (anki-editor-push-notes '(4)) + (anki-editor-reset-cloze-number)) + ;; Initialize + (anki-editor-reset-cloze-number)) + ;;;; Org mode (use-package org :config @@ -536,15 +572,49 @@ ("a" "Anki templates") ("ai" "Inbox basic" entry (file+headline "~/org/anki/inbox.org" "Inbox") - "* %T %^g\n:PROPERTIES:\n:ANKI_NOTE_TYPE: Basic\n:END:\n** Front\n%c%?\n** Back\n%x\n") + "* %T %^g\n:PROPERTIES:\n:ANKI_NOTE_TYPE: Basic\n:END:\n** Front\n%?\n** Back\n%x\n") ("as" "Sailing basic" entry (file+headline "~/org/anki/sailing.org" "Sailing") - "* %T\n:PROPERTIES:\n:ANKI_NOTE_TYPE: Basic\n:END:\n** Front\n%c%?\n** Back\n%x\n"))) + "* %T\n:PROPERTIES:\n:ANKI_NOTE_TYPE: Basic\n:END:\n** Front\n%?\n** Back\n%x\n") + ("az" "Sailing cloze" entry + (file+headline "~/org/anki/sailing.org" "Sailing") + "* %T\n:PROPERTIES:\n:ANKI_NOTE_TYPE: Cloze\n:END:\n** Text\n%x%?\n** Extra\n"))) ;; Install the link type (org-add-link-type "notmuch" 'org-notmuch-open) (add-hook 'org-store-link-functions 'org-notmuch-store-link) + (add-hook 'org-mode-hook + (defun kj/org-setup-media-handler () + (yank-media-handler "image/.*" #'kj/org--image-yank-media-handler))) + + (defun kj/org--image-yank-media-handler (mimetype data) + "Save image DATA of mime-type MIMETYPE and insert link at point. + It is saved as per `org-yank-image-save-type'. The name for the + image is prompted and the extension is automatically added to the + end." + (let* ((ext (symbol-name (mailcap-mime-type-to-extension mimetype))) + (iname (format-time-string "clipboard-%Y-%m-%d-%H:%M")) + (filename (file-name-with-extension iname ext)) + (absname (expand-file-name + filename + default-directory)) + link) + (with-temp-file absname + (insert data)) + (setq link (org-link-make-string + (concat "./" filename))) + (insert link))) + + (defun kj/org-screenshot () + (interactive) + (let* ((filename (format-time-string "screenshot-%Y-%m-%d-%H:%M:%S.png")) + (path (expand-file-name filename default-directory)) + (link (org-link-make-string (concat "file:" filename))) + (async-shell-command-display-buffer nil)) + (async-shell-command (format "grim -g \"$(slurp)\" %S" path)) + (insert link))) + (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) |