feat: add org-journal integration and calendar keybindings
- Configure org-journal with custom templates and auto-setup hooks - Add keybindings for calendar access and journal management - Update org-agenda-files to include journal and blog paths
This commit is contained in:
@@ -63,7 +63,10 @@
|
||||
|
||||
;; agenda相关
|
||||
(global-set-key (kbd "C-c a") 'org-agenda)
|
||||
(setq org-agenda-files '("d:/emacs/org/learning-org-mode.org")) ; agenda文件,目录或单个文件
|
||||
(with-eval-after-load 'org
|
||||
(setq org-agenda-files '("d:/emacs/org/learning-org-mode.org"
|
||||
"d:/emacs/hugo/this-is-my-blog/all-blog.org"
|
||||
"d:/emacs/my-org-daily/"))) ; agenda文件,目录或文件
|
||||
(setq org-agenda-span 'day)
|
||||
|
||||
|
||||
@@ -144,4 +147,56 @@ See `org-capture-templates' for more information."
|
||||
(goto-char (point-min))
|
||||
(org-table-map-tables 'org-table-align t)))
|
||||
|
||||
;; org-journal
|
||||
(use-package org-journal
|
||||
:config
|
||||
(setq org-journal-dir "D:/emacs/my-org-daily/"
|
||||
org-journal-file-format "%Y-%m-%d.org"
|
||||
org-journal-file-header "#+title: Daily Journal\n#+category: journal\n\n"
|
||||
org-journal-time-format "%R \n:PROPERTIES:\n:Created: <%Y-%m-%d %a %H:%M:%S>\n:END:\n"
|
||||
org-journal-time-prefix "\n*** TODO "
|
||||
org-journal-hide-entries-p t
|
||||
org-journal-date-format (lambda (time)
|
||||
(format "* %s %s\n:PROPERTIES:\n:Created: [%s]\n:END:"
|
||||
(format-time-string "%Y-%m-%d" time)
|
||||
(format-time-string "%a" time)
|
||||
(format-time-string "%Y-%m-%d %a" time))))
|
||||
|
||||
(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)
|
||||
(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.")))))
|
||||
|
||||
;; 在org-journal加载cns-mode
|
||||
(add-hook 'org-journal-mode-hook
|
||||
(lambda ()
|
||||
(global-cns-mode-enable-in-buffer)))
|
||||
|
||||
(provide 'init-org)
|
||||
|
||||
Reference in New Issue
Block a user