8 Sep 2005 00:28
RE: How to highlight columns?
<matthew.miner <at> misys.com>
2005-09-07 22:28:14 GMT
2005-09-07 22:28:14 GMT
Actually, if I understand it correctly, the script below, instead of
assuming that a tab is one char, assumes that a tab is 8 chars (or whatever
tab-width is) Since a tab can vary between 1 and tab-width chars, this is
just as wrong as counting tabs as 1 char.
Since tabs are an issue, PERHAPS it's acceptable to untabify the region,
then tabify it when done?
I think what I might do in your shoes is:
1. Do my work, whatever it is.
2. Save it when done.
3. Untabify the file (all tabs-> spaces) -- depending upon the rules for
your file, the file might now be considered 'damaged'...
4. Run my check to make sure the file is 'valid' (all lines < 80 chars).
5. Reload and fix the file if necessary.
That would properly preserve the valid tabs, if any. If there are no
"literal tabs" - i.e., you can safely convert all tabs to spaces, and then
back - I would work in non-tab mode, do my validation, then tabify.
Guaranteed correct results. (And something you could easily code as a
keystroke macro).
Also, FWIW, I don't know what system you are working on, but most systems
I've worked on that were sensitive to line length did NOT like tabs at all
(such as MVS and its 80-column-card-image orientation). So, perhaps it's
appropriate to never even use tabs?
"Dan Bar Dov"
<danb <at> voltaire.com> To: <matthew.miner <at> misys.com>, <xemacs-news <at> xemacs.org>
Sent by: cc:
xemacs-news-bounces Subject: RE: How to highlight columns?
<at> xemacs.org
09/05/2005 12:06 PM
Thanks but your suggestions do not work.
The problem is that regex counts TAB character as 1. The requirement is to
limit lines to 80 characters long, where each TAB count as tab-width.
This beats all regex methods including font-lock-mode.
The best I have so far (when I'll make it work) is
;(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') tab-width 1)))
; (forward-char))
; (point)))
; (end (end-of-line))
; (extent (make-extent start end)))
; (set-extent-property extent 'face face)
; (goto-char end)))))
Dan
> -----Original Message-----
> From: xemacs-news-bounces <at> xemacs.org
> [mailto:xemacs-news-bounces <at> xemacs.org] On Behalf Of
> matthew.miner <at> misys.com
> Sent: Monday, August 22, 2005 6:27 PM
> To: xemacs-news <at> xemacs.org
> Subject: Re: How to highlight columns?
>
> Sorry, forgot:
>
> list-matching-lines for regex .\{80\}.+
chars (i.e., without using foint-lock).
>
> ----- Forwarded by Matthew Miner/IQFS on 08/22/2005 11:25 AM -----
>
>
> Matthew Miner
>
> To:
> <xemacs-news <at> xemacs.org>
> 08/22/2005 11:25 cc:
>
> AM Subject: Re:
> How to highlight columns?(Document link: Matthew Miner)
>
>
>
>
>
>
>
> Sorry, no time to test in font lock, but, start with the regex:
>
> .\{80\}.+
> Shows lines longer than 80 chars.
>
> Add a grouping to isolate the after 80 stuff:
> .\{80\}\(.+\)
>
> Then add to your font-lock list...
> ...
> '(".\\{80\\}\\(.\\)" 1 font-lock-string-face)
> ...
>
> I'm guessing that's a start...
> Hope it helps.
>
>
>
>
>
> "Dan Bar Dov"
>
> <danb <at> voltaire.com> To:
> <xemacs-news <at> xemacs.org>
> Sent by: cc:
>
> xemacs-news-bounces Subject:
> How to highlight columns?
> <at> xemacs.org
>
>
>
>
>
> 08/21/2005 04:38 AM
>
>
>
>
>
>
>
>
>
>
> 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.
>
> Any ideas?
>
> Dan
>
>
>
>
>
>
>
> This email and any attachments have been scanned for known
> viruses using
> multiple scanners. We believe that this email and any
> attachments are virus
> free, however the recipient must take full responsibility for virus
> checking. This email message is intended for the named
> recipient only. It
> may be privileged and/or confidential. If you are not the
> intended named
> recipient of this email then you should not copy it or use it for any
> purpose, nor disclose its contents to any other person. You
> should contact
> the Misys Banking and Securities Division as shown below so
> that we can
> take appropriate action at no cost to yourself. Misys Banking and
> Securities Division, 1 St George's Road, Wimbledon, London, SW19 4DR,
> England. Email: banking.postmaster <at> misys.com. Tel: +44 (0) 20
> 8879 1188
> Fax: +44 (0) 20 8947 3373
>
>
>
>
RSS Feed