refactor(org): Centralize org-directory and simplify paths

- Replace scattered platform conditionals with unified `org-directory`
- Update todo keywords to include WAITING state
- Streamline capture templates
- Remove unused priority-based agenda custom commands
This commit is contained in:
User
2026-07-02 17:02:31 +08:00
parent ffa5717770
commit 74691ac72b

View File

@@ -1,4 +1,4 @@
;;; init-org.el --- org-mode config -*- lexical-binding: t -*- ;;; init-org.el --- org-mode config -*- lexical-binding: t -*-
;;; Commentary: ;;; Commentary:
@@ -11,6 +11,14 @@
(org-mode . my-org-electric-pair-fix) (org-mode . my-org-electric-pair-fix)
(org-mode . electric-pair-local-mode) (org-mode . electric-pair-local-mode)
:init
(setq org-directory
(cond
(*is-windows* "h:/emacs/my-org-note")
(*is-mac* "~/org/my-org-note")
(*is-linux* "~/org/my-org-note")
(*is-android* "~/storage/shared/my-org-note")))
:config :config
(defvar org-hide-space-keywords (defvar org-hide-space-keywords
'(("\\cc\\( \\)[*/_=~+]\\cc.*?[*/_=~+]" '(("\\cc\\( \\)[*/_=~+]\\cc.*?[*/_=~+]"
@@ -40,20 +48,11 @@
;; 设置todo关键字 ;; 设置todo关键字
(setq org-todo-keywords (setq org-todo-keywords
(quote ((sequence "TODO(t)" "STARTED(S)" "|" "DONE(d!/!)") (quote ((sequence "TODO(t)" "SOMEDAY(S)" "STARTED(s)" "WAITING(w)" "|" "DONE(d!/!)" "CANCELLED(c@/!)")
(sequence "IDKY(i)" "SOMEDAY(s)" "|" "CANCELLED(c@/!)")))) (sequence "IDKY(i)" "|" "KNOWN(k)" "CANCELLED(c@/!)"))))
;; agenda相关 ;; agenda相关
(cond (setq org-agenda-files `(,(concat org-directory "/20260509T232442==agenda--all-my-todos__org.org")))
(*is-windows*
(setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org"
"h:/emacs/my-org-note/20260509T232442==agenda--all-my-todos__org.org")))
(*is-mac*
(setq org-agenda-files '("~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org")))
(*is-linux*
(setq org-agenda-files '("~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org")))
(*is-android*
(setq org-agenda-files '("~/storage/shared/my-org-note/20260509T232442==agenda--all-my-todos__org.org"))))
(setq org-agenda-span 'day) (setq org-agenda-span 'day)
(setq org-agenda-skip-function-global (setq org-agenda-skip-function-global
@@ -83,13 +82,7 @@
(after-init . denote-rename-buffer-mode) (after-init . denote-rename-buffer-mode)
(dired-mode . denote-dired-mode) (dired-mode . denote-dired-mode)
:init :init
(cond (setq denote-directory org-directory)
(*is-android*
(setq denote-directory "~/storage/shared/my-org-note/"))
(*is-windows*
(setq denote-directory "H:/emacs/my-org-note/"))
(t
(setq denote-directory "~/org/my-org-note/")))
(setq denote-org-store-link-to-heading 'context (setq denote-org-store-link-to-heading 'context
denote-prompts '(title signature keywords)) denote-prompts '(title signature keywords))
(setq denote-title-history nil (setq denote-title-history nil
@@ -160,23 +153,7 @@
(org-agenda-finalize . disable-truncate-lines) (org-agenda-finalize . disable-truncate-lines)
:config :config
(setq org-agenda-custom-commands (setq org-agenda-custom-commands
'(("pa" "priority >= A" '(("qd" "TODO entries sort by closed time"
((org-ql-block '(and (priority "A") (todo))
((org-ql-block-header "priority = A")))))
("pb" "priority >= B"
((org-ql-block '(and (priority >= "B") (todo))
((org-ql-block-header "priority >= B")
(org-super-agenda-groups
'((:name "priority = A" :priority "A")
(:name "priority = B" :priority "B")))))))
("pc" "priority >= C"
((org-ql-block '(and (priority >= "C") (todo))
((org-ql-block-header "priority >= C")
(org-super-agenda-groups
'((:name "priority = A" :priority "A")
(:name "priority = B" :priority "B")
(:name "priority = C" :priority "C")))))))
("qd" "TODO entries sort by closed time"
((org-ql-block '(closed) ((org-ql-block '(closed)
((org-ql-block-header "Closed TODOs") ((org-ql-block-header "Closed TODOs")
(org-super-agenda-groups (org-super-agenda-groups
@@ -201,6 +178,7 @@
((org-ql-block-header "all TODOs") ((org-ql-block-header "all TODOs")
(org-super-agenda-groups (org-super-agenda-groups
'((:name "started" :todo "STARTED") '((:name "started" :todo "STARTED")
(:name "waiting" :todo "WAITING")
(:name "priority = A" :priority "A") (:name "priority = A" :priority "A")
(:name "priority = B" :priority "B") (:name "priority = B" :priority "B")
(:name "priority = C" :priority "C") (:name "priority = C" :priority "C")
@@ -212,39 +190,24 @@
(use-package org-capture (use-package org-capture
:straight nil :straight nil
:config :config
(setq my-org-capture-file (concat org-directory "/20260509T232442==agenda--all-my-todos__org.org"))
(setq org-capture-templates (setq org-capture-templates
(cond `(("t" "TODO" entry
((or *is-linux* *is-mac*) (file+headline ,my-org-capture-file "Something to do")
'(("t" "TODO" entry "* TODO %<%m-%d> %?\n%T" :empty-lines 1)
(file+headline "~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do") ("s" "STARTED" entry
"* TODO %<%m-%d> %?\n%T" (file+headline ,my-org-capture-file "Something to do")
:empty-lines 1) "* STARTED %<%m-%d> %?\n%T" :empty-lines 1)
("s" "SOMEDAY" entry ("S" "SOMEDAY" entry
(file+headline "~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do") (file+headline ,my-org-capture-file "Something to do")
"* SOMEDAY %<%m-%d> %?\n%T" "* SOMEDAY %<%m-%d> %?\n%T" :empty-lines 1)
:empty-lines 1) ("i" "IDKY" entry
("i" "IDKY" entry (file+headline ,my-org-capture-file "Something to know")
(file+headline "~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do") "* IDKY %<%m-%d> %?\n%T" :empty-lines 1))))
"* IDKY %<%m-%d> %?\n%T"
:empty-lines 1)))
(*is-android*
'(("t" "TODO" entry
(file+headline "~/storage/shared/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do")
"* TODO %<%m-%d> %?\n%T"
:empty-lines 1)
("s" "SOMEDAY" entry
(file+headline "~/storage/shared/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do")
"* SOMEDAY %<%m-%d> %?\n%T"
:empty-lines 1)
("i" "IDKY" entry
(file+headline "~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org" "Something to do")
"* IDKY %<%m-%d> %?\n%T"
:empty-lines 1)))
(t nil))))
;; hugo ;; hugo
(use-package ox-hugo (use-package ox-hugo
:config :init
(with-eval-after-load 'org-capture (with-eval-after-load 'org-capture
(defun org-hugo-new-subtree-post-capture-template () (defun org-hugo-new-subtree-post-capture-template ()
"Returns `org-capture' template string for new Hugo post. "Returns `org-capture' template string for new Hugo post.
@@ -259,25 +222,18 @@ See `org-capture-templates' for more information."
":END:" ":END:"
"\n\n") ;Place the cursor here finally "\n\n") ;Place the cursor here finally
"\n"))) "\n")))
(if *is-windows* (add-to-list 'org-capture-templates
(add-to-list 'org-capture-templates `("h" ;`org-capture' binding + h
'("h" ;`org-capture' binding + h "Hugo post"
"Hugo post" entry
entry ;; It is assumed that below file is present in `org-directory'
;; It is assumed that below file is present in `org-directory' ;; and that it has a "Blog Ideas" heading. It can even be a
;; and that it has a "Blog Ideas" heading. It can even be a ;; symlink pointing to the actual location of all-posts.org!
;; symlink pointing to the actual location of all-posts.org! (file+headline ,(if *is-windows*
(file+headline "h:/emacs/hugo/this-is-my-blog/all-blog.org" "Blog Ideas") "h:/emacs/hugo/this-is-my-blog/all-blog.org"
(function org-hugo-new-subtree-post-capture-template))) "~/org/hugo/this-is-my-blog/all-blog.org")
(add-to-list 'org-capture-templates "Blog Ideas")
'("h" ;`org-capture' binding + h (function org-hugo-new-subtree-post-capture-template)))))
"Hugo post"
entry
;; It is assumed that below file is present in `org-directory'
;; and that it has a "Blog Ideas" heading. It can even be a
;; symlink pointing to the actual location of all-posts.org!
(file+headline "~/org/hugo/this-is-my-blog/all-blog.org" "Blog Ideas")
(function org-hugo-new-subtree-post-capture-template))))))
;; presentation ;; presentation
(use-package org-tree-slide) (use-package org-tree-slide)