From 2b80a3c1f9c05f8b5d48c16a57ef2e4e11b21fec Mon Sep 17 00:00:00 2001 From: noa Date: Tue, 29 Apr 2025 15:19:05 +0800 Subject: Org updates --- emacs/init.el | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 7 deletions(-) (limited to 'emacs') diff --git a/emacs/init.el b/emacs/init.el index 3dbf1f4..71bf065 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -465,14 +465,22 @@ (biblio-bibtex-use-autokey t) (biblio-download-directory "~/Documents/Library/Papers")) + ;;; Taking notes (use-package org :defer t :init :custom + (org-modules '(ol-doi ol-w3m ol-bbdb ol-bibtex ol-docview ol-gnus ol-info ol-irc ol-mhe ol-rmail ol-eww org-habit)) + (org-clock-sound "~/Library/Ringtones/Loud ding.wav") + (org-imenu-depth 3) (org-tags-column 0) - (org-agenda-files '("~/Documents/Notes.org" "~/Documents/Notes/")) + (org-agenda-files '("~/Documents/Agenda.org")) + (org-refile-targets '((org-agenda-files :maxlevel . 3))) + (org-refile-use-outline-path 'file) + (org-outline-path-complete-in-steps nil) + (org-refile-allow-creating-parent-nodes 'confirm) (org-replace-disputed-keys t) (org-support-shift-select 'always) ;; Still refuses to fix on timestamps :/ (org-log-done 'time) @@ -488,34 +496,99 @@ (org-src-tab-acts-natively t) (org-edit-src-content-indentation 0) (org-use-sub-superscripts '{}) + (org-export-preserve-breaks t) + (org-agenda-remove-tags t) + (org-agenda-prefix-format '((agenda . " %?-14t% s") + (todo . "") + (tags . " %i %-12:c") + (search . " %i %-12:c"))) + (org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")) + (org-agenda-deadline-leaders '("Deadline: " "In %3d d.: " "%2d d. ago: ")) + (org-agenda-time-grid '((daily today require-timed remove-match) + nil + "" "")) + (org-agenda-show-current-time-in-grid nil) + (org-agenda-format-date "%n%Y-%m-%d %A") + (org-agenda-span 'day) + (org-agenda-custom-commands + '(("n" "Agenda and unassigned to-dos" + ((agenda "") + (alltodo "" + ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done + 'scheduled 'deadline)) + (org-agenda-overriding-header "\nDrifting tasks"))))))) + + ;; ((agenda "") + ;; (tags-todo "-SCHEDULED={.+}"))))) + (org-agenda-skip-scheduled-if-deadline-is-shown t) + (org-treat-insert-todo-heading-as-state-change t) + (org-log-into-drawer t) :custom-face (org-table ((t (:inherit fixed-pitch)))) - (org-date ((t (:inherit fixed-pitch :underline t))))) + (org-date ((t (:inherit fixed-pitch :underline t)))) + ;; :bind (:map org-mode-map + ;; ([remap imenu] . consult-org-heading)) + ) + +(defun log-todo-next-creation-date (&rest ignore) + "Log NEXT creation time in the property drawer under the key 'ACTIVATED'" + (when (and (string= (org-get-todo-state) "NEXT") + (not (org-entry-get nil "ACTIVATED"))) + (org-entry-put nil "ACTIVATED" (format-time-string "[%Y-%m-%d]")))) +(add-hook 'org-after-todo-state-change-hook #'log-todo-next-creation-date) (use-package oc + :defer t :after org :custom - (org-cite-global-bibliography '("~/Documents/Library/References.bib")) + (org-cite-global-bibliography '("~/Documents/References.bib")) (org-cite-export-processors '((beamer csl) (latex csl) (t csl)))) + (use-package oc-csl + :defer t :after oc :custom - (org-cite-csl-styles-dir "~/Documents/Library/Citations styles")) + (org-cite-csl-styles-dir "~/Library/Citation styles")) + +;; Support chinese in latex pdf export +(require 'ox-latex) +(add-to-list 'org-latex-classes '("ctexart" "\\documentclass{ctexart}" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + +(add-to-list 'org-latex-classes '("ctexbook" "\\documentclass[11pt]{ctexbook}" ("\\part{%s}" . "\\part*{%s}") + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) + + ;; Not working how i want (use-package org-capture :bind ("C-c c" . org-capture) :custom (org-capture-templates - '(("d" "Today's diary" entry - (file+headline "~/Documents/Notes.org" "Diary") - "** %u\n%?")))) + '(("d" "Today's diary" plain (file+olp+datetree "~/Documents/Diary.org") + "%?") + ("t" "Todo" entry (file "~/Documents/Agenda.org") + "* TODO %?\n%U\n%a\n%i") + ("s" "Source" entry (file "~/Documents/Sources.org") + "* TODO %?\n%U\n#+begin_src bibtex :tangle References.bib\n#+end_src\n") + ("a" "Appointment" entry (file"~/Documents/Agenda.org") + "* %?\n%T\n" :time-prompt t) + ))) ;; See https://llazarek.github.io/blog/2018/07/organization-with-org-mode.html ;; for configuring the org agenda +(use-package org-agenda + :bind ("C-c a" . org-agenda)) ;; Experimental website generator (use-package ox-hugo -- cgit 1.4.1-2-gfad0