yeet
This commit is contained in:
42
.config/emacs/modules/lang/org/contrib/brain.el
Normal file
42
.config/emacs/modules/lang/org/contrib/brain.el
Normal file
@@ -0,0 +1,42 @@
|
||||
;;; lang/org/contrib/brain.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +brain)
|
||||
|
||||
(use-package! org-brain
|
||||
:defer t
|
||||
:init
|
||||
(setq org-brain-visualize-default-choices 'all
|
||||
org-brain-title-max-length 24
|
||||
org-brain-include-file-entries nil
|
||||
org-brain-file-entries-use-title nil)
|
||||
|
||||
:config
|
||||
(set-popup-rule! "^\\*org-brain"
|
||||
:side 'right :size 1.00 :select t :quit nil :ttl nil)
|
||||
|
||||
(cl-pushnew '("b" "Brain" plain (function org-brain-goto-end)
|
||||
"* %i%?" :empty-lines 1)
|
||||
org-capture-templates
|
||||
:key #'car :test #'equal)
|
||||
|
||||
(when (featurep! :editor evil +everywhere)
|
||||
;; TODO Make a proper evil keybind scheme for org-brain
|
||||
;; REVIEW This should be handled upstream by evil-collection
|
||||
(set-evil-initial-state!
|
||||
'(org-brain-visualize-mode
|
||||
org-brain-select-map
|
||||
org-brain-move-map
|
||||
org-brain-polymode-map)
|
||||
'normal)
|
||||
(defun +org--evilify-map (map)
|
||||
(let (keys)
|
||||
(map-keymap (lambda (event function)
|
||||
(push function keys)
|
||||
(push (vector event) keys))
|
||||
map)
|
||||
(apply #'evil-define-key* 'normal map keys)))
|
||||
|
||||
(+org--evilify-map org-brain-visualize-mode-map)
|
||||
(+org--evilify-map org-brain-select-map)
|
||||
(+org--evilify-map org-brain-move-map)
|
||||
(after! polymode
|
||||
(+org--evilify-map org-brain-polymode-map))))
|
||||
68
.config/emacs/modules/lang/org/contrib/dragndrop.el
Normal file
68
.config/emacs/modules/lang/org/contrib/dragndrop.el
Normal file
@@ -0,0 +1,68 @@
|
||||
;;; lang/org/contrib/dragndrop.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +dragndrop)
|
||||
|
||||
(use-package! org-download
|
||||
:commands
|
||||
org-download-dnd
|
||||
org-download-yank
|
||||
org-download-screenshot
|
||||
org-download-clipboard
|
||||
org-download-dnd-base64
|
||||
:init
|
||||
;; HACK We add these manually so that org-download is truly lazy-loaded
|
||||
(pushnew! dnd-protocol-alist
|
||||
'("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd)
|
||||
'("^data:" . org-download-dnd-base64))
|
||||
(advice-add #'org-download-enable :override #'ignore)
|
||||
|
||||
(after! org
|
||||
;; A shorter link to attachments
|
||||
(+org-define-basic-link "download" (lambda () (or org-download-image-dir org-attach-id-dir "."))
|
||||
:image-data-fun #'+org-image-file-data-fn
|
||||
:requires 'org-download))
|
||||
:config
|
||||
(unless org-download-image-dir
|
||||
(setq org-download-image-dir org-attach-id-dir))
|
||||
(setq org-download-method 'attach
|
||||
org-download-timestamp "_%Y%m%d_%H%M%S"
|
||||
org-download-screenshot-method
|
||||
(cond (IS-MAC "screencapture -i %s")
|
||||
(IS-LINUX
|
||||
(cond ((executable-find "maim") "maim -s %s")
|
||||
((executable-find "scrot") "scrot -s %s")
|
||||
((executable-find "gnome-screenshot") "gnome-screenshot -a -f %s"))))
|
||||
|
||||
org-download-heading-lvl nil
|
||||
org-download-link-format "[[download:%s]]\n"
|
||||
org-download-annotate-function (lambda (_link) "")
|
||||
org-download-link-format-function
|
||||
(lambda (filename)
|
||||
(if (eq org-download-method 'attach)
|
||||
(format "[[attachment:%s]]\n"
|
||||
(org-link-escape
|
||||
(file-relative-name filename (org-attach-dir))))
|
||||
;; Handle non-image files a little differently. Images should be
|
||||
;; inserted as normal with previews. Other files, like pdfs or zips,
|
||||
;; should be linked to, with an icon indicating the type of file.
|
||||
(format (concat (unless (image-type-from-file-name filename)
|
||||
(concat (+org-attach-icon-for filename)
|
||||
" "))
|
||||
org-download-link-format)
|
||||
(org-link-escape
|
||||
(funcall org-download-abbreviate-filename-function filename)))))
|
||||
org-download-abbreviate-filename-function
|
||||
(lambda (path)
|
||||
(if (file-in-directory-p path org-download-image-dir)
|
||||
(file-relative-name path org-download-image-dir)
|
||||
path)))
|
||||
|
||||
(defadvice! +org--dragndrop-then-display-inline-images-a (_link filename)
|
||||
:after #'org-download-insert-link
|
||||
(when (image-type-from-file-name filename)
|
||||
(save-excursion
|
||||
(org-display-inline-images
|
||||
t t
|
||||
(progn (org-back-to-heading t) (point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp))) (backward-char 1))
|
||||
(point)))))))
|
||||
41
.config/emacs/modules/lang/org/contrib/ipython.el
Normal file
41
.config/emacs/modules/lang/org/contrib/ipython.el
Normal file
@@ -0,0 +1,41 @@
|
||||
;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +ipython)
|
||||
|
||||
(use-package! ob-ipython
|
||||
:defer t
|
||||
:init
|
||||
(defvar +ob-ipython-local-runtime-dir nil)
|
||||
|
||||
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
|
||||
|
||||
(add-hook! '+org-babel-load-functions
|
||||
(defun +org-babel-load-ipython-h (lang)
|
||||
(and (string-prefix-p "jupyter-" (symbol-name lang))
|
||||
(require 'ob-ipython nil t))))
|
||||
|
||||
(after! org-src
|
||||
(add-to-list 'org-src-lang-modes '("ipython" . python)))
|
||||
(after! ox-latex
|
||||
(add-to-list 'org-latex-minted-langs '(ipython "python")))
|
||||
:config
|
||||
(set-popup-rules!
|
||||
'(("\\*ob-ipython.*"
|
||||
:slot 2 :side right :size 100 :height 0.2
|
||||
:select nil :quit nil :ttl nil)
|
||||
("^ \\*Python"
|
||||
:slot 0 :side right :size 100
|
||||
:select nil :quit nil :ttl nil)))
|
||||
|
||||
;; advices for remote kernel and org-src-edit
|
||||
(advice-add #'ob-ipython--create-repl :override #'+org-ob-ipython-create-repl-a)
|
||||
(advice-add #'org-babel-edit-prep:ipython :override #'+org-babel-edit-prep:ipython-a)
|
||||
(advice-add #'org-babel-execute:ipython :before #'+org-babel-execute:ipython-a)
|
||||
(advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a)
|
||||
|
||||
;; retina resolution image hack
|
||||
(when IS-MAC
|
||||
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
|
||||
|
||||
;; ipython has its own async keyword, disable ipython in ob-async.
|
||||
(after! ob-async
|
||||
(add-to-list 'ob-async-no-async-languages-alist "ipython")))
|
||||
71
.config/emacs/modules/lang/org/contrib/journal.el
Normal file
71
.config/emacs/modules/lang/org/contrib/journal.el
Normal file
@@ -0,0 +1,71 @@
|
||||
;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +journal)
|
||||
|
||||
(use-package! org-journal
|
||||
:defer t
|
||||
:init
|
||||
;; HACK `org-journal' adds a `magic-mode-alist' entry for detecting journal
|
||||
;; files, but this causes us lazy loaders a big problem: an unacceptable
|
||||
;; delay on the first file the user opens, because calling the autoloaded
|
||||
;; `org-journal-is-journal' pulls all of `org' with it. So, we replace it
|
||||
;; with our own, extra layer of heuristics.
|
||||
(add-to-list 'magic-mode-alist '(+org-journal-p . org-journal-mode))
|
||||
|
||||
(defun +org-journal-p ()
|
||||
"Wrapper around `org-journal-is-journal' to lazy load `org-journal'."
|
||||
(when-let (buffer-file-name (buffer-file-name (buffer-base-buffer)))
|
||||
(if (or (featurep 'org-journal)
|
||||
(and (file-in-directory-p
|
||||
buffer-file-name (expand-file-name org-journal-dir org-directory))
|
||||
(require 'org-journal nil t)))
|
||||
(org-journal-is-journal))))
|
||||
|
||||
;; `org-journal-dir' defaults to "~/Documents/journal/", which is an odd
|
||||
;; default, so we change it to {org-directory}/journal (we expand it after
|
||||
;; org-journal is loaded).
|
||||
(setq org-journal-dir "journal/"
|
||||
org-journal-cache-file (concat doom-cache-dir "org-journal"))
|
||||
|
||||
:config
|
||||
;; Remove the orginal journal file detector and rely on `+org-journal-p'
|
||||
;; instead, to avoid loading org-journal until the last possible moment.
|
||||
(setq magic-mode-alist (assq-delete-all 'org-journal-is-journal magic-mode-alist))
|
||||
|
||||
;; `org-journal' can't deal with symlinks, so resolve them here.
|
||||
(setq org-journal-dir (expand-file-name org-journal-dir org-directory)
|
||||
;; Doom opts for an "open in a popup or here" strategy as a default.
|
||||
;; Open in "other window" is less predictable, and can replace a window
|
||||
;; we wanted to keep visible.
|
||||
org-journal-find-file #'find-file)
|
||||
|
||||
;; Setup carryover to include all configured TODO states. We cannot carry over
|
||||
;; [ ] keywords because `org-journal-carryover-items's syntax cannot correctly
|
||||
;; interpret it as anything other than a date.
|
||||
(setq org-journal-carryover-items "TODO=\"TODO\"|TODO=\"PROJ\"|TODO=\"STRT\"|TODO=\"WAIT\"|TODO=\"HOLD\"")
|
||||
|
||||
(set-company-backend! 'org-journal-mode 'company-capf 'company-dabbrev)
|
||||
|
||||
(map! (:map org-journal-mode-map
|
||||
:n "]f" #'org-journal-next-entry
|
||||
:n "[f" #'org-journal-previous-entry
|
||||
:n "C-n" #'org-journal-next-entry
|
||||
:n "C-p" #'org-journal-previous-entry)
|
||||
(:map org-journal-search-mode-map
|
||||
"C-n" #'org-journal-search-next
|
||||
"C-p" #'org-journal-search-previous)
|
||||
:localleader
|
||||
(:map org-journal-mode-map
|
||||
"c" #'org-journal-new-entry
|
||||
"d" #'org-journal-new-date-entry
|
||||
"n" #'org-journal-next-entry
|
||||
"p" #'org-journal-previous-entry
|
||||
(:prefix "s"
|
||||
"s" #'org-journal-search
|
||||
"f" #'org-journal-search-forever
|
||||
"F" #'org-journal-search-future
|
||||
"w" #'org-journal-search-calendar-week
|
||||
"m" #'org-journal-search-calendar-month
|
||||
"y" #'org-journal-search-calendar-year))
|
||||
(:map org-journal-search-mode-map
|
||||
"n" #'org-journal-search-next
|
||||
"p" #'org-journal-search-prev)))
|
||||
40
.config/emacs/modules/lang/org/contrib/jupyter.el
Normal file
40
.config/emacs/modules/lang/org/contrib/jupyter.el
Normal file
@@ -0,0 +1,40 @@
|
||||
;;; lang/org/contrib/jupyter.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +jupyter)
|
||||
|
||||
(use-package! ob-jupyter
|
||||
:defer t
|
||||
:init
|
||||
(after! ob-async
|
||||
(pushnew! ob-async-no-async-languages-alist
|
||||
"jupyter-python"
|
||||
"jupyter-julia"
|
||||
"jupyter-R"))
|
||||
|
||||
(after! org-src
|
||||
(dolist (lang '(python julia R))
|
||||
(cl-pushnew (cons (format "jupyter-%s" lang) lang)
|
||||
org-src-lang-modes :key #'car)))
|
||||
|
||||
(add-hook! '+org-babel-load-functions
|
||||
(defun +org-babel-load-jupyter-h (lang)
|
||||
(when (string-prefix-p "jupyter-" (symbol-name lang))
|
||||
(require 'jupyter)
|
||||
(let* ((lang-name (symbol-name lang))
|
||||
(lang-tail (string-remove-prefix "jupyter-" lang-name)))
|
||||
(and (not (assoc lang-tail org-src-lang-modes))
|
||||
(require (intern (format "ob-%s" lang-tail))
|
||||
nil t)
|
||||
(add-to-list 'org-src-lang-modes (cons lang-name (intern lang-tail)))))
|
||||
(with-demoted-errors "Jupyter: %s"
|
||||
(require lang nil t)
|
||||
(require 'ob-jupyter nil t)))))
|
||||
:config
|
||||
(defadvice! +org--ob-jupyter-initiate-session-a (&rest _)
|
||||
:after #'org-babel-jupyter-initiate-session
|
||||
(unless (bound-and-true-p jupyter-org-interaction-mode)
|
||||
(jupyter-org-interaction-mode)))
|
||||
|
||||
;; Remove text/html since it's not human readable
|
||||
(delq! :text/html jupyter-org-mime-types)
|
||||
|
||||
(require 'tramp))
|
||||
14
.config/emacs/modules/lang/org/contrib/noter.el
Normal file
14
.config/emacs/modules/lang/org/contrib/noter.el
Normal file
@@ -0,0 +1,14 @@
|
||||
;;; lang/org/contrib/noter.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +noter)
|
||||
|
||||
(use-package! org-noter
|
||||
:defer t
|
||||
:preface
|
||||
;; Allow the user to preempt this and set the document search path
|
||||
;; If not set then use `org-directory'
|
||||
(defvar org-noter-notes-search-path nil)
|
||||
:config
|
||||
(unless org-noter-notes-search-path
|
||||
(setq org-noter-notes-search-path (list org-directory)))
|
||||
(setq org-noter-auto-save-last-location t
|
||||
org-noter-separate-notes-from-heading t))
|
||||
17
.config/emacs/modules/lang/org/contrib/pomodoro.el
Normal file
17
.config/emacs/modules/lang/org/contrib/pomodoro.el
Normal file
@@ -0,0 +1,17 @@
|
||||
;;; lang/org/contrib/pomodoro.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +pomodoro)
|
||||
|
||||
(after! org-pomodoro
|
||||
;; prefer PulseAudio to ALSA in $current_year
|
||||
(setq org-pomodoro-audio-player (or (executable-find "paplay")
|
||||
org-pomodoro-audio-player))
|
||||
|
||||
;; configure pomodoro alerts to use growl or libnotify
|
||||
(alert-add-rule :category "org-pomodoro"
|
||||
:style (cond (alert-growl-command
|
||||
'growl)
|
||||
(alert-notifier-command
|
||||
'notifier)
|
||||
(alert-libnotify-command
|
||||
'libnotify)
|
||||
(alert-default-style))))
|
||||
67
.config/emacs/modules/lang/org/contrib/present.el
Normal file
67
.config/emacs/modules/lang/org/contrib/present.el
Normal file
@@ -0,0 +1,67 @@
|
||||
;;; lang/org/contrib/present.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +present)
|
||||
|
||||
(defvar +org-present-text-scale 5
|
||||
"The `text-scale-amount' for `org-tree-slide-mode'.")
|
||||
|
||||
(defvar +org-present-hide-first-heading nil
|
||||
"If non-nil, hide the top-level heading for the current slide.
|
||||
|
||||
Some presenters think the first level heading takes up too much space, or use
|
||||
them as slide names, rather than titles. Instead, you can use second level
|
||||
headings as titles, and you have more freedom to place them wherever you like.")
|
||||
|
||||
|
||||
(after! ox
|
||||
(add-to-list 'org-export-backends 'beamer))
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! org-re-reveal
|
||||
:after ox
|
||||
:config
|
||||
(setq org-re-reveal-root (expand-file-name "../../" (locate-library "dist/reveal.js" t))
|
||||
org-re-reveal-revealjs-version "4"))
|
||||
|
||||
|
||||
(use-package! org-tree-slide
|
||||
:commands org-tree-slide-mode
|
||||
:config
|
||||
(org-tree-slide-simple-profile)
|
||||
(setq org-tree-slide-activate-message " "
|
||||
org-tree-slide-deactivate-message " "
|
||||
org-tree-slide-modeline-display nil
|
||||
org-tree-slide-heading-emphasis t)
|
||||
|
||||
(add-hook 'org-tree-slide-after-narrow-hook #'org-display-inline-images)
|
||||
(add-hook 'org-tree-slide-mode-hook #'+org-present-prettify-slide-h)
|
||||
(add-hook 'org-tree-slide-play-hook #'+org-present-hide-blocks-h)
|
||||
|
||||
(when (featurep! :editor evil)
|
||||
(map! :map org-tree-slide-mode-map
|
||||
:n [C-right] #'org-tree-slide-move-next-tree
|
||||
:n [C-left] #'org-tree-slide-move-previous-tree)
|
||||
(add-hook 'org-tree-slide-mode-hook #'evil-normalize-keymaps))
|
||||
|
||||
(defadvice! +org-present--hide-first-heading-maybe-a (fn &rest args)
|
||||
"Omit the first heading if `+org-present-hide-first-heading' is non-nil."
|
||||
:around #'org-tree-slide--display-tree-with-narrow
|
||||
(letf! (defun org-narrow-to-subtree ()
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(org-with-limited-levels
|
||||
(narrow-to-region
|
||||
(progn
|
||||
(when (org-before-first-heading-p)
|
||||
(org-next-visible-heading 1))
|
||||
(ignore-errors (org-up-heading-all 99))
|
||||
(when +org-present-hide-first-heading
|
||||
(forward-line 1))
|
||||
(point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp)))
|
||||
(backward-char 1))
|
||||
(point)))))))
|
||||
(apply fn args))))
|
||||
24
.config/emacs/modules/lang/org/contrib/pretty.el
Normal file
24
.config/emacs/modules/lang/org/contrib/pretty.el
Normal file
@@ -0,0 +1,24 @@
|
||||
;;; lang/org/contrib/pretty.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +pretty)
|
||||
(after! org
|
||||
(setq org-highlight-latex-and-related '(native script entities)))
|
||||
|
||||
|
||||
(use-package! org-superstar ; "prettier" bullets
|
||||
:hook (org-mode . org-superstar-mode)
|
||||
:config
|
||||
;; Make leading stars truly invisible, by rendering them as spaces!
|
||||
(setq org-superstar-leading-bullet ?\s
|
||||
org-superstar-leading-fallback ?\s
|
||||
org-hide-leading-stars nil
|
||||
org-superstar-todo-bullet-alist
|
||||
'(("TODO" . 9744)
|
||||
("[ ]" . 9744)
|
||||
("DONE" . 9745)
|
||||
("[X]" . 9745))))
|
||||
|
||||
|
||||
(use-package! org-fancy-priorities ; priority icons
|
||||
:hook (org-mode . org-fancy-priorities-mode)
|
||||
:hook (org-agenda-mode . org-fancy-priorities-mode)
|
||||
:config (setq org-fancy-priorities-list '("⚑" "⬆" "■")))
|
||||
96
.config/emacs/modules/lang/org/contrib/roam.el
Normal file
96
.config/emacs/modules/lang/org/contrib/roam.el
Normal file
@@ -0,0 +1,96 @@
|
||||
;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +roam)
|
||||
|
||||
(defvar +org-roam-open-buffer-on-find-file t
|
||||
"If non-nil, open the org-roam buffer when opening an org roam file.")
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! org-roam
|
||||
:hook (org-load . +org-init-roam-maybe-h)
|
||||
:hook (org-roam-backlinks-mode . turn-on-visual-line-mode)
|
||||
:commands (org-roam-buffer-toggle-display
|
||||
org-roam-dailies-find-date
|
||||
org-roam-dailies-find-today
|
||||
org-roam-dailies-find-tomorrow
|
||||
org-roam-dailies-find-yesterday)
|
||||
:preface
|
||||
;; Set this to nil so we can later detect if the user has set custom values
|
||||
;; for these variables. If not, default values will be set in the :config
|
||||
;; section.
|
||||
(defvar org-roam-directory nil)
|
||||
(defvar org-roam-db-location nil)
|
||||
:init
|
||||
(map! :after org
|
||||
:map org-mode-map
|
||||
:localleader
|
||||
:prefix ("m" . "org-roam")
|
||||
"b" #'org-roam-switch-to-buffer
|
||||
"f" #'org-roam-find-file
|
||||
"g" #'org-roam-graph
|
||||
"i" #'org-roam-insert
|
||||
"I" #'org-roam-insert-immediate
|
||||
"m" #'org-roam
|
||||
"t" #'org-roam-tag-add
|
||||
"T" #'org-roam-tag-delete
|
||||
(:prefix ("d" . "by date")
|
||||
:desc "Find previous note" "b" #'org-roam-dailies-find-previous-note
|
||||
:desc "Find date" "d" #'org-roam-dailies-find-date
|
||||
:desc "Find next note" "f" #'org-roam-dailies-find-next-note
|
||||
:desc "Find tomorrow" "m" #'org-roam-dailies-find-tomorrow
|
||||
:desc "Capture today" "n" #'org-roam-dailies-capture-today
|
||||
:desc "Find today" "t" #'org-roam-dailies-find-today
|
||||
:desc "Capture Date" "v" #'org-roam-dailies-capture-date
|
||||
:desc "Find yesterday" "y" #'org-roam-dailies-find-yesterday
|
||||
:desc "Find directory" "." #'org-roam-dailies-find-directory))
|
||||
:config
|
||||
(defun +org-init-roam-maybe-h ()
|
||||
"Activate `org-roam-mode'. If it fails, fail gracefully."
|
||||
(unless (with-demoted-errors "ORG ROAM ERROR: %s"
|
||||
(org-roam-mode +1)
|
||||
t)
|
||||
(message "To try reinitializing org-roam, run 'M-x org-roam-mode'")
|
||||
(org-roam-mode -1)))
|
||||
|
||||
(setq org-roam-directory
|
||||
(file-name-as-directory
|
||||
(file-truename
|
||||
(expand-file-name (or org-roam-directory "roam")
|
||||
org-directory)))
|
||||
org-roam-db-location (or org-roam-db-location
|
||||
(concat doom-etc-dir "org-roam.db"))
|
||||
;; Make org-roam buffer sticky; i.e. don't replace it when opening a
|
||||
;; file with an *-other-window command.
|
||||
org-roam-buffer-window-parameters '((no-delete-other-windows . t))
|
||||
org-roam-link-use-custom-faces 'everywhere
|
||||
org-roam-completion-everywhere t
|
||||
org-roam-completion-system
|
||||
(cond ((featurep! :completion helm) 'helm)
|
||||
((featurep! :completion ivy) 'ivy)
|
||||
((featurep! :completion ido) 'ido)
|
||||
('default)))
|
||||
|
||||
;; Normally, the org-roam buffer doesn't open until you explicitly call
|
||||
;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the
|
||||
;; org-roam buffer will be opened for you when you use `org-roam-find-file'
|
||||
;; (but not `find-file', to limit the scope of this behavior).
|
||||
(add-hook! 'find-file-hook
|
||||
(defun +org-roam-open-buffer-maybe-h ()
|
||||
(and +org-roam-open-buffer-on-find-file
|
||||
(memq 'org-roam-buffer--update-maybe post-command-hook)
|
||||
(not (window-parameter nil 'window-side)) ; don't proc for popups
|
||||
(not (eq 'visible (org-roam-buffer--visibility)))
|
||||
(with-current-buffer (window-buffer)
|
||||
(org-roam-buffer--get-create)))))
|
||||
|
||||
;; Hide the mode line in the org-roam buffer, since it serves no purpose. This
|
||||
;; makes it easier to distinguish from other org buffers.
|
||||
(add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode))
|
||||
|
||||
|
||||
;; Since the org module lazy loads org-protocol (waits until an org URL is
|
||||
;; detected), we can safely chain `org-roam-protocol' to it.
|
||||
(use-package! org-roam-protocol
|
||||
:after org-protocol)
|
||||
185
.config/emacs/modules/lang/org/contrib/roam2.el
Normal file
185
.config/emacs/modules/lang/org/contrib/roam2.el
Normal file
@@ -0,0 +1,185 @@
|
||||
;;; lang/org/contrib/roam2.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +roam2)
|
||||
|
||||
(defvar +org-roam-open-buffer-on-find-file t
|
||||
"If non-nil, open the org-roam buffer when opening an org roam file.")
|
||||
|
||||
(defvar +org-roam-link-to-org-use-id 'create-if-interactive
|
||||
"`org-roam-directory' local value for `org-id-link-to-org-use-id'.
|
||||
It's not recommended to set this to nil in order for other parts
|
||||
of org-mode to properly utilize ID links.")
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! org-roam
|
||||
:hook (org-load . +org-init-roam-h)
|
||||
:preface
|
||||
;; Set this to nil so we can later detect if the user has set custom values
|
||||
;; for these variables. If not, default values will be set in the :config
|
||||
;; section.
|
||||
(defvar org-roam-directory nil)
|
||||
(defvar org-roam-db-location nil)
|
||||
|
||||
:init
|
||||
(doom-load-packages-incrementally
|
||||
'(ansi-color dash f rx seq magit-section emacsql emacsql-sqlite))
|
||||
|
||||
;; Don't display warning message dedicated for v1 users. Need to be set early.
|
||||
(setq org-roam-v2-ack t)
|
||||
|
||||
(defadvice! +org-roam-suppress-sqlite-build-a (fn &rest args)
|
||||
"Suppress automatic building of sqlite3 binary when loading `org-roam'.
|
||||
This is a blocking operation that can take a while to complete
|
||||
and better be deferred when there will be an actual demand for
|
||||
the database. See `+org-init-roam-h' for the launch process."
|
||||
:around #'emacsql-sqlite-ensure-binary
|
||||
(if (not (boundp 'org-roam-db-version))
|
||||
(apply fn args)
|
||||
(advice-remove #'emacsql-sqlite-ensure-binary #'+org-roam-suppress-sqlite-build-a)
|
||||
nil))
|
||||
|
||||
:config
|
||||
(defun +org-init-roam-h ()
|
||||
"Setup `org-roam' but don't immediately initialize its database.
|
||||
Instead, initialize it when it will be actually needed."
|
||||
(letf! ((#'org-roam-db-sync #'ignore))
|
||||
(org-roam-setup))
|
||||
(defadvice! +org-roam-try-init-db-a (&rest _)
|
||||
"Try to initialize org-roam database at the last possible safe moment.
|
||||
In case of failure, fail gracefully."
|
||||
:before #'org-roam-db-query
|
||||
(message "Initializing org-roam database...")
|
||||
(let ((run-cleanup-p t))
|
||||
(unwind-protect
|
||||
;; Try to build the binary if it doesn't exist. In case of failure
|
||||
;; this will error, run the cleanup and exit, and in case of success
|
||||
;; this will return nil and sync the database.
|
||||
(setq run-cleanup-p (emacsql-sqlite-ensure-binary))
|
||||
(when run-cleanup-p
|
||||
(setq org-roam--sqlite-available-p nil)
|
||||
(org-roam-teardown)
|
||||
(message (concat "EmacSQL failied to build SQLite binary for org-roam; "
|
||||
"see *Compile-Log* buffer for details.\n"
|
||||
"To try reinitialize org-roam, run \"M-x org-roam-setup\"")))))
|
||||
(advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a)
|
||||
(org-roam-db-sync)))
|
||||
|
||||
(setq org-roam-directory
|
||||
(thread-first (or org-roam-directory "roam")
|
||||
(expand-file-name org-directory)
|
||||
(file-truename)
|
||||
(file-name-as-directory))
|
||||
org-roam-db-location
|
||||
(or org-roam-db-location
|
||||
(concat doom-etc-dir "org-roam.db"))
|
||||
org-roam-node-display-template
|
||||
"${doom-hierarchy:*} ${doom-tags:45}"
|
||||
org-roam-completion-everywhere t
|
||||
org-roam-mode-section-functions
|
||||
#'(org-roam-backlinks-section
|
||||
org-roam-reflinks-section))
|
||||
|
||||
(setq-hook! 'org-roam-find-file-hook
|
||||
org-id-link-to-org-use-id +org-roam-link-to-org-use-id)
|
||||
|
||||
;; Normally, the org-roam buffer doesn't open until you explicitly call
|
||||
;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the
|
||||
;; org-roam buffer will be opened for you whenever you visit a file in
|
||||
;; `org-roam-directory'.
|
||||
(add-hook! 'org-roam-find-file-hook :append
|
||||
(defun +org-roam-open-with-buffer-maybe-h ()
|
||||
(and +org-roam-open-buffer-on-find-file
|
||||
(not org-roam-capture--node) ;; don't proc for roam capture buffers
|
||||
(not org-capture-mode) ;; don't proc for normal capture buffers
|
||||
(not (eq 'visible (org-roam-buffer--visibility)))
|
||||
(org-roam-buffer-toggle))))
|
||||
|
||||
(set-popup-rules!
|
||||
`((,(regexp-quote org-roam-buffer) ; persistent org-roam buffer
|
||||
:side right :width .33 :height .5 :ttl nil :modeline nil :quit nil :slot 1)
|
||||
("^\\*org-roam: " ; node dedicated org-roam buffer
|
||||
:side right :width .33 :height .5 :ttl nil :modeline nil :quit nil :slot 2)))
|
||||
|
||||
(add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode)
|
||||
|
||||
(map! (:map org-mode-map
|
||||
:localleader
|
||||
:prefix ("m" . "org-roam")
|
||||
"D" #'org-roam-demote-entire-buffer
|
||||
"f" #'org-roam-node-find
|
||||
"F" #'org-roam-ref-find
|
||||
"g" #'org-roam-graph
|
||||
"i" #'org-roam-node-insert
|
||||
"I" #'org-id-get-create
|
||||
"m" #'org-roam-buffer-toggle
|
||||
"M" #'org-roam-buffer-display-dedicated
|
||||
"n" #'org-roam-capture
|
||||
"r" #'org-roam-refile
|
||||
"R" #'org-roam-link-replace-all
|
||||
(:prefix ("d" . "by date")
|
||||
:desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note
|
||||
:desc "Goto date" "d" #'org-roam-dailies-goto-date
|
||||
:desc "Capture date" "D" #'org-roam-dailies-capture-date
|
||||
:desc "Goto next note" "f" #'org-roam-dailies-goto-next-note
|
||||
:desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow
|
||||
:desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow
|
||||
:desc "Capture today" "n" #'org-roam-dailies-capture-today
|
||||
:desc "Goto today" "t" #'org-roam-dailies-goto-today
|
||||
:desc "Capture today" "T" #'org-roam-dailies-capture-today
|
||||
:desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday
|
||||
:desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday
|
||||
:desc "Find directory" "-" #'org-roam-dailies-find-directory)
|
||||
(:prefix ("o" . "node properties")
|
||||
"a" #'org-roam-alias-add
|
||||
"A" #'org-roam-alias-remove
|
||||
"t" #'org-roam-tag-add
|
||||
"T" #'org-roam-tag-remove
|
||||
"r" #'org-roam-ref-add
|
||||
"R" #'org-roam-ref-remove)))
|
||||
|
||||
(when (featurep! :editor evil +everywhere)
|
||||
(add-hook! 'org-roam-mode-hook
|
||||
(defun +org-roam-detach-magit-section-mode-map-h ()
|
||||
"Detach `magit-section-mode-map' from `org-roam-mode-map'.
|
||||
Inheriting its keymaps introduces a lot of conflicts in
|
||||
`org-roam-mode' based buffers, where Evil and leader keybindings
|
||||
will become completely overridden. This is because `magit-section'
|
||||
uses 'keymap text-property to attach section-unique keymaps, which
|
||||
has a higher level of precedence than `emulation-mode-map-alists'.
|
||||
|
||||
Note: We do this each time through the hook, because otherwise
|
||||
sections seems to ignore the detachment."
|
||||
(set-keymap-parent org-roam-mode-map nil)))
|
||||
|
||||
(map! :map org-roam-mode-map
|
||||
:nv "]" #'magit-section-forward-sibling
|
||||
:nv "[" #'magit-section-backward-sibling
|
||||
:nv "gj" #'magit-section-forward-sibling
|
||||
:nv "gk" #'magit-section-backward-sibling
|
||||
:nv "gr" #'revert-buffer
|
||||
:nv "gR" #'revert-buffer
|
||||
:nv "z1" #'magit-section-show-level-1
|
||||
:nv "z2" #'magit-section-show-level-2
|
||||
:nv "z3" #'magit-section-show-level-3
|
||||
:nv "z4" #'magit-section-show-level-4
|
||||
:nv "za" #'magit-section-toggle
|
||||
:nv "zc" #'magit-section-hide
|
||||
:nv "zC" #'magit-section-hide-children
|
||||
:nv "zo" #'magit-section-show
|
||||
:nv "zO" #'magit-section-show-children
|
||||
:nv "zr" #'magit-section-show-level-4-all
|
||||
:nv "C-j" #'magit-section-forward
|
||||
:nv "C-k" #'magit-section-backward
|
||||
:g "M-p" #'magit-section-backward-sibling
|
||||
:g "M-n" #'magit-section-forward-sibling
|
||||
:g [tab] #'magit-section-toggle
|
||||
:g [C-tab] #'magit-section-cycle
|
||||
:g [backtab] #'magit-section-cycle-global)))
|
||||
|
||||
|
||||
;; Since the org module lazy loads org-protocol (waits until an org URL is
|
||||
;; detected), we can safely chain `org-roam-protocol' to it.
|
||||
(use-package! org-roam-protocol
|
||||
:after org-protocol)
|
||||
Reference in New Issue
Block a user