RE: How to highlight columns?

"Dan Bar Dov" <[email protected]> Wed, 24 Aug 2005 12:35:32 +0300
Newsgroups gmane.emacs.xemacs.general
Message-ID <[email protected]>
Here's my unsuccessful attempt to count tabs as 8 chars

(defun highlight-tail1 ()
  (interactive)
  (let ((face (find-face 'highlight)))
    (while (not (equal (point) (point-max)))
      (let* ((start (progn (beginning-of-line 1)
			   (while (and (count < 80) (not (equal (point) (end-of-line))))
			     (setq count (+ count (if (looking-at '\t') 8 1)))
			     (forward-char))
			   (point)))
	     (end (end-of-line))
	     (extent (make-extent start end)))
	(set-extent-property extent 'face face)
	(goto-char end))))) 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Dan Bar Dov
> Sent: Wednesday, August 24, 2005 10:25 AM
> To: Glynn Clements
> Cc: [email protected]
> Subject: RE: How to highlight columns?
> 
> Good, except as you noted the tabs. Can it use the 
> "tab-width" to compensate?
> 
> Dan 
> 
> > -----Original Message-----
> > From: Glynn Clements [mailto:[email protected]]
> > Sent: Tuesday, August 23, 2005 9:41 PM
> > To: Dan Bar Dov
> > Cc: [email protected]
> > Subject: Re: How to highlight columns?
> > 
> > 
> > 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]>
> > 
> 
>