5 Commits

1 changed files with 55 additions and 429 deletions
Split View
  1. 484
      config.org

484
config.org

@ -1220,162 +1220,6 @@ https://github.com/jwiegley/use-package/issues/319
:map org-mode-map ("S-<right>" . org-shiftright)
("S-<left>" . org-shiftleft))
:init
(defun my--org-files-with-tag (dir tag)
"Return a list of .org files in DIR recursively that have a #+FILETAGS: TAG."
(let ((files (directory-files-recursively dir "\\.org$"))
(tag-re (format "^#\\+filetags:.*\\:%s\\:" (regexp-quote tag))))
(seq-filter
(lambda (file)
(with-temp-buffer
(insert-file-contents file nil 0 1000)
(goto-char (point-min))
(re-search-forward tag-re nil t)))
files)))
(defun my--org-agenda-files-update ()
"Update `org-agenda-files` from MY--PATH_ORG_FILES based on file tag :agenda:."
(when (derived-mode-p 'org-mode)
(setq org-agenda-files (my--org-files-with-tag MY--PATH_ORG_FILES "agenda"))))
(defun my--todo-p ()
"Return non-nil if current buffer has any todo entry.
TODO entries marked as done are ignored, meaning this function
returns nil if current buffer contains only completed tasks."
(seq-find
(lambda (type)
(eq type 'todo))
(org-element-map
(org-element-parse-buffer 'headline)
'headline
(lambda (h)
(org-element-property :todo-type h)))))
(defun my--todo-update-tag ()
"Update AGENDA tag in the current buffer."
(when (and (not (active-minibuffer-window))
(my--buffer-note-p))
(save-excursion
(goto-char (point-min))
(let* ((tags (my--buffer-tags-get))
(original-tags tags))
(if (my--todo-p)
(setq tags (cons "agenda" tags))
(setq tags (remove "agenda" tags)))
;;cleanup duplicates
(when (or (seq-difference tags original-tags)
(seq-difference original-tags tags))
(apply #'my--buffer-tags-set tags))))))
(defun my--buffer-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_FILES))
(file-name-directory buffer-file-name))))
(defun my--buffer-tags-get ()
"Return filetags value in current buffer."
(my--buffer-prop-get-list "filetags" "[ :]"))
(defun my--buffer-tags-set (&rest tags)
"Set TAGS in current buffer.
If filetags value is already set, replace it."
(if tags
(my--buffer-prop-set
"filetags" (concat ":" (string-join tags ":") ":"))
(my--buffer-prop-remove "filetags")))
(defun my--buffer-tags-add (tag)
"Add a TAG to filetags in current buffer."
(let* ((tags (my--buffer-tags-get))
(tags (append tags (list tag))))
(apply #'my--buffer-tags-set tags)))
(defun my--buffer-tags-remove (tag)
"Remove a TAG from filetags in current buffer."
(let* ((tags (my--buffer-tags-get))
(tags (delete tag tags)))
(apply #'my--buffer-tags-set tags)))
(defun my--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 my--buffer-prop-set-list (name values &optional separators)
"Set a file property called NAME to VALUES in current buffer.
VALUES are quoted and combined into single string using
`combine-and-quote-strings'.
If SEPARATORS is non-nil, it should be a regular expression
matching text that separates, but is not part of, the substrings.
If nil it defaults to `split-string-and-unquote', normally
\"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t.
If the property is already set, replace its value."
(my--buffer-prop-set
name (combine-and-quote-strings values separators)))
(defun my--buffer-prop-get (name)
"Get a buffer property called NAME as a string."
(org-with-point-at 1
(when (re-search-forward (concat "^#\\+" name ": \\(.*\\)")
(point-max) t)
(buffer-substring-no-properties
(match-beginning 1)
(match-end 1)))))
(defun my--buffer-prop-get-list (name &optional separators)
"Get a buffer property NAME as a list using SEPARATORS.
If SEPARATORS is non-nil, it should be a regular expression
matching text that separates, but is not part of, the substrings.
If nil it defaults to `split-string-default-separators', normally
\"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t."
(let ((value (my--buffer-prop-get name)))
(when (and value (not (string-empty-p value)))
(split-string-and-unquote value separators))))
(defun my--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 ""))))
;; (defun my--org-agenda-files-set ()
;; "Sets default agenda files.
;; Necessary when updating roam agenda todos."
;; (setq org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
;; (concat MY--PATH_ORG_FILES "projects.org")
;; (concat MY--PATH_ORG_FILES "tasks.org")))
;; (when *sys/linux*
;; (nconc org-agenda-files
;; (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$"))))
;; (my--org-agenda-files-set)
(setq org-agenda-files (my--org-files-with-tag MY--PATH_ORG_FILES "agenda"))
;; (cl-remove-if (lambda (file)
;; ;; exclude some subdirs
;; (let ((excluded-dirs '("notes" "dummy")))
;; (cl-some (lambda (dir) (string-match-p (concat "/" dir "/") file))
;; excluded-dirs)))
;; ;; (string-match-p "/notes/" file))
; (directory-files-recursively MY--PATH_ORG_FILES "\\.org$")) ;;)
(defun my--org-skip-subtree-if-priority (priority)
"Skip an agenda subtree if it has a priority of PRIORITY.
@ -1387,9 +1231,6 @@ If nil it defaults to `split-string-default-separators', normally
(if (= pri-value pri-current)
subtree-end
nil)))
(add-hook 'find-file-hook #'my--todo-update-tag)
(add-hook 'before-save-hook #'my--todo-update-tag)
(add-hook 'after-save-hook #'my--org-agenda-files-update)
;; (add-to-list 'org-tags-exclude-from-inheritance "agenda") ;;removed in org 9.5
;; use inheritance except for "agenda"
(setq org-use-tag-inheritance
@ -1433,15 +1274,27 @@ nil)))
;; entry for a todo in a todo file
;; add an entry to a new or existing node
;; which is not in the org-node exclusion list
'(("i" "capture into ID node"
'(("i" "capture into node"
entry (function org-node-capture-target) nil
:jump-to-captured t
:empty-lines-after 1)
;; jump to an existing org-node
("j" "Jumo to ID node"
("j" "jumo to node"
plain (function org-node-capture-target) nil
:jump-to-captured t
:immediate-finish t)
("t" "simple task"
entry (file "~/archiv/notes/tasks.org")
"* TODO %?\n :PROPERTIES:\n :CREATED: %U\n :END:\n"
:prepend t
:prepare-finalize (org-id-get-create)
:jump-to-captured t)
("n" "simple note"
entry (file "~/archiv/notes/notes.org")
"* %?\n :PROPERTIES:\n :CREATED: %U\n :END:\n"
:prepend t
:prepare-finalize (org-id-get-create)
:jump-to-captured t)
("p" "phone call"
entry (file+olp+datetree "~/archiv/notes/phonecalls.org")
"* call [%<%Y-%m-%d %H:%M>] %?"
@ -1482,20 +1335,8 @@ nil)))
(tags priority-down category-keep)
(search category-keep))))
(org-agenda-custom-commands
'(("c" "Simple agenda view"
((tags "PRIORITY=\"A\""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "Hohe Priorität:")))
(agenda ""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-span 7)
(org-agenda-start-on-weekday nil)
(org-agenda-overriding-header "Nächste 7 Tage:")))
(alltodo ""
((org-agenda-skip-function '(or (my--org-skip-subtree-if-priority ?A)
(org-agenda-skip-if nil '(scheduled deadline))))
(org-agenda-overriding-header "Sonstige Aufgaben:")))))
("q" "test"
'(
("c" "Standard Agenda"
(
(agenda ""
((org-agenda-span 7)
@ -1535,8 +1376,20 @@ nil)))
(not (tags "@bag")))
((org-ql-block-header "tasks in pipeline")))
))
("p" "super agenda"
("o" "old Simple agenda view"
((tags "PRIORITY=\"A\""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "Hohe Priorität:")))
(agenda ""
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-span 7)
(org-agenda-start-on-weekday nil)
(org-agenda-overriding-header "Nächste 7 Tage:")))
(alltodo ""
((org-agenda-skip-function '(or (my--org-skip-subtree-if-priority ?A)
(org-agenda-skip-if nil '(scheduled deadline))))
(org-agenda-overriding-header "Sonstige Aufgaben:")))))
("p" "super agenda test"
((org-ql-block
'(and (todo)
(not (done)))
@ -1576,14 +1429,16 @@ Elpaca cant find it, though it's built in org
#+end_src
** COMMENT habits
** habits
#+BEGIN_SRC emacs-lisp
(require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
;; (add-to-list 'org-modules "org-habit")
(setq org-habit-graph-column 80
org-habit-preceding-days 30
org-habit-following-days 7
org-habit-show-habits-only-for-today nil)
;(require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
;; (add-to-list 'org-modules "org-habit")
(when *sys/linux*
(setq org-habit-graph-column 80
org-habit-preceding-days 30
org-habit-following-days 7
org-habit-show-habits-only-for-today nil
))
#+END_SRC
** contacts
@ -1614,250 +1469,6 @@ Ggf. durch org-roam-journal ersetzen
org-journal-enable-agenda-integration t)))
#+END_SRC
** COMMENT org-roam
[[https://github.com/org-roam/org-roam][Github]]
Um Headings innerhalb einer Datei zu verlinken:
- org-id-get-create im Heading,
- org-roam-node-insert in der verweisenden Datei
Bei Problemen wie unique constraint
org-roam-db-clear-all
org-roam-db-sync
#+BEGIN_SRC emacs-lisp
;(use-package emacsql-sqlite-builtin
; :ensure t)
(defun my--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 my--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-roam
; :requires emacsql-sqlite-builtin
:ensure t
:defer 2
:after org
:init
(setq org-roam-v2-ack t)
(defun my--roamtodo-p ()
"Return non-nil if current buffer has any todo entry.
TODO entries marked as done are ignored, meaning this function
returns nil if current buffer contains only completed tasks."
(seq-find
(lambda (type)
(eq type 'todo))
(org-element-map
(org-element-parse-buffer 'headline)
'headline
(lambda (h)
(org-element-property :todo-type h)))))
(defun my--roamtodo-update-tag ()
"Update ROAMTODO tag in the current buffer."
(when (and (not (active-minibuffer-window))
(my--buffer-roam-note-p))
(save-excursion
(goto-char (point-min))
(let* ((tags (my--buffer-tags-get))
(original-tags tags))
(if (my--roamtodo-p)
(setq tags (cons "roamtodo" tags))
(setq tags (remove "roamtodo" tags)))
;;cleanup duplicates
(when (or (seq-difference tags original-tags)
(seq-difference original-tags tags))
(apply #'my--buffer-tags-set tags))))))
(defun my--buffer-tags-get ()
"Return filetags value in current buffer."
(my--buffer-prop-get-list "filetags" "[ :]"))
(defun my--buffer-tags-set (&rest tags)
"Set TAGS in current buffer.
If filetags value is already set, replace it."
(if tags
(my--buffer-prop-set
"filetags" (concat ":" (string-join tags ":") ":"))
(my--buffer-prop-remove "filetags")))
(defun my--buffer-tags-add (tag)
"Add a TAG to filetags in current buffer."
(let* ((tags (my--buffer-tags-get))
(tags (append tags (list tag))))
(apply #'my--buffer-tags-set tags)))
(defun my--buffer-tags-remove (tag)
"Remove a TAG from filetags in current buffer."
(let* ((tags (my--buffer-tags-get))
(tags (delete tag tags)))
(apply #'my--buffer-tags-set tags)))
(defun my--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 my--buffer-prop-set-list (name values &optional separators)
"Set a file property called NAME to VALUES in current buffer.
VALUES are quoted and combined into single string using
`combine-and-quote-strings'.
If SEPARATORS is non-nil, it should be a regular expression
matching text that separates, but is not part of, the substrings.
If nil it defaults to `split-string-and-unquote', normally
\"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t.
If the property is already set, replace its value."
(my--buffer-prop-set
name (combine-and-quote-strings values separators)))
(defun my--buffer-prop-get (name)
"Get a buffer property called NAME as a string."
(org-with-point-at 1
(when (re-search-forward (concat "^#\\+" name ": \\(.*\\)")
(point-max) t)
(buffer-substring-no-properties
(match-beginning 1)
(match-end 1)))))
(defun my--buffer-prop-get-list (name &optional separators)
"Get a buffer property NAME as a list using SEPARATORS.
If SEPARATORS is non-nil, it should be a regular expression
matching text that separates, but is not part of, the substrings.
If nil it defaults to `split-string-default-separators', normally
\"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t."
(let ((value (my--buffer-prop-get name)))
(when (and value (not (string-empty-p value)))
(split-string-and-unquote value separators))))
(defun my--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 ""))))
(defun my--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 my--org-roam-filter-by-tag (tag-name)
(lambda (node)
(member tag-name (org-roam-node-tags node))))
(defun my--org-roam-list-notes-by-tag (tag-name)
(mapcar #'org-roam-node-file
(seq-filter
(my--org-roam-filter-by-tag tag-name)
(org-roam-node-list))))
;; (defun my/org-roam-refresh-agenda-list ()
;; "Add all org roam files with #+filetags: roamtodo"
;; (interactive)
;; (my--org-agenda-files-set)
;; (nconc org-agenda-files
;; (my--org-roam-list-notes-by-tag "roamtodo"))
;; (setq org-agenda-files (delete-dups org-agenda-files)))
(add-hook 'find-file-hook #'my--roamtodo-update-tag)
(add-hook 'before-save-hook #'my--roamtodo-update-tag)
;; (advice-add 'org-agenda :before #'my/org-roam-refresh-agenda-list)
;; (advice-add 'org-todo-list :before #'my/org-roam-refresh-agenda-list)
(add-to-list 'org-tags-exclude-from-inheritance "roamtodo")
: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
;; (my/org-roam-refresh-agenda-list)
(when *work_remote*
(setq org-roam-capture-templates
'(("n" "note" plain
"%?"
:if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("i" "idea" plain
"%?"
:if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("p" "project" plain
"%?"
:target (file+head "projects/${slug}.org" "#+title: ${title}\n#+filetags: :project:\n")
:unnarrowed t)
("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")))
("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"))))))
:custom
(org-roam-database-connector 'sqlite-builtin)
(org-roam-directory MY--PATH_ORG_ROAM)
(org-roam-completion-everywhere t)
(org-roam-capture-templates
'(("n" "note" plain
"%?"
:if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("i" "idea" plain
"%?"
:if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.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))
#+END_SRC
** org-node (alternative to org-roam)
https://github.com/meedstrom/org-node
no sqlite, just plain text and linking with ids
@ -1877,7 +1488,22 @@ because it fails to pull system info about the number of cores.
;;requirement for org-node
(use-package org-mem
:ensure (:host github :repo "meedstrom/org-mem")
:after el-job)
:after el-job
:init
(defun my--set-agenda-files (&rest _)
(setq org-agenda-files
(cl-loop
for file in (org-mem-all-files)
unless (string-search "archive" file)
when (seq-find (lambda (entry)
(or (org-mem-entry-active-timestamps entry)
(org-mem-entry-todo-state entry)
(org-mem-entry-scheduled entry)
(org-mem-entry-deadline entry)))
(org-mem-entries-in file))
collect file)))
(add-hook 'org-mem-post-full-scan-functions #'my--set-agenda-files)
)
(use-package org-node
:ensure t

Loading…
Cancel
Save