From a0a8a6e7ccfb166d88e13df7bae89acbdba5a88c Mon Sep 17 00:00:00 2001 From: aciceri Date: Mon, 18 Oct 2021 13:58:48 +0200 Subject: [PATCH] Starting out with org-roam --- .github/workflows/check.yml | 2 +- pkgs/emacs/default.nix | 1 + users/ccr/default.nix | 1 + .../emacs/emacs.d/config/config-org.el | 93 ++++++++++++++++--- .../emacs/emacs.d/config/config-spelling.el | 2 - 5 files changed, 82 insertions(+), 17 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2ee2395..2e3aee0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -33,7 +33,7 @@ jobs: with: name: aciceri-fleet 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 build ".#nixosConfigurations.pc.config.system.build.toplevel" - run: nix -Lv develop -c echo OK diff --git a/pkgs/emacs/default.nix b/pkgs/emacs/default.nix index b7380bf..8a031bd 100644 --- a/pkgs/emacs/default.nix +++ b/pkgs/emacs/default.nix @@ -21,6 +21,7 @@ emacsWithPackages ( helm-ag fira-code-mode org-superstar + org-fragtog org-roam org-download visual-fill-column diff --git a/users/ccr/default.nix b/users/ccr/default.nix index fb9ee37..0f7e56a 100644 --- a/users/ccr/default.nix +++ b/users/ccr/default.nix @@ -13,6 +13,7 @@ gsettings-desktop-schemas lxappearance yarn + texlive.combined.scheme-full ]; }; diff --git a/users/profiles/emacs/emacs.d/config/config-org.el b/users/profiles/emacs/emacs.d/config/config-org.el index 83dbf29..0b2ddff 100644 --- a/users/profiles/emacs/emacs.d/config/config-org.el +++ b/users/profiles/emacs/emacs.d/config/config-org.el @@ -4,10 +4,42 @@ (require 'org-protocol) :custom (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 ((org-mode . auto-fill-mode) ;refill-mode breaks org headings - (org-mode . (lambda () (org-superstar-mode 1))) - (org-mode . prettify-symbols-mode))) + (org-mode . org-num-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 :hook @@ -20,18 +52,11 @@ (org-roam-directory (file-truename "~/roam/")) (org-roam-graph-executable "dot") (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 - '( - ("i" "incremental" plain - #'org-roam-capture--get-point - "${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}")))) - + '(("d" "default" plain "\n%?" :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}") :unnarrowed t))) + :hook + ((org-roam-mode . (lambda () (org-hide-properties)))) :bind (("C-c n l" . org-roam-buffer-toggle) ("C-c n f" . org-roam-node-find) ("C-c n g" . org-roam-graph) @@ -40,8 +65,48 @@ ;; Dailies ("C-c n j" . org-roam-dailies-capture-today)) :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) - (require 'org-roam-protocol) + (require 'org-roam-protocol)) (provide 'config-org) diff --git a/users/profiles/emacs/emacs.d/config/config-spelling.el b/users/profiles/emacs/emacs.d/config/config-spelling.el index 37338bf..94cfa2c 100644 --- a/users/profiles/emacs/emacs.d/config/config-spelling.el +++ b/users/profiles/emacs/emacs.d/config/config-spelling.el @@ -10,8 +10,6 @@ ((ispell-program-name "hunspell") (ispell-dictionary "it_IT")) :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 () (interactive) (let* ((dict ispell-current-dictionary)