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