nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] configurable part separator lines

2014-04-29 11:34:21
in the absence of any more comments, i've pushed this change (which
makes all part separator lines configurable) to master.  i've been
using it for a week now, and it seems solid -- i've been testing quite
a bit with various kinds of messages while writing some new wrapper
scripts, so it's gotten some exercise.

(i actually think it would be safe for 1.6, but it's late in that
game, and i'm about to go away for a week, so i'm not going to push
for that.  if someone else thinks it would be okay, then by all means
pull it in.)

in case anyone's interested, i use this marker format:

    [*@[ part %{part} - %{content-type} - %<{description}\
    %{description}%?{cdispo-filename}%{cdispo-filename}%|%{ctype-name}%> \
    %<(unseen)\(suppressed\)%> ]@*]

the ugly extra punctuation at either end makes it fairly reliable to
post-process to either add color or remove the markers entirely.  here
are some snippets of what i've been using:

    setcolors()
    {
        if [ -t 1 ]
        then
            RED="$(printf \\033[31m)"
            GREEN="$(printf \\033[32m)"
            YELLOW="$(printf \\033[33m)"
            BLUE="$(printf \\033[34m)"
            NORMAL="$(printf \\033[m)"
        fi
    }

    hilite_headers()
    {
        sed -e "1,/^$/s/^Subject:\(.*\)/Subject:${RED}\1${NORMAL}/"  \
            -e "1,/^$/s/^From:\(.*\)/From:${BLUE}\1${NORMAL}/" 
    }

    hilite_part_markers()
    {
        # 1: removes default top-level non-mime text/plain separator
        # 2: colorize all other part separator lines
        # 2a: and add an extra newline, for readablility
        sed -e "/\[\*@\(\[ part  - text\/plain -   \]\)@\*\]/d" \
            -e "s/\[\*@\(\[ part .*\]\)@\*\]/${GREEN}\1${NORMAL}\n/"
    }

    hilite()
    {
        hilite_headers | hilite_part_markers
    }

    ptext()
    {
        MHSHOW=$Mail/mhn.block_html \
            mhshow -type text/plain "$@" | hilite | less
    }

    remove_part_markers()
    {
        # delete part markers entirely if they're the whole line,
        # otherwise just remove that part of the line.
        sed -e '/^\[\*@\(\[ part .* \]\)@\*\]$/d' \
            -e 's/\[\*@\(\[ part .* \]\)@\*\]//'
    }

paul

i wrote:
ken wrote:
 > I'm not fond of the idea of the new pseudo-component you created called
 > "hidden".  I know you can use it as a boolean, but defining it to a fixed
 > string seems wrong to me.
 > 
 > There is an existing function called %(unseen); I think it would be 
perfect
 > for this.  The way you pass in values to unseen is via the "dat" array

and right you were.  this seems cleaner, and the name works nicely.  new
draft patch attached.


----------------------
 paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma, 
where it's 38.3 degrees)

----------------------
 paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma, 
where it's 39.4 degrees)

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>