all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to fontify region according to mode
@ 2010-08-14 17:14 Dan Davison
  2010-08-14 17:21 ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Davison @ 2010-08-14 17:14 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-16 14:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-14 17:14 How to fontify region according to mode Dan Davison
2010-08-14 17:21 ` Lennart Borgman
2010-08-14 18:08   ` Dan Davison
2010-08-14 18:35     ` Lennart Borgman
2010-08-16 13:28       ` Dan Davison
2010-08-16 14:39         ` Lennart Borgman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.