[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to fontify region according to mode
From: |
Dan Davison |
Subject: |
How to fontify region according to mode |
Date: |
Sat, 14 Aug 2010 13:14:02 -0400 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
I want to write a function to fontify a region according to a certain
mode, and I tried the following tactic (see function below):
- get the value of `font-lock-defaults' from a buffer in the target mode
and bind it inside a let
- bind a bunch of other font-lock variable names to stop them being
overwritten
- call `font-lock-set-defaults'
- call `font-lock-fontify-region'
It didn't seem to work. Could someone suggest how to alter this so that
it works, or is this approach fundamentally flawed?
(defun dan/font-lock-fontify-region (mode start end)
(let ((font-lock-defaults
(with-temp-buffer
(funcall mode)
font-lock-defaults))
font-lock-keywords
font-lock-keywords-only
font-lock-keywords-case-fold-search
font-lock-syntax-table
font-lock-beginning-of-syntax-function)
(font-lock-set-defaults)
(font-lock-fontify-region start end)))
I want the rest of the buffer to remain unaltered and, for now, I'm not
looking for a solution involving mumamo/multi-mode etc.
Thanks,
Dan
- How to fontify region according to mode,
Dan Davison <=