.emacs.d/lisp/init-org.el
2024-12-28 10:59:10 +08:00

80 lines
3.1 KiB
EmacsLisp

;;; init-org.el --- Org settings -*- lexical-binding: t -*-;;; Commentary:
;;; Code:
(use-package org
:config
; Line Truncation @ https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html
(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))
; Dynamic Headline Numbering @ https://orgmode.org/manual/Dynamic-Headline-Numbering.html
(setq org-startup-numerated t)
; Hide emphasis markup characters in buffers @ https://orgmode.org/manual/Emphasis-and-Monospace.html
(setq org-hide-emphasis-markers t)
; https://orgmode.org/manual/Fast-access-to-TODO-states.html
; https://orgmode.org/guide/Progress-Logging.html
(setq org-todo-keywords
'((sequence "TODO(t)" "HOLD(h!)" "WIP(i!)" "WAIT(w!)" "|" "DONE(d!)" "CANCELLED(c@/!)")
(sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f!)")))
; https://orgmode.org/manual/Faces-for-TODO-keywords.html
(setq org-todo-keyword-faces
'(("TODO" . (:foreground "#7c7c75" :weight bold))
("HOLD" . (:foreground "#feb24c" :weight bold))
("WIP" . (:foreground "#0098dd" :weight bold))
("WAIT" . (:foreground "#9f7efe" :weight bold))
("DONE" . (:foreground "#50a14f" :weight bold))
("CANCELLED" . (:foreground "#ff6480" :weight bold))
("REPORT" . (:foreground "magenta" :weight bold))
("BUG" . (:foreground "red" :weight bold))
("KNOWNCAUSE" . (:foreground "yellow" :weight bold))
("FIXED" . (:foreground "green" :weight bold))))
)
(use-package org-modern
:hook (after-init . (lambda ()
(setq org-modern-hide-stars 'leading)
(global-org-modern-mode t)))
:config
(setq org-modern-table nil))
(use-package org-appear
:hook
(org-mode . org-appear-mode)
:config
(setq org-appear-autolinks t)
(setq org-appear-autosubmarkers t)
(setq org-appear-autoentities t)
(setq org-appear-autokeywords t)
(setq org-appear-inside-latex t)
)
(use-package org-bars
:vc (org-bars :url "https://github.com/tonyaldon/org-bars.git"
:rev :newest)
:hook (org-mode . org-bars-mode))
;; org-mode 导出为 markdown @ https://emacs-china.org/t/org-mode-markdown/17393/3
;; 如果将 #+begin_src #+end_src 紧跟标题, 则导出效果正常 (workaround)
(use-package ox-gfm
:after org
:config
(setq org-export-with-sub-superscripts nil)
(setq org-export-headline-levels 5)
(setq org-export-coding-system 'utf-8)
(setq org-export-with-broken-links 'mark)
(setq org-link-file-path-type 'relative)
;; 定义自动导出为 Markdown 的函数
(defun export-org-to-markdown-if-org-mode ()
"Export current org-mode buffer to a markdown file if in org-mode."
(when (eq major-mode 'org-mode) ; 确保当前缓冲区是 org-mode
(org-gfm-export-to-markdown)))
;; 添加到 org-mode 的保存钩子中
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'after-save-hook 'export-org-to-markdown-if-org-mode nil 'make-it-local))))
(provide 'init-org)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-org.el ends here