font tweaking

John Beck <[email protected]> Sat, 23 Apr 2005 16:23:27 -0700
Newsgroups gmane.mail.exmh.devel
Message-ID <[email protected]>
I thought it might be nice to extend the various text highlighting tricks
to include one which shows "starred" text (i.e., something between "*"
characters, often used for emphasis, like "I *really* mean it") as bold.
I added the following to Hook_MsgHighlight_jcl-beautify in msgShow.tcl

        if {[regexp {\*.+\*} $txt bolded]} {
            if {[regexp {^[^*]*\*} $txt beforefirststar]} {
                set firstlen [expr [string length $beforefirststar]]
                set endpos [expr $firstlen + [string length $bolded] - 2]
                $t tag add embolded $idx.[expr $firstlen] $idx.[expr $endpos]
            } else {
                $t tag add embolded $idx.0 $idx.end
            }
            continue
        }

and put this in my default file:

*b_embolded:    -font 9x15bold

And it works, sometimes.  If I change the default file line to:

*b_embolded:    -foreground red

then it works all the time.  But if I try to change the font rather than
the color, it doesn't work if the message in question has a charset value
in its Content-Type: header.  I.e.:

Content-Type: text/plain

works and even:

Content-Type: text/plain; charset=

works, but

Content-Type: text/plain; charset=x

does not work, for any non-null value of x.

Looking at the code, the cause of the discrepancy appeared to be this chunk
of code from MimeParseSingle in mime.c:

            if [info exists mimeHdr($part,param,charset)] {
                set tag [MimeSetCharset $tkw $part]
                $tkw tag remove noteTag "insert -1line"  end
                $tkw tag add $tag insert end
                if [info exists firstLinePosition] {
                    seek $fileIO $firstLinePosition
                }
                Mime_SetFileEncoding $fileIO $part
                if [info exists firstLinePosition] {
                    gets $fileIO firstLine
                }
            }  else {
                set tag {}
            }

and in fact, if I replace the first three lines of the if block with the one
line from the else block, then the problem goes away without any *apparent*
side-effects.  But as I only have the vaguest idea what this code is doing
and no idea why, I thought it would be wise to consult here before making
such a change.  Who has clues in this area?

Thanks.
-- John