[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
font-lock-add-keywords in hi-lock.el
From: |
Juri Linkov |
Subject: |
font-lock-add-keywords in hi-lock.el |
Date: |
Wed, 14 Dec 2005 19:11:22 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
hi-lock-mode breaks existing highlighting when its regexps cover
areas highlighted by standard font-lock keywords (non-syntactic).
This is especially undesirable on large highlighted areas like
outline headings etc.
A good solution for this problem is to append new hi-lock keywords
at the end of the current highlighting list instead of adding them
at the beginning. Thus hi-lock regexps always will be placed over
standard highlighted keywords.
A patch below sets the 3rd arg `HOW' (former `APPEND') of
`font-lock-add-keywords' to t. (The parameter `OVERRIDE' of the
MATCH-HIGHLIGHT form is already t on every hi-lock keyword, so this
will work correctly.)
Index: lisp/hi-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v
retrieving revision 1.35
diff -c -r1.35 hi-lock.el
*** lisp/hi-lock.el 10 Dec 2005 11:47:28 -0000 1.35
--- lisp/hi-lock.el 14 Dec 2005 17:07:29 -0000
***************
*** 526,532 ****
"Highlight REGEXP with face FACE."
(let ((pattern (list regexp (list 0 (list 'quote face) t))))
(unless (member pattern hi-lock-interactive-patterns)
! (font-lock-add-keywords nil (list pattern))
(push pattern hi-lock-interactive-patterns)
(let ((buffer-undo-list t)
(inhibit-read-only t)
--- 543,549 ----
"Highlight REGEXP with face FACE."
(let ((pattern (list regexp (list 0 (list 'quote face) t))))
(unless (member pattern hi-lock-interactive-patterns)
! (font-lock-add-keywords nil (list pattern) t)
(push pattern hi-lock-interactive-patterns)
(let ((buffer-undo-list t)
(inhibit-read-only t)
***************
*** 544,550 ****
(when (or hi-lock-file-patterns patterns)
(font-lock-remove-keywords nil hi-lock-file-patterns)
(setq hi-lock-file-patterns patterns)
! (font-lock-add-keywords nil hi-lock-file-patterns)
(font-lock-fontify-buffer)))
(defun hi-lock-find-patterns ()
--- 561,567 ----
(when (or hi-lock-file-patterns patterns)
(font-lock-remove-keywords nil hi-lock-file-patterns)
(setq hi-lock-file-patterns patterns)
! (font-lock-add-keywords nil hi-lock-file-patterns t)
(font-lock-fontify-buffer)))
(defun hi-lock-find-patterns ()
***************
*** 573,580 ****
(defun hi-lock-font-lock-hook ()
"Add hi lock patterns to font-lock's."
(if font-lock-mode
! (progn (font-lock-add-keywords nil hi-lock-file-patterns)
! (font-lock-add-keywords nil hi-lock-interactive-patterns))
(hi-lock-mode -1)))
(provide 'hi-lock)
--- 590,598 ----
(defun hi-lock-font-lock-hook ()
"Add hi lock patterns to font-lock's."
(if font-lock-mode
! (progn
! (font-lock-add-keywords nil hi-lock-file-patterns t)
! (font-lock-add-keywords nil hi-lock-interactive-patterns t))
(hi-lock-mode -1)))
(provide 'hi-lock)
--
Juri Linkov
http://www.jurta.org/emacs/