Re: How to highlight columns?
Glynn Clements <[email protected]> Tue, 23 Aug 2005 19:40:58 +0100
| Newsgroups | gmane.emacs.xemacs.general |
|---|---|
| Message-ID | <[email protected]> |
Dan Bar Dov wrote:
> I'd like to highlight all text/code that's beyond column 80.
> I cannot figure how to set font-lock to do that, not how to write an
> interactive functions to do that.
Here's a simple example:
(defun highlight-tail ()
(interactive)
(let ((exp "^.\\{1,80\\}\\(.*\\)$")
(face (find-face 'highlight)))
(while (re-search-forward exp nil t)
(let* ((start (match-beginning 1))
(end (match-end 1))
(extent (make-extent start end)))
(set-extent-property extent 'face face)
(goto-char end)))))
It highlights everything after the 80th character, which may not be
the 80th column due to characters spanning multiple columns (primarily
tabs, but also control characters using ^M or \015 display forms).
--
Glynn Clements <[email protected]>