2

Since I use Emacs' org-mode for academic writing, in the beginning of my .org files, I always have a long list of latex export settings of the form:

#+LATEX_HEADER: lorem ipsum dolor
#+LATEX_HEADER: lorem ipsum dolor
...

Or code snippets scattered around the document of the form:

#+BEGIN_SRC emacs-lips
lorem ipsum dolor
#+END_SRC

All these lines (both the lorem ipsum part and the #+BLAHBLAH part), I would like to have displayed in a mono spaced font, say Liberation Mono, that respects the custom colors and custom sizes I have defined elsewhere.

I searched, and I came to the conclusion that, as suggested here, using font-lock would be the way to go. Unfortunately, by looking at examples, I couldn't figure out on my own how to set it up properly. I tried the following, but either the regexp is wrong or the syntax is wrong:

(add-hook 'org-mode-hook
          (lambda ()
           (font-lock-add-keywords nil
            '(("^\#\+.*$" 1
               font-lock-comment-face t)))))

So, the question is: has anybody been able to work this out? Or, would anyone suggest a different way?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
  • 1
    `org-mode` is too complex to just add something using `font-lock-add-keywords`. The better approach is to delve into the source-code looking at functions such as `org-set-font-lock-defaults` and a slew of other functions that are responsible for controlling the font-lock behavior in `org-mode` buffers. Find out which functions control certain behavior you wish to change, and then implement that change on a case by case basis by modifying the functions and/or variables responsible. If you find an area of `org-mode` that is not highlighted at all, then that would be a bit easier (*maybe*). – lawlist Oct 05 '16 at 02:10
  • Thank you for your comment! From what you say, I guess I have some homework to do. I thought what I wanted was relatively simple to implement. I will look at the org source-code, and update the question accordingly, as soon as I can get any further. – Carlos Alberto Rivera Carreño Oct 05 '16 at 23:09

2 Answers2

1

I was trying to get something similar going for me. I came up with the following code, after poking around other answers here and in the Emacs Stack Exchange.

(add-hook 'org-mode-hook
            '(lambda ()
               (variable-pitch-mode 1) ;; All fonts with variable pitch.
               (mapc
                (lambda (face) ;; Other fonts with fixed-pitch.
                  (set-face-attribute face nil :inherit 'fixed-pitch))
                (list 'org-code 
                      'org-link 
                      'org-block
                      'org-table
                      'org-block-begin-line
                      'org-block-end-line
                      'org-meta-line
                      'org-document-info-keyword))))

I tried it with Emacs 25.1 and Org-mode 9.0.3.

Daniel
  • 11,332
  • 9
  • 44
  • 72
0

You can always create a heading * Configuration :ARCHIVE: with the ARCHIVE tag at the top of your file. That keeps the heading from being expanded, hiding it from normal view. The ARCHIVE tag

  • [...] does not open when you attempt to do so with a visibility cycling command (see Visibility cycling). You can force cycling archived subtrees with C-TAB, or by setting the option org-cycle-open-archived-trees. Also normal outline commands like show-all will open archived subtrees.
  • During sparse tree construction (see Sparse trees), matches in archived subtrees are not exposed, unless you configure the option org-sparse-tree-open-archived-trees.
  • During agenda view construction (see Agenda views), the content of archived trees is ignored unless you configure the option org-agenda-skip-archived-trees, in which case these trees will always be included. In the agenda you can press v a to get archives temporarily included.
  • Archived trees are not exported (see Exporting), only the headline is. Configure the details using the variable org-export-with-archived-trees.
  • Archived trees are excluded from column view unless the variable org-columns-skip-archived-trees is configured to nil.

LaTeX-exporting works if you set '(org-export-with-archived-trees nil).

serv-inc
  • 35,772
  • 9
  • 166
  • 188