From afd19bc6757aa20c03cc42d5a52798ee1807ee45 Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 1 Feb 2023 17:03:15 +0100 Subject: [PATCH] some code cleanup --- config.org | 153 +++++++++++++++++++++++------------------------------ 1 file changed, 65 insertions(+), 88 deletions(-) diff --git a/config.org b/config.org index 053d914..a3f578e 100644 --- a/config.org +++ b/config.org @@ -862,9 +862,17 @@ If the property is already set, replace its value." ; (add-hook 'org-mode-hook 'company/org-mode-hook) ; (add-hook 'org-src-mode-hook 'smartparens-mode) ; (add-hook 'org-mode-hook 'org-indent-mode) - :bind (:map org-mode-map ("S-" . org-shiftright) + :bind (("C-c l" . org-store-link) + ("C-c c" . org-capture) + ("C-c a" . org-agenda) + :map org-mode-map ("S-" . org-shiftright) ("S-" . org-shiftleft)) :init + (defun my--org-company () + (set (make-local-variable 'company-backends) + '(company-capf company-files)) + (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)) + (defun my--org-agenda-files-set () "Sets default agenda files. Necessary when updating roam agenda todos." @@ -876,11 +884,6 @@ Necessary when updating roam agenda todos." (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$")))) (my--org-agenda-files-set) :config - (defun my--org-company () - (set (make-local-variable 'company-backends) - '(company-capf company-files)) - (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (message "company/org-mode-hook")) (setq org-modules (quote (org-id org-habit org-tempo ;; easy templates @@ -888,43 +891,70 @@ Necessary when updating roam agenda todos." (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")) (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations") org-log-into-drawer "LOGBOOK") + (setq org-log-done 'time ;; create timestamp when task is done + org-blank-before-new-entry '((heading) (plain-list-item))) ;; prevent new line before new item + :custom + (org-pretty-entities t) + (org-startup-truncated t) + (org-startup-align-all-tables t) + (org-src-fontify-natively t) ;; use syntax highlighting in code blocks + (org-src-preserve-indentation t) ;; no extra indentation + (org-src-window-setup 'current-window) ;; C-c ' opens in current window + (org-src-tab-acts-natively t) + ) +#+END_SRC - ;; some display customizations - (setq org-pretty-entities t - org-startup-truncated t - org-startup-align-all-tables t) +** org-agenda +Custom keywords, depending on environment +#+BEGIN_SRC emacs-lisp +(use-package org + :if *work_remote* + :config + (setq org-todo-keywords + '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))) +#+END_SRC - ;; some source code blocks customizations - (setq org-src-window-setup 'current-window ;; C-c ' opens in current window - org-src-fontify-natively t ;; use syntax highlighting in code blocks - org-src-preserve-indentation t ;; no extra indentation - org-src-tab-acts-natively t) +Sort agenda by deadline and priority +#+BEGIN_SRC emacs-lisp +(setq org-agenda-sorting-strategy + (quote + ((agenda deadline-up priority-down) + (todo priority-down category-keep) + (tags priority-down category-keep) + (search category-keep)))) +#+END_SRC - (setq org-log-done 'time ;; create timestamp when task is done - org-blank-before-new-entry '((heading) (plain-list-item)))) ;; prevent new line before new item +Customize the org agenda +#+BEGIN_SRC emacs-lisp +(defun my--org-skip-subtree-if-priority (priority) + "Skip an agenda subtree if it has a priority of PRIORITY. + + PRIORITY may be one of the characters ?A, ?B, or ?C." + (let ((subtree-end (save-excursion (org-end-of-subtree t))) + (pri-value (* 1000 (- org-lowest-priority priority))) + (pri-current (org-get-priority (thing-at-point 'line t)))) + (if (= pri-value pri-current) + subtree-end + nil))) + +(setq 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-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:"))))))) #+END_SRC ** languages Set some languages and disable confirmation for evaluating code blocks C-c C-c -+BEGIN_SRC emacs-lisp -(org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (gnuplot . t) - (js . t) - (latex . t) - (lisp . t) - (python . t) - (shell . t) - (sqlite . t) - (org . t) - (R . t) - (scheme . t))) - -(setq org-confirm-babel-evaluate nil) -+END_SRC -Another setup, because org-babel-do-load-languages requires eager loading #+begin_src emacs-lisp (use-package ob-org :defer t @@ -1013,59 +1043,6 @@ Another setup, because org-babel-do-load-languages requires eager loading org-habit-show-habits-only-for-today nil) #+END_SRC -** org-agenda -Custom keywords, depending on environment -#+BEGIN_SRC emacs-lisp -(when *work_remote* - (setq org-todo-keywords - '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))) -#+END_SRC - -Add some key bindings -#+BEGIN_SRC emacs-lisp -(bind-key "C-c l" 'org-store-link) -(bind-key "C-c c" 'org-capture) -(bind-key "C-c a" 'org-agenda) -#+END_SRC - -Sort agenda by deadline and priority -#+BEGIN_SRC emacs-lisp -(setq org-agenda-sorting-strategy - (quote - ((agenda deadline-up priority-down) - (todo priority-down category-keep) - (tags priority-down category-keep) - (search category-keep)))) -#+END_SRC - -Customize the org agenda -#+BEGIN_SRC emacs-lisp -(defun my--org-skip-subtree-if-priority (priority) - "Skip an agenda subtree if it has a priority of PRIORITY. - - PRIORITY may be one of the characters ?A, ?B, or ?C." - (let ((subtree-end (save-excursion (org-end-of-subtree t))) - (pri-value (* 1000 (- org-lowest-priority priority))) - (pri-current (org-get-priority (thing-at-point 'line t)))) - (if (= pri-value pri-current) - subtree-end - nil))) - -(setq 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-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:"))))))) -#+END_SRC - ** *TODO* [[https://github.com/alphapapa/org-ql][org-ql]] [[https://github.com/nobiot/org-transclusion][org-transclusion]]?