刚用emacs/spacemacs, 折腾配置文件就遇到下面这个问题. 在~/.spacemacs中, 最后一行load-file了这个文件.
;; Jiaxing Zhang's GNU/Emacs file
;; Note: This is for org-mode related settings
(require 'org)
; (define-key global-map "\C-cl" 'org-store-link)
; (define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-log-done 'time)
(setq org-columns-default-format "%7TODO(To Do) %30ITEM(Task) %6EFFORT(estimate){:} %SCHEDULED %DEADLINE %6CLOCKSUM(Clock)")
; (setq org-log-done 'note)
; (setq org-emphasis-alist
; '(("*" (bold :foreground "Orange" ))
; ("/" italic)
; ("_" underline)
; ("=" (:background "maroon" :foreground "white"))
; ("~" (:background "deep sky blue" :foreground "MidnightBlue"))
; ("+" (:strike-through t))))
; (setq org-todo-keywords
; '((sequence "TODO" "IN-PROGRESS" "WAITING" "DONE")))
(setq org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "INFLIGHT(f)" "DONE(d)")))
;; flyspell-mode on for org-mode
; (add-hook 'org-mode-hook 'turn-on-flyspell)
;; flyspell-mode to ignore in code block
(add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
(setq org-agenda-files (list "/Users/quebec/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/org/todo.org"))
; (setq org-capture-templates
; '(("t" "Todo" entry (file+headline "~/notes/org/gtd.org" "Tasks")
; "* TODO %?\n %i\n %a")
; ("s" "Scratch" entry (file+datetree "~/notes/org/scratch.org")
; "* %?\nEntered on %U\n %i\n %a")))
(global-set-key (kbd "C-<right>") 'org-do-demote)
(global-set-key (kbd "C-<left>") 'org-do-promote)
(define-key global-map "\C-ct"
(lambda () (interactive) (org-capture nil "t")))
(define-key global-map "\C-cs"
(lambda () (interactive) (org-capture nil "s")))
;;; To save the clock history across Emacs sessions, use
; (if (file-exists-p org-clock-persist-file)
; ;; (setq org-clock-persist 'history)
; (org-clock-persistence-insinuate)
; (shell-command (concat "touch " org-clock-persist-file)))
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
; {{{3 latex
(setq org-latex-pdf-process '("xelatex --shell-escape -interaction nonstopmode %f"))
;; 生成PDF后清理辅助文件
;; https://answer-id.com/53623039
(setq org-latex-logfiles-extensions
(quote ("lof" "lot" "tex~" "tex" "aux"
"idx" "log" "out" "toc" "nav"
"snm" "vrb" "dvi" "fdb_latexmk"
"blg" "brf" "fls" "entoc" "ps"
"spl" "bbl" "xdv")))
;; 图片默认宽度
(setq org-image-actual-width '(300))
(setq org-export-with-sub-superscripts nil)
;; 不要自动创建备份文件
(setq make-backup-files nil)
;; elegantpaper.cls
;; https://github.com/ElegantLaTeX/ElegantPaper/blob/master/elegantpaper.cls
(with-eval-after-load 'ox-latex
;; http://orgmode.org/worg/org-faq.html#using-xelatex-for-pdf-export
;; latexmk runs pdflatex/xelatex (whatever is specified) multiple times
;; automatically to resolve the cross-references.
; (setq org-latex-pdf-process '("latexmk -xelatex -quiet -shell-escape -f %f"))
(setq org-latex-listings t)
(add-to-list 'org-latex-classes
'("elegantpaper"
"\\documentclass[lang=cn]{elegantpaper}
[NO-DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
)
; {{{3 fragtog
(use-package org-fragtog
:hook
(org-mode . org-fragtog-mode)
:config
(setq org-startup-with-latex-preview t)
(setq org-latex-create-formula-image-program 'dvisvgm)
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
:custom
(org-fragtog-preview-delay 1.0))
; {{{3 export
;; Define a function for turning a single subtree into a top-level tree
;; (:export: headings might be located at an arbitrary nesting level,
;; so a single call to "org-promote-subtree" is not enough):
(defun org-promote-to-top-level ()
"Promote a single subtree to top-level."
(let ((cur-level (org-current-level)))
(loop repeat (/ (- cur-level 1) (org-level-increment))
do (org-promote-subtree))))
;; Define a function that applies "org-promote-to-top-level"
;; to each :export: subtree:
(defun org-export-trees-to-top-level (backend)
"Promote all subtrees tagged :export: to top-level.
BACKEND is the export back-end being used, as a symbol."
(org-map-entries 'org-promote-to-top-level "+export"))
;; Make org-mode run "org-export-subtrees-to-top-level" as part of the export
;; process:
(add-hook 'org-export-before-parsing-hook 'org-export-trees-to-top-level)
其中初始化了(setq org-image-actual-width '(300))
, 但是, 启动emacs后发现并没有生效, 于是用describle-variable查看, 发现它并没有被正确设置.
org-image-actual-width is a variable defined in ‘org.el’.
Its value is nil
Original value was t
但我又用describle-symbol查看org-export-trees-to-top-level
, 发现这个已经被设置了, 说明这个文件是被正确执行了. 那么为什么org-image-actual-width的设置完全没起作用呢?
而且, 当我启动emacs, 再次load-file这个文件, 它又被正确设置了:
org-image-actual-width is a variable defined in ‘org.el’.
Its value is (300)
Original value was t
那么启动的时候怎么就没被正确设置呢? 一头雾水. 平台是mac, emacs是27.2.