Config: migrate from org-journal to denote-journal

This commit is contained in:
2026-05-10 01:15:28 +08:00
parent 5ee06f8500
commit 1b7d2d1e5e
7 changed files with 71 additions and 189 deletions

View File

@@ -42,7 +42,8 @@
(use-package delight
:config
(delight '((eldoc-mode nil eldoc)
(org-indent-mode nil org))))
(org-indent-mode nil org)
(desktop-environment-mode nil desktop-environment))))
;; 安装gcmh用于管理内存回收
(use-package gcmh

View File

@@ -94,17 +94,20 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
(consult-ripgrep (unless *is-windows*
'("~/org/my-org-note/" "~/org/hugo/this-is-my-blog/all-blog.org"))))
(defun org-journal-open-current-journal-file-delete-other-window()
"Call org-journal-open-current-journal-file and delete other window."
(interactive)
(org-journal-open-current-journal-file)
(delete-other-windows))
(defun my-denote-journal-path-to-existing-entry (&optional date interval)
"Return the path of current denote journal if it exists, otherwise return nil."
(require 'denote-journal)
(let* ((internal-date (denote-journal--date-in-interval-p (or date (current-time)) interval))
(files (denote-journal--get-entry internal-date interval)))
(if files
(denote-journal-select-file-prompt files))))
(defun org-journal-new-entry-delete-other-window()
"Call org-journal-new-entry and delete other window."
(defun my-denote-journal-open-entry ()
"Open current denote-journal entry."
(interactive)
(org-journal-new-entry nil)
(delete-other-windows))
(if (my-denote-journal-path-to-existing-entry)
(find-file (my-denote-journal-path-to-existing-entry))
(message "No journal for today yet")))
(defun org-table-align-all ()
"Ajust all table in current buffer."

View File

@@ -74,8 +74,8 @@
;; j for journal
(general-def
:prefix "C-c j"
"o" 'org-journal-open-current-journal-file-delete-other-window
"n" 'org-journal-new-entry-delete-other-window)
"o" 'my-denote-journal-open-entry
"n" 'denote-journal-new-or-existing-entry)
;; m for media
(general-def
@@ -152,7 +152,12 @@
"C-c i" 'consult-outline
"C-c t l" 'org-toggle-link-display
"M-{" 'org-previous-visible-heading
"M-}" 'org-next-visible-heading)
"M-}" 'org-next-visible-heading
"C-," 'duplicate-and-move-to-next-line)
;; calendar
(general-def calendar-mode-map
"RET" 'denote-journal-calendar-find-file)
;; emms
(general-def emms-playlist-mode-map
@@ -249,11 +254,6 @@
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
"show diff between the buffer and its file"))
;; 在calendar中快速打开当天日记
(general-def calendar-mode-map
"j o" 'org-journal-open-entry-for-editing
"<RET>" 'org-journal-open-entry-for-editing)
;; multiple-cursors
(defhydra hydra-multiple-cursors ()
"

View File

@@ -53,9 +53,9 @@
(setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org"
"h:/emacs/my-org-daily/")))
(*is-mac*
(setq org-agenda-files '("~/org/my-org-daily")))
(setq org-agenda-files '("~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org")))
(*is-linux*
(setq org-agenda-files '("~/org/my-org-daily/"))))
(setq org-agenda-files '("~/org/my-org-note/20260509T232442==agenda--all-my-todos__org.org"))))
(setq org-agenda-span 'day)
(setq org-default-priority ?C)
@@ -83,6 +83,15 @@
;; denote-org
(use-package denote-org)
;; denote-journal
(use-package denote-journal
:init
(add-hook 'calendar-mode-hook #'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"))
;; denote-explore
(use-package denote-explore)
@@ -93,8 +102,6 @@
:init
(consult-notes-denote-mode)
:config
(setq consult-notes-file-dir-sources '(("Org Notes" ?n "~/org/my-org-note/" :hidden t)
("Org Journal" ?j "~/org/my-org-daily/" :hidden t)))
(setq consult-notes-denote-display-keywords-indicator "_")
(setq consult-notes-denote-display-id-format 'date)
(setq consult-notes-denote-display-signature t))
@@ -116,108 +123,8 @@
(require 'org-download)
(setq org-return-follows-link t)))
;; org-journal
(use-package org-journal
:config
(setq org-journal-file-format "%Y-%m-%d.org"
org-journal-file-header "#+category: journal\n#+STARTUP: content\n\n"
org-journal-time-prefix "\n*** TODO "
org-journal-time-format "%m-%d \n<%Y-%m-%d %a %H:%M:%S>\n"
org-journal-hide-entries-p t
org-journal-date-format (lambda (time)
(format "* %s %s\n\n[%s]\n"
(format-time-string "%Y-%m-%d" time)
(format-time-string "%a" time)
(format-time-string "%Y-%m-%d %a" time)))
org-journal-carryover-items "TODO=\"TODO\"|TODO=\"STARTED\"|TODO=\"WAITING\"|TODO=\"SOMEDAY\"")
(if *is-windows*
(setq org-journal-dir "h:/emacs/my-org-daily/")
(setq org-journal-dir "~/org/my-org-daily/"))
(add-hook 'org-journal-mode-hook 'font-lock-update)
(defun my/journal-setup-new-day ()
(save-excursion
(org-back-to-heading)
(let ((day-end (save-excursion (org-end-of-subtree) (point))))
(unless (search-forward "** daily" day-end t)
(goto-char day-end)
(unless (bolp) (insert "\n"))
(insert "\n\n** daily\n\n\n")
(insert "** tasks\n")))))
(add-hook 'org-journal-after-header-create-hook #'my/journal-setup-new-day)
(defun my/journal-position-cursor-after-time ()
(when (derived-mode-p 'org-journal-mode)
(org-back-to-heading)
(end-of-line)))
(add-hook 'org-journal-after-entry-create-hook #'my/journal-position-cursor-after-time)
(defun org-journal-open-entry-for-editing (&optional event)
"Open journal entry for the date under cursor in calendar for editing."
(interactive
(list last-nonmenu-event))
(let* ((date (calendar-cursor-to-date t event))
(time (org-journal--calendar-date->time date))
(org-journal-file (org-journal--get-entry-path time)))
(if (file-exists-p org-journal-file)
(progn
(funcall org-journal-find-file org-journal-file)
(unless (org-journal--daily-p)
(org-journal--goto-entry date)))
(message "No journal entry for this date."))))
(defun my/org-journal-mark-old-todos-as-comment (entries)
"Change TODO entry's TODO keyword to COMMENT after carryover."
(save-excursion
(let* ((todo-keywords (cl-remove-if
(lambda (kw) (member kw org-done-keywords))
org-todo-keywords-1))
(todo-pattern (when todo-keywords
(regexp-opt todo-keywords 'words))))
(when todo-pattern
(mapc (lambda (entry)
(let ((start (car entry))
(end (set-marker (make-marker) (cadr entry))))
(goto-char start)
(while (re-search-forward (concat "^\\(\\*+ \\)" todo-pattern) end t)
(replace-match "\\1COMMENT" t nil))
(set-marker end nil)))
(reverse entries))))
(save-buffer)))
(setq org-journal-handle-old-carryover-fn #'my/org-journal-mark-old-todos-as-comment)
;; 在org-journal加载cns-mode
(add-hook 'org-journal-mode-hook
(lambda ()
(global-cns-mode-enable-in-buffer))))
;; org-ql
(use-package org-ql
:config
(with-eval-after-load 'org-ql-view
(keymap-set org-ql-view-map (kbd "q") 'org-agenda-Quit))
(setq org-ql-views
'(("tags: emacs category:note"
:buffers-files org-agenda-files
:query (and (tags "emacs") (category "note"))
:sort date)
("group by time"
:buffers-files org-agenda-files
:query (and (ts :to "today") (tags "root"))
:sort date
:super-groups ((:auto-ts t)))
("group by category"
:buffers-files org-agenda-files
:query (tags "root")
:super-groups ((:auto-property "CATEGORY"))))))
(use-package org-ql)
;; org-super-agenda 配置
(use-package org-super-agenda
@@ -235,25 +142,21 @@
("qd" "TODO entries sort by closed time"
((org-ql-block '(closed)
((org-ql-block-header "Closed TODOs")
(org-ql-sort '(closed))
(org-super-agenda-groups
'((:auto-ts t)))))))
("qS" "SOMEDAYs"
((org-ql-block '(todo "SOMEDAY")
((org-ql-block-header "SOMEDAYs")
(org-ql-sort '(start-time))
(org-super-agenda-groups
'((:auto-ts t)))))))
("qs" "STARTEDs"
((org-ql-block '(todo "STARTED")
((org-ql-block-header "STARTEDs")
(org-ql-sort '(start-time))
(org-super-agenda-groups
'((:auto-ts t)))))))
("qt" "TODOs sort by start time"
((org-ql-block '(todo)
((org-ql-block-header "TODOs")
(org-ql-sort '(start-time))
(org-super-agenda-groups
'((:auto-ts t)))))))
("qa" "all TODO entries"
@@ -267,55 +170,18 @@
(:name "someday" :todo "SOMEDAY")
))))))))
(setq org-tag-alist '(
("scheme" . ?s)
("emacs" . ?e)
("elisp" . ?E)
("org" . ?o)
("linux" . ?l)
("computer-stuff" . ?c)
("philosophy" . ?p)
("film" . ?f)
("game" . ?g)
("gamestudies" . ?G)
("masterpiece" . ?m)
))
;; (setq org-tags-exclude-from-inheritance '())
;; capture模板
(defvar my-org-capture-temp-title "" "Temporarily store the org-capture filename.")
(setq org-capture-templates
'(("n" "New Note" plain
(file (lambda ()
(setq my-org-capture-temp-title (read-string "Filename (without .org): "))
(expand-file-name (if *is-windows*
(format "%s/%s-%s.org"
"h:/emacs/my-org-note/"
(format-time-string "%Y%m%d")
my-org-capture-temp-title)
(format "%s/%s-%s.org"
"~/org/my-org-note/"
(format-time-string "%Y%m%d")
my-org-capture-temp-title)))))
"
#+title: %(symbol-value 'my-org-capture-temp-title)
#+date: %U
#+category: %^{Category|none|project|book|article|note|wisdom|fun|data}
* %(symbol-value 'my-org-capture-temp-title) :root%^g
:PROPERTIES:
:END:
%U
%?
# Local Variables:
# org-use-tag-inheritance: nil
# End:
"
:jump-to-captured t)))
(unless *is-windows*
(setq org-capture-templates
'(("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
:jump-to-captured t)
("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
:jump-to-captured t))))
(setq org-bookmark-names-plist nil)

View File

@@ -19,8 +19,8 @@
'((custom-theme-set-faces
theme-name
`(org-level-1 ((,class (:foreground ,orange :height 1.0 :weight normal))))
`(org-level-2 ((,class (:foreground ,green :height 1.0 :weight normal))))
`(org-level-3 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(org-level-2 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(org-level-3 ((,class (:foreground ,green :height 1.0 :weight normal))))
`(org-level-4 ((,class (:foreground ,yellow :height 1.0 :weight normal))))
`(org-level-5 ((,class (:foreground ,cyan :height 1.0 :weight normal))))
`(org-level-6 ((,class (:foreground ,green :height 1.0 :weight normal))))
@@ -33,6 +33,7 @@
`(org-block-end-line ((,class (:foreground ,base01 :overline t :slant italic :extend t))))
`(org-priority ((,class (:foreground ,green :weight bold))))
`(org-checkbox ((,class (:foreground ,base0 :weight bold))))
`(denote-journal-calendar ((,class (:foreground ,red :slant italic))))
`(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold))))
`(font-lock-doc-face ((,class (:foreground ,green :slant normal))))
`(font-lock-string-face ((,class (:foreground ,green))))
@@ -41,6 +42,8 @@
`(dashboard-heading ((,class (:foreground ,green :weight bold))))
`(dirvish-file-time ((,class (:foreground ,base01))))
`(dired-header ((,class (:foreground ,green))))
`(dired-async-mode-message ((,class (:foreground ,red))))
`(dired-async-message ((,class (:foreground ,yellow))))
`(consult-file ((,class (:foreground ,green))))
`(denote-faces-keywords ((,class (:foreground ,cyan))))
`(mode-line ((,class (:foreground ,base0 :background ,base02))))

View File

@@ -19,8 +19,8 @@
'((custom-theme-set-faces
theme-name
`(org-level-1 ((,class (:foreground ,orange :height 1.0 :weight normal))))
`(org-level-2 ((,class (:foreground ,green :height 1.0 :weight normal))))
`(org-level-3 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(org-level-2 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(org-level-3 ((,class (:foreground ,green :height 1.0 :weight normal))))
`(org-level-4 ((,class (:foreground ,yellow :height 1.0 :weight normal))))
`(org-level-5 ((,class (:foreground ,cyan :height 1.0 :weight normal))))
`(org-level-6 ((,class (:foreground ,green :height 1.0 :weight normal))))
@@ -33,6 +33,7 @@
`(org-block-end-line ((,class (:foreground ,base01 :overline t :slant italic :extend t))))
`(org-priority ((,class (:foreground ,green :weight bold))))
`(org-checkbox ((,class (:foreground ,base0 :weight bold))))
`(denote-journal-calendar ((,class (:foreground ,red))))
`(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold))))
`(font-lock-doc-face ((,class (:foreground ,green :slant normal))))
`(font-lock-string-face ((,class (:foreground ,green))))
@@ -41,6 +42,8 @@
`(dashboard-heading ((,class (:foreground ,green :weight bold))))
`(dirvish-file-time ((,class (:foreground ,base01))))
`(dired-header ((,class (:foreground ,green))))
`(dired-async-mode-message ((,class (:foreground ,red))))
`(dired-async-message ((,class (:foreground ,yellow))))
`(consult-file ((,class (:foreground ,green))))
`(denote-faces-keywords ((,class (:foreground ,cyan))))
`(mode-line ((,class (:foreground ,base0 :background ,base02))))