org中的source code, 很多主题都会把header, drawer显示出来.
比如最适合org阅读的leuven主题
当文档中有很多块代码时,将` +begin_src`的部分显示出来, 相当干扰和分散注意力.
doom-challenger-deeper这个主题, 做得比较出色
默认不显示header的部分.
但是这个主题, 看着比较暗鸦, 没有多大的精神头,
求推荐一个类似功能的主题.
org中的source code, 很多主题都会把header, drawer显示出来.
比如最适合org阅读的leuven主题
当文档中有很多块代码时,将` +begin_src`的部分显示出来, 相当干扰和分散注意力.
doom-challenger-deeper这个主题, 做得比较出色
默认不显示header的部分.
但是这个主题, 看着比较暗鸦, 没有多大的精神头,
求推荐一个类似功能的主题.
Describe-face然后customize-face
w, 这个终极解决方法, 审美和技术含量很高, 一个流行的主题, 修改一处, 可能会导致多处看起来不舒服, 然后再去修改, 多米诺骨牌一样.
(with-eval-after-load 'org
(defvar-local rasmus/org-at-src-begin -1
"Variable that holds whether last position was a ")
(defvar rasmus/ob-header-symbol ?☰
"Symbol used for babel headers")
(defun rasmus/org-prettify-src--update ()
(let ((case-fold-search t)
(re "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*")
found)
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(goto-char (match-end 0))
(let ((args (org-trim
(buffer-substring-no-properties (point)
(line-end-position)))))
(when (org-string-nw-p args)
(let ((new-cell (cons args rasmus/ob-header-symbol)))
(cl-pushnew new-cell prettify-symbols-alist :test #'equal)
(cl-pushnew new-cell found :test #'equal)))))
(setq prettify-symbols-alist
(cl-set-difference prettify-symbols-alist
(cl-set-difference
(cl-remove-if-not
(lambda (elm)
(eq (cdr elm) rasmus/ob-header-symbol))
prettify-symbols-alist)
found :test #'equal)))
;; Clean up old font-lock-keywords.
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords (prettify-symbols--make-keywords))
(font-lock-add-keywords nil prettify-symbols--keywords)
(while (re-search-forward re nil t)
(font-lock-flush (line-beginning-position) (line-end-position))))))
(defun rasmus/org-prettify-src ()
"Hide src options via `prettify-symbols-mode'.
`prettify-symbols-mode' is used because it has uncollpasing. It's
may not be efficient."
(let* ((case-fold-search t)
(at-src-block (save-excursion
(beginning-of-line)
(looking-at "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*"))))
;; Test if we moved out of a block.
(when (or (and rasmus/org-at-src-begin
(not at-src-block))
;; File was just opened.
(eq rasmus/org-at-src-begin -1))
(rasmus/org-prettify-src--update))
;; Remove composition if at line; doesn't work properly.
;; (when at-src-block
;; (with-silent-modifications
;; (remove-text-properties (match-end 0)
;; (1+ (line-end-position))
;; '(composition))))
(setq rasmus/org-at-src-begin at-src-block)))
(defun rasmus/org-prettify-symbols ()
(mapc (apply-partially 'add-to-list 'prettify-symbols-alist)
(cl-reduce 'append
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?✎) ;; ➤ 🖝 ➟ ➤ ✎
("#+end_src" . ?□) ;; ⏹
("#+header:" . ,rasmus/ob-header-symbol)
("#+begin_quote" . ?»)
("#+end_quote" . ?«)))))
(turn-on-prettify-symbols-mode)
(add-hook 'post-command-hook 'rasmus/org-prettify-src t t))
(add-hook 'org-mode-hook #'rasmus/org-prettify-symbols))
上面这段代码可以吧 #+begin_src 转换成这样
直接设置 prettify-symbols-alist
就行了
(setq-default prettify-symbols-alist '(("#+BEGIN_SRC" . "✎")
("#+END_SRC" . "□")
("#+begin_src" . "✎")
("#+end_src" . "□")))
(add-hook 'org-mode-hook 'prettify-symbols-mode)
好看诶, 能参考下代码嘛
如果你用的是Doom:
(after! org
(appendq! +ligatures-extra-symbols
`(:checkbox "☐"
:pending "◼"
:checkedbox "☑"
:list_property "∷"
:ellipses "…"
:arrow_right "→"
:arrow_left "←"
:title "❤"
:subtitle "𝙩"
:author "✍"
:date "⚓"
:property "☸"
:options "⌥"
:latex_class "🄲"
:latex_header "⇥"
:beamer_header "↠"
:attr_latex "🄛"
:attr_html "🄗"
:begin_quote "❮"
:end_quote "❯"
:caption "☰"
:header "›"
:results "🍌"
:begin_export "⏩"
:end_export "⏪"
:properties "⚙"
:end "∎"
:priority_a ,(propertize "🅰" 'face 'all-the-icons-red)
:priority_b ,(propertize "🅱" 'face 'all-the-icons-orange)
:priority_c ,(propertize "🅲" 'face 'all-the-icons-yellow)
:priority_d ,(propertize "🅳" 'face 'all-the-icons-green)
:priority_e ,(propertize "🅴" 'face 'all-the-icons-blue)))
(set-ligatures! 'org-mode
:merge t
:checkbox "[ ]"
:pending "[-]"
:checkedbox "[X]"
:list_property "::"
:em_dash "---"
:ellipsis "..."
:arrow_right "->"
:arrow_left "<-"
:title "#+title:"
:subtitle "#+subtitle:"
:author "#+author:"
:date "#+date:"
:property "#+property:"
:options "#+options:"
:latex_class "#+latex_class:"
:latex_header "#+latex_header:"
:beamer_header "#+beamer_header:"
:attr_latex "#+attr_latex:"
:attr_html "#+attr_latex:"
:begin_quote "#+begin_quote"
:end_quote "#+end_quote"
:caption "#+caption:"
:header "#+header:"
:begin_export "#+begin_export"
:end_export "#+end_export"
:results "#+RESULTS:"
:property ":PROPERTIES:"
:end ":END:"
:priority_a "[#A]"
:priority_b "[#B]"
:priority_c "[#C]"
:priority_d "[#D]"
:priority_e "[#E]")
(plist-put +ligatures-extra-symbols :name "⁍")
)
完整配置地址: GitHub - lijigang/emacs.d: Personal emacs config with doom, especially for Orgmode use.
这个主题是什么呀,怎么设置的
nano-emacs theme