May 3, 2014: Initial answer -- apparent working solution.
A tab has a character code of
9
.The width of a tab is equal to only one (1)
point
.A tab can be equal to one or more columns wide, depending upon the
tab-width
.When dealing with tabs, determining the type of character that follows a particular
column
is problematic because . . . [to be filled in when I understand more].When dealing with tabs, moving forward one (1)
point
and looking back is also problematic because . . . [to be filled in when I understand more].
The working solution is to move one (1) column
ahead and check the preceding character code -- if it is still a character code of 9
, then do not place an overlay (at that preceding column). If the target column was already on a non-tab character, then moving forward one (1) column
and looking back should logically yield the proper result.
(defun test ()
(interactive)
(let* (my-last-column
my-o-beg-a my-o-end-a (my-col-a 3)
my-o-beg-b my-o-end-b (my-col-b 28)
my-o-beg-c my-o-end-c (my-col-c 29) )
(generate-test-buffer)
(goto-char (point-max))
(while (re-search-backward "\n" (point-min) t)
(setq my-last-column (current-column))
(setq my-o-beg-a (progn (move-to-column my-col-a) (point)))
(setq my-o-end-a (+ 1 my-o-beg-a))
(setq my-o-beg-b (progn (move-to-column my-col-b) (point)))
(setq my-o-end-b (+ 1 my-o-beg-b))
(setq my-o-beg-c (progn (move-to-column my-col-c) (point)))
(setq my-o-end-c (+ 1 my-o-beg-c))
(when (and
(< my-col-a my-last-column)
(not (progn (move-to-column (+ 1 my-col-a)) (eq (preceding-char) 9))))
(overlay-put (make-overlay my-o-beg-a my-o-end-a) 'face '(
(background-color . "cyan")
(foreground-color . "black") )))
(when (and
(< my-col-b my-last-column)
(not (progn (move-to-column (+ 1 my-col-b)) (eq (preceding-char) 9))))
(overlay-put (make-overlay my-o-beg-b my-o-end-b) 'face '(
(background-color . "yellow")
(foreground-color . "black") )))
(when (and
(< my-col-b my-last-column)
(not (progn (move-to-column (+ 1 my-col-c)) (eq (preceding-char) 9))))
(overlay-put (make-overlay my-o-beg-c my-o-end-c) 'face '(
(background-color . "red")
(foreground-color . "black") ))) )))