`variable-pitch` for org-mode, fixed-pitch for tables?

人走茶凉 提交于 2019-12-17 23:44:27

问题


I found out about variable-pitch-mode through a thread here on StackOverflow, and it's very handy when writing in org-mode, easier on the eyes and everything. But using tables in org is close to worthless when using proportional fonts. And being able to use tables is one of the strengths with org-mode :-(

Is there any way to have proportional fonts for text, headings etc. but a monospace font for tables in org-mode?


回答1:


See if this works,

(set-face-attribute 'org-table nil :inherit 'fixed-pitch)

You may use C-u C-x = to see which face is in effect at a particular point.




回答2:


This code will make tables and ascii art and source code blocks to be displayed in monospace font, while preserving other font attributes for tables (such as color blue) and so on. Code is based on the other answer, the only difference is preservation.

(defun my-adjoin-to-list-or-symbol (element list-or-symbol)
  (let ((list (if (not (listp list-or-symbol))
                  (list list-or-symbol)
                list-or-symbol)))
    (require 'cl-lib)
    (cl-adjoin element list)))

(eval-after-load "org"
  '(mapc
    (lambda (face)
      (set-face-attribute
       face nil
       :inherit
       (my-adjoin-to-list-or-symbol
        'fixed-pitch
        (face-attribute face :inherit))))
    (list 'org-code 'org-block 'org-table 'org-block-background)))

If you'd like to learn how this works and how to apply this to other situations (such as Info mode), read my post on the subject



来源:https://stackoverflow.com/questions/3758139/variable-pitch-for-org-mode-fixed-pitch-for-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!