;;; init-org.el --- org-mode config -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: (use-package org :hook (org-mode . org-indent-mode) (org-mode . visual-line-mode) (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.*?[*/_=~+]" (0 (prog1 () (add-text-properties (match-beginning 1) (match-end 1) '(invisible t))))) ("[*/_=~+].*?\\cc[*/_=~+]\\( \\)\\cc" (0 (prog1 () (add-text-properties (match-beginning 1) (match-end 1) '(invisible t))))))) (font-lock-add-keywords 'org-mode org-hide-space-keywords 'append) (if *is-windows* (add-hook 'org-mode-hook 'font-lock-update)) (unless *is-windows* (add-hook 'org-mode 'jinx-mode)) (defun my-org-electric-pair-fix () (setq-local electric-pair-inhibit-predicate (lambda (char) (or (eq char ?<) (electric-pair-default-inhibit char))))) ;; log默认放入drawer中 (setq org-log-done t org-log-into-drawer t) ;; 不要在capture时设置bookmark (setq org-bookmark-names-plist nil) ;; 设置todo关键字 (setq org-todo-keywords (quote ((sequence "TODO(t)" "SOMEDAY(S)" "STARTED(s)" "WAITING(w)" "|" "DONE(d!/!)" "CANCELLED(c@/!)") (sequence "IDKY(i)" "|" "KNOWN(k)" "CANCELLED(c@/!)")))) ;; agenda相关 (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 '(org-agenda-skip-entry-if 'todo '("COMMENT")))) ;; phscroll,优化表格换行 (use-package phscroll :hook (org-mode . org-phscroll-activate) :init (setq org-startup-truncated nil)) ;; org-babel scheme (use-package ob-scheme :demand t :after org :straight nil :config (add-to-list 'org-babel-load-languages '(scheme . t)) (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)) ;; denote (use-package denote :hook (after-init . denote-rename-buffer-mode) (dired-mode . denote-dired-mode) :init (setq denote-directory org-directory) (setq denote-org-store-link-to-heading 'context denote-prompts '(title signature keywords)) (setq denote-title-history nil denote-signature-history '("note" "project" "fun" "wisdom" "article" "data" "metanote" "agenda" "journal" "archive") denote-known-keywords '("emacs") denote-title-history nil)) ;; denote-org (use-package denote-org) ;; denote-lint (use-package denote-lint :straight '(denote-lint :type git :host github :repo "Andsy10/denote-lint") :config (setq org-link-elisp-confirm-function nil)) ;; denote-journal (use-package denote-journal :hook (calendar-mode . denote-journal-calendar-mode) :config (setq denote-journal-directory (expand-file-name "journal" denote-directory)) (setq denote-journal-keyword nil) (setq denote-journal-signature "journal") (setq denote-journal-keyword "daily")) ;; denote-explore (use-package denote-explore) ;; consult-denote (use-package consult-denote :hook (after-init . consult-denote-mode) :init (setq consult-denote-grep-command 'consult-ripgrep)) ;; org-download (use-package org-download :after org :demand t :hook (org-mode . org-link-preview-region) :config (setq-default org-download-image-dir "./images/" org-download-heading-lvl nil) (setq org-download-dragndrop t org-download-method 'directory org-image-actual-width nil org-download-image-html-width 600 org-return-follows-link t)) ;; org-ql (use-package org-ql) ;; org-super-agenda 配置 (use-package org-super-agenda :config (org-super-agenda-mode)) ;; agenda (use-package org-agenda :straight nil :hook (org-agenda-finalize . disable-truncate-lines) :config (setq org-agenda-custom-commands '(("qd" "TODO entries sort by closed time" ((org-ql-block '(closed) ((org-ql-block-header "Closed TODOs") (org-super-agenda-groups '((:auto-ts t))))))) ("qs" "SOMEDAYs" ((org-ql-block '(todo "SOMEDAY") ((org-ql-block-header "SOMEDAYs") (org-super-agenda-groups '((:auto-ts t))))))) ("qS" "STARTEDs" ((org-ql-block '(todo "STARTED") ((org-ql-block-header "STARTEDs") (org-super-agenda-groups '((:auto-ts t))))))) ("qt" "TODOs sort by start time" ((org-ql-block '(todo) ((org-ql-block-header "TODOs") (org-super-agenda-groups '((:auto-ts t))))))) ("qa" "all TODO entries" ((org-ql-block '(and (not (done)) (todo)) ((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") (:name "other priority" :priority< "C") (:name "someday" :todo "SOMEDAY") (:name "I dont know yet" :todo "IDKY")))))))))) ;; capture (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 `(("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 :init (with-eval-after-load 'org-capture (defun org-hugo-new-subtree-post-capture-template () "Returns `org-capture' template string for new Hugo post. See `org-capture-templates' for more information." (let* ((title (read-from-minibuffer "Post Title: ")) ;Prompt to enter the post title (fname (org-hugo-slug title))) (mapconcat #'identity `( ,(concat "* TODO " title) ":PROPERTIES:" ,(concat ":EXPORT_FILE_NAME: " fname) ":END:" "\n\n") ;Place the cursor here finally "\n"))) (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) ;; 农历日历 (use-package cal-china-x :after calendar :autoload cal-china-x-setup :init (cal-china-x-setup) :config (setq calendar-mark-holidays-flag t cal-china-x-important-holidays cal-china-x-chinese-holidays cal-china-x-general-holidays '((holiday-lunar 1 15 "元宵节") (holiday-lunar 7 7 "七夕节") (holiday-fixed 3 8 "妇女节") (holiday-fixed 3 12 "植树节") (holiday-fixed 5 4 "青年节") (holiday-fixed 6 1 "儿童节") (holiday-fixed 9 10 "教师节")) holiday-other-holidays '((holiday-fixed 2 14 "情人节") (holiday-fixed 4 1 "愚人节") (holiday-fixed 12 25 "圣诞节") (holiday-fixed 6 7 "高考") (holiday-float 5 0 2 "母亲节") (holiday-float 6 0 3 "父亲节") (holiday-float 11 4 4 "感恩节")) calendar-holidays (append cal-china-x-important-holidays cal-china-x-general-holidays holiday-other-holidays))) (provide 'init-org) ;;; init-org.el ends here