From 92b9bb6ab3ad8e89b673040360a386428a471640 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 30 Jan 2023 12:14:12 +0100 Subject: [PATCH] moved roam function to proper place, minor change in org loading --- config.org | 191 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 79 deletions(-) diff --git a/config.org b/config.org index f71d22a..e47e406 100644 --- a/config.org +++ b/config.org @@ -778,26 +778,35 @@ When moving BAR to archive, it will go to FILENAME.org_archive below the heading [[http://doc.endlessparentheses.com/Var/org-archive-location.html][Other examples]] ** org #+BEGIN_SRC emacs-lisp -(defun me/org-roam-filter-by-tag (tag-name) - (lambda (node) - (member tag-name (org-roam-node-tags node)))) - -(defun me/org-roam-list-notes-by-tag (tag-name) - (mapcar #'org-roam-node-file - (seq-filter - (me/org-roam-filter-by-tag tag-name) - (org-roam-node-list)))) - -(defun me/org-roam-refresh-agenda-list () - "Add all org roam files with #+filetags: Project" - (interactive) -;; (setq org-agenda-files (me/org-roam-list-notes-by-tag "Project"))) - (nconc org-agenda-files - (me/org-roam-list-notes-by-tag "Project"))) +(defun me--buffer-prop-set (name value) + "Set a file property called NAME to VALUE in buffer file. +If the property is already set, replace its value." + (setq name (downcase name)) + (org-with-point-at 1 + (let ((case-fold-search t)) + (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)") + (point-max) t) + (replace-match (concat "#+" name ": " value) 'fixedcase) + (while (and (not (eobp)) + (looking-at "^[#:]")) + (if (save-excursion (end-of-line) (eobp)) + (progn + (end-of-line) + (insert "\n")) + (forward-line) + (beginning-of-line))) + (insert "#+" name ": " value "\n"))))) + +(defun me--buffer-prop-remove (name) + "Remove a buffer property called NAME." + (org-with-point-at 1 + (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)") + (point-max) t) + (replace-match "")))) + (use-package org - :ensure org-contrib - :pin gnu + :ensure t :mode (("\.org$" . org-mode)) :diminish org-indent-mode :defer t @@ -832,9 +841,6 @@ When moving BAR to archive, it will go to FILENAME.org_archive below the heading (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations") org-log-into-drawer "LOGBOOK") - ;; build the agenda list the first ime for the session - (me/org-roam-refresh-agenda-list) - ;; some display customizations (setq org-pretty-entities t org-startup-truncated t @@ -1055,66 +1061,93 @@ Bei Problemen wie unique constraint org-roam-db-clear-all org-roam-db-sync #+BEGIN_SRC emacs-lisp -(use-package org-roam - :ensure t - :defer t - :init - (setq org-roam-v2-ack t) - :config - (require 'org-roam-dailies) ;; ensure the keymap is available - (org-roam-db-autosync-mode) - :custom - (org-roam-directory MY--PATH_ORG_ROAM) - (org-roam-completion-everywhere t) - (org-roam-capture-templates - '(("d" "default" plain - "%?" - :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: ${title}\n") - :unnarrowed t) - ("n" "ndefault" plain - "%?" - :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: ${title}\n") - :unnarrowed t) - )) - :bind (("C-c n l" . org-roam-buffer-toggle) - ("C-c n f" . org-roam-node-find) - ("C-c n i" . org-roam-node-insert) - :map org-mode-map - ("C-M-i" . completion-at-point) - :map org-roam-dailies-map - ("Y" . org-roam-dailies-capture-yesterday) - ("T" . org-roam-dailies-capture-tomorrow)) - :bind-keymap - ("C-c n d" . org-roam-dailies-map)) - -(use-package org-roam - :if (eq *sys/windows* t) - :init - (setq exec-path (append exec-path '("P:/Tools/sqlite"))) - (use-package emacsql-sqlite3 + (use-package org-roam :ensure t + :defer t + :after org :init - (setq emacsql-sqlite3-binary "P:/Tools/sqlite/sqlite3.exe")) - :config - (add-to-list 'org-roam-capture-templates - '("t" "telephone call" plain - "%?" - :if-new (file+head "telephone/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") - :unnarrowed t) t) - (add-to-list 'org-roam-capture-templates - '("p" "new Project" plain - "** ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" - :target (file+olp "projects.org" ("Active"))) t) - (add-to-list 'org-roam-capture-templates - '("s" "Sicherheitenmeldung" plain - "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" - :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen"))) t) - (add-to-list 'org-roam-capture-templates - '("m" "Monatsbericht" plain' - "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" - :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))) t) - :custom - (org-roam-database-connector 'sqlite3)) + (setq org-roam-v2-ack t) + + (defun me--buffer-roam-note-p () + "Return non-nil if the currently visited buffer is a note." + (and buffer-file-name + (string-prefix-p + (expand-file-name (file-name-as-directory MY--PATH_ORG_ROAM)) + (file-name-directory buffer-file-name)))) + + (defun me/org-roam-filter-by-tag (tag-name) + (lambda (node) + (member tag-name (org-roam-node-tags node)))) + + (defun me/org-roam-list-notes-by-tag (tag-name) + (mapcar #'org-roam-node-file + (seq-filter + (me/org-roam-filter-by-tag tag-name) + (org-roam-node-list)))) + + (defun me/org-roam-refresh-agenda-list () + "Add all org roam files with #+filetags: Project" + (interactive) + (nconc org-agenda-files + (me/org-roam-list-notes-by-tag "Project"))) + :config + (require 'org-roam-dailies) ;; ensure the keymap is available + (org-roam-db-autosync-mode) + ;; build the agenda list the first ime for the session + (me/org-roam-refresh-agenda-list) + + :custom + (org-roam-directory MY--PATH_ORG_ROAM) + (org-roam-completion-everywhere t) + (org-roam-capture-templates + '(("d" "default" plain + "%?" + :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: ${title}\n") + :unnarrowed t) + ("n" "ndefault" plain + "%?" + :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: ${title}\n") + :unnarrowed t) + )) + :bind (("C-c n l" . org-roam-buffer-toggle) + ("C-c n f" . org-roam-node-find) + ("C-c n i" . org-roam-node-insert) + :map org-mode-map + ("C-M-i" . completion-at-point) + :map org-roam-dailies-map + ("Y" . org-roam-dailies-capture-yesterday) + ("T" . org-roam-dailies-capture-tomorrow)) + :bind-keymap + ("C-c n d" . org-roam-dailies-map)) + + (use-package org-roam + :if (eq *sys/windows* t) + :init + (setq exec-path (append exec-path '("P:/Tools/sqlite"))) + (use-package emacsql-sqlite3 + :ensure t + :init + (setq emacsql-sqlite3-binary "P:/Tools/sqlite/sqlite3.exe")) + :config + (add-to-list 'org-roam-capture-templates + '("t" "telephone call" plain + "%?" + :if-new (file+head "telephone/%<%Y%m%d%H%M%S>-${plug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") + :unnarrowed t) t) + (add-to-list 'org-roam-capture-templates + '("p" "new Project" plain + "** ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" + :target (file+olp "projects.org" ("Active"))) t) + (add-to-list 'org-roam-capture-templates + '("s" "Sicherheitenmeldung" plain + "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" + :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen"))) t) + (add-to-list 'org-roam-capture-templates + '("m" "Monatsbericht" plain' + "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" + :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))) t) + :custom + (org-roam-database-connector 'sqlite3)) #+END_SRC