Starting out with org-roam

This commit is contained in:
Andrea Ciceri 2021-10-18 13:58:48 +02:00
parent b22971dbd5
commit a0a8a6e7cc
No known key found for this signature in database
GPG key ID: A1FC89532D1C5654
5 changed files with 82 additions and 17 deletions

View file

@ -33,7 +33,7 @@ jobs:
with: with:
name: aciceri-fleet name: aciceri-fleet
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- run: sed 's/#\(.*\)/\1/g' flake.nix # disabling outputs unsupported inside the GitHub action - run: sed -i 's/#\(.*\).*\#.* ga-uncomment/\1/g' flake.nix # disabling outputs unsupported inside the GitHub action
- run: nix -Lv flake check - run: nix -Lv flake check
- run: nix -Lv build ".#nixosConfigurations.pc.config.system.build.toplevel" - run: nix -Lv build ".#nixosConfigurations.pc.config.system.build.toplevel"
- run: nix -Lv develop -c echo OK - run: nix -Lv develop -c echo OK

View file

@ -21,6 +21,7 @@ emacsWithPackages (
helm-ag helm-ag
fira-code-mode fira-code-mode
org-superstar org-superstar
org-fragtog
org-roam org-roam
org-download org-download
visual-fill-column visual-fill-column

View file

@ -13,6 +13,7 @@
gsettings-desktop-schemas gsettings-desktop-schemas
lxappearance lxappearance
yarn yarn
texlive.combined.scheme-full
]; ];
}; };

View file

@ -4,10 +4,42 @@
(require 'org-protocol) (require 'org-protocol)
:custom :custom
(org-startup-folded 'fold) (org-startup-folded 'fold)
(org-agenda-files '("~/roam/"))
(org-ellipsis "")
(org-startup-indented nil)
(org-superstar-remove-leading-stars t)
(org-superstar-leading-bullet ?\s)
(org-indent-mode-turns-on-hiding-stars nil)
:hook :hook
((org-mode . auto-fill-mode) ;refill-mode breaks org headings ((org-mode . auto-fill-mode) ;refill-mode breaks org headings
(org-mode . (lambda () (org-superstar-mode 1))) (org-mode . org-num-mode)
(org-mode . prettify-symbols-mode))) (org-mode . (lambda ()
(dolist (face '((org-level-1 1.5)
(org-level-2 1.4)
(org-level-3 1.3)
(org-level-4 1.2)
(org-level-5 1.1)))
(set-face-attribute (car face) nil :weight 'semi-bold :height (cadr face)))))
(org-mode . prettify-symbols-mode))
:config
(org-indent-mode -1))
(use-package org-fragtog
:custom
(org-format-latex-options (plist-put org-format-latex-options :scale 1.6))
:hook
((org-mode . org-fragtog-mode)))
(use-package org-download
:hook
((org-mode . (lambda () (setq-local org-download-image-dir "~/roam/images/")))))
(use-package org-superstar
:custom
(org-superstar-special-todo-items t)
(org-superstar-headline-bullets-list '("\u200b"))
:hook
(('org-mode . (lambda () (org-superstar-mode 1)))))
(use-package org-download (use-package org-download
:hook :hook
@ -20,18 +52,11 @@
(org-roam-directory (file-truename "~/roam/")) (org-roam-directory (file-truename "~/roam/"))
(org-roam-graph-executable "dot") (org-roam-graph-executable "dot")
(org-roam-db-location (file-truename "roam/org-roam.db")) (org-roam-db-location (file-truename "roam/org-roam.db"))
(org-roam-node-display-template "${directories:10} ${tags:10} ${title:100} ${backlinkscount:6}")
(org-roam-capture-templates (org-roam-capture-templates
'( '(("d" "default" plain "\n%?" :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}") :unnarrowed t)))
("i" "incremental" plain :hook
#'org-roam-capture--get-point ((org-roam-mode . (lambda () (org-hide-properties))))
"${body}\n%?" ;; this reads from
; "%i%?"
:empty-lines-before 1
:file-name "web/${slug}"
:head "#+title: ${title}\n#+roam_key ${ref}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n\n"
:unnarrowed t)
("r" "roam-ref" plain #'org-roam-capture--get-point "%i%?" :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}"))))
:bind (("C-c n l" . org-roam-buffer-toggle) :bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find) ("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph) ("C-c n g" . org-roam-graph)
@ -40,8 +65,48 @@
;; Dailies ;; Dailies
("C-c n j" . org-roam-dailies-capture-today)) ("C-c n j" . org-roam-dailies-capture-today))
:config :config
(defun org-hide-properties ()
"Hide all org-mode headline property drawers in buffer. Could be slow if it has a lot of overlays."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward
"^ *:properties:\n\\( *:.+?:.*\n\\)+ *:end:\n" nil t)
(let ((ov_this (make-overlay (match-beginning 0) (match-end 0))))
(overlay-put ov_this 'display "")
(overlay-put ov_this 'hidden-prop-drawer t))))
(put 'org-toggle-properties-hide-state 'state 'hidden))
(defun org-show-properties ()
"Show all org-mode property drawers hidden by org-hide-properties."
(interactive)
(remove-overlays (point-min) (point-max) 'hidden-prop-drawer t)
(put 'org-toggle-properties-hide-state 'state 'shown))
(defun org-toggle-properties ()
"Toggle visibility of property drawers."
(interactive)
(if (eq (get 'org-toggle-properties-hide-state 'state) 'hidden)
(org-show-properties)
(org-hide-properties)))
(cl-defmethod org-roam-node-directories ((node org-roam-node))
(if-let ((dirs (file-name-directory (file-relative-name (org-roam-node-file node) org-roam-directory))))
(format "(%s)" (car (f-split dirs)))
""))
(cl-defmethod org-roam-node-backlinkscount ((node org-roam-node))
(let* ((count (caar (org-roam-db-query
[:select (funcall count source)
:from links
:where (= dest $s1)
:and (= type "id")]
(org-roam-node-id node)))))
(format "[%d]" count)))
(org-roam-db-autosync-mode) (org-roam-db-autosync-mode)
(require 'org-roam-protocol) (require 'org-roam-protocol))
(provide 'config-org) (provide 'config-org)

View file

@ -10,8 +10,6 @@
((ispell-program-name "hunspell") ((ispell-program-name "hunspell")
(ispell-dictionary "it_IT")) (ispell-dictionary "it_IT"))
:config :config
;(add-to-list 'ispell-hunspell-dictionary-alist '("italian-hunspell" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "it_IT") nil iso-8859-1))
;(add-to-list 'ispell-hunspell-dictionary-alist '("english-hunspell" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "en_US") nil iso-8859-1))
(defun switch-dictionary-it-en () (defun switch-dictionary-it-en ()
(interactive) (interactive)
(let* ((dict ispell-current-dictionary) (let* ((dict ispell-current-dictionary)