Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

org-mode

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?

like image 599
monotux Avatar asked Sep 21 '10 07:09

monotux


2 Answers

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.

like image 142
huaiyuan Avatar answered Oct 05 '22 20:10

huaiyuan


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

like image 27
Jisang Yoo Avatar answered Oct 05 '22 19:10

Jisang Yoo