[email protected] wrote in
 <[email protected]>:
 |Hello,
 |
 |This is my first message here as I am a new user.
 |Initialy, I was a GNU emacs (with rmail) user but I did want to go \
 |the "old" way.

No fun that is, still.

 |After several try&error of several mail(x) program, I just discovere \
 |s-nail (or is it s-mailx?).

The idea is that it becomes the latter with v15.  v15 will bring
a new MIME (mail message internal structure) layer, and a major
change in how the code works (it currently still  uses
siglongjmp(3) to move around, in at least certain parts).

The new MIME layer will bring the possibility to send a complete
email message via the -t command line switch, for example, and
also scriptable access to message parts.
Today the former is impossible, the latter is only possible in
parts, and a bit hacky.

 |So far I am really loving it.

Expect, however, walls.  (Your mileage may vary.)

 |I am fetching my mails with mpop and I send my mail with Postfix MTA \
 |on a MacOS (nobody is perfect) system.
 |
 |Eventually I could switch to full s-nail for both mail retrieval/sending \
 |as I see it is built-in.

Yes, that would do.  I had this configuration for years.  However
i went the other way around, because the built-in SMTP client has
no queue, so if it cannot send out immediately, then it gets a bit
problematic.  (The message is in *record*, and can be `resend', or
better `Resend', then, but it is not comfortable.)

 |Expect some weird and dumb question on my part :)

Sure.  I currently have super odd living times, though..

 --End of <[email protected]>

[email protected] wrote in
 <[email protected]>:
 |This may sound stupid but, until now, .mailrc was just filed of aliases \
 |here.
 |I see .mailrc is much more than this.
 |
 |Lurking the manpage, I see I can have a bunch of things in it.
 |I already added some basic stuff (such as record) but I am curoius \
 |to see what experienced users have in there .mailrc (or is it .s-nail.rc \
 |BTW?).

It is a POSIX standardized program, and the standard defines this
to be ~/.mailrc.  But you can set the $MAILRC environment
variable.  (And it is, actually, a compile-time decision.)

The manual includes a section "An example configuration", which
be of interest.  The (default) global mailrc (usually /etc/mail.rc
or /etc/mailx.rc, here /usr/etc/mailx.rc) is also heavily
commented.

I would recommend to have a ~/.mailrc that is compatible with
other mailx, for example:

  # ~/.mailrc
  
  set PAGER="less -I -F -E"
  set LISTER="ls -latr"
  set VISUAL="vim -c ':set filetype=mail'"
  
  set append asksub header hold keep outfolder save sendwait
  set crt escape=! folder=sec.arena/mail DEAD=+dead indentprefix=" |" MBOX=+mbox
  
  retain date from to cc subject message-id mail-followup-to reply-to user-agent
  
  set mailx-extra-rc=~/.s-mailrc
  #source ~/.mail_aliases

S-nail does support the *mailx-extra-rc* variable (i use ** for
vars, `' for commands etc..), and will automatically load the
according file.  You can avoid this "double load" via environment,
i for example have

  MAILRC=/home/steffen/.s-mailrc
  MAILX_NO_SYSTEM_RC=1

so that only ~/.s-mailrc is loaded.
I will attach that file, but it will surely be a bit confusing for
a beginner.  It also does not include accounts, mailing-lists, and
aliases, these are in ~/.s-mailrc-private, which i load via the
*mailx-extra-rc* thing.  Like, for example, and it gets messy :/

  \mlist \
        '@lists\..+$' \
                '@googlegroups\.com$'
  \mlsubscribe \
        s-mailx@(lists\.)?sdaoden\.eu \
        [email protected]

                [email protected] \

  \alias mailx [email protected]

or

  account ich {
          \call ich
  }
  define ich {
          \call .ich-shared
          \se autobcc=ich \
                  from='Steffen Nurpmeso <[email protected]>' \
                  
[email protected]=~/sec.arena/tls.git/[email protected] \
                  
_smime-sign-cert=~/sec.arena/tls.git/smime/[email protected] \
                  user=steffen
          # smime-sign

          ca newmail 'call load-sdaoden.eu'

          \xcall ich-sendmail
  }
  define ich-sendmail {
          \call .ich-unset
          \se r-option-implicit
  }
  define .ich-shared {
          \unalternates *; \alt \
                  [email protected] \
                  #...

          \se \
                  nostealthmua \
                  record=+sent \
                  user=sdaoden
          \xcall ich-sigs
                  #socks-proxy=localhost:42021
  }
  define .ich-unset {
          \uns mta-no-recipient-arguments \
                  mta mta-argv0 mta-bcc-ok mta-no-default-arguments 
mta-arguments \
                  r-option-implicit
  }

 |-- xavier
 --End of <[email protected]>

Now offline for hours, feel free to post :)

Ciao, and greetings,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
#@ ~/.s-mailrc
if $version == ""
        ec '~/.s-mailrc needs (at least) S-[mn]ailx v14.8.0 (2015-04-30) or 
later'
        xit 1
endif
# Most macro content etc., however, will require newest development
# (a set "set v15-compat=y" that is, as will be default with v14.10.0+)
define age {
        \if $version-hexnum -lt 0x0E00A000 && [ $version-hexnum -lt 0x0E009018 
|| $features !% ,+devel, ]
                \echoerr "Program too old: $0"
                \xit 42
        \en
}

# sh(1) alike field splitting *plus* if/elif acting like bash(1)s [[ ]] *not* 
before v14.10!

# v14_10 {{{
define v14_10 {
        # *asksend* added in v14.9.3, but "now" no longer built-in default
        # *mailx-extra-rc* here, sails on the edge.
        # **-inject-** in v14.9.11, but do not want "wysh set"
        \se \
                asksend \
                forward-inject-head=$'--- Forwarded from %f ---\n' \
                        forward-inject-tail=$' -- End forward <%i>\n' \
                line-editor-config=quote-rndtrip,srch-case,srch-pos0,srch-regex 
\
                mailx-extra-rc=~/.s-mailrc-private \
                on-mailbox-event-+download=ombe-thread-nocollapse \
                        on-mailbox-event-+gmane=ombe-thread-nocollapse \
                        on-mailbox-event-+sent=ombe-sortdate-showlast \
                quote-inject-head=$'%n wrote in\n <%i>:\n' \
                        quote-inject-tail=$' --End of <%i>\n' \
                ttycharset-detect=latin1

        \if $features =% ,+debug, || $features =% ,+devel,; \se memdebug; \en

        \if t && $features =% ,+regex,; \se 
on-history-addition=on-history-addition; \en

        \if -N tls-config-pairs && $tls-features =% ,+option-ktls,
                \se tls-config-pairs=$tls-config-pairs',Options=-Bugs\,KTLS'
        \en

        \local >i ! </dev/null less --version >/dev/null 2>&1
        \if $? -eq 0
                \env se LESS=RIFe
        \el
                \env uns LESS # want built-in!
        \en

        ca ece \\echoerr
        ca forward \\local forward
        ca fo forward
        ca mail \\local mail
        ca m mail
        ca reply \\local reply
        ca r reply
        ca Lreply \\local Lreply
        ca Lr Lreply
        ca s \\sea
        ca xa \\call xarith
        ca newall '\eval ! exec gmane-fetch.pl; \if $? -eq 0; newmail; \el; ece 
GMANE failed; \en #'
}
# }}}

# v14_9 {{{
define v14_9 {
        \commandalias ca '\'commandalias
        ca hp '\headerpick'
        ca xd '\call xdebug'
        ca xv '\call xverbose'

        \filetype \
                bz2 'bzip2 -dc' 'bzip2 -zc' \
                gpg 'gpg -d' 'gpg -e' \
                gz 'gzip -dc' 'gzip -zc' \
                lz 'plzip -dc' 'plzip -9c' \
                lz.pgp 'gpg -d | plzip -dc' 'plzip -9c | gpg -e' \
                xz 'xz -dc' 'xz -zc' \
                zst 'zstd -dc' 'zstd --ultra -22 -T0 -zc' \
                zst.pgp 'gpg -d | zstd -dc' 'zstd --ultra -22 -T0 -zc | gpg -e'

        hp type retain \
                author bcc cc date from message-id sender subject to \
                mail-followup-to reply-to \
                user-agent openpgp blahblahblah authentication-results \
                dkim-signature
        hp forward retain \
                author cc date from message-id list-id sender subject to \
                mail-followup-to reply-to \
                openpgp
        \if $features =% ,+regex,
                # ^Authentication-Results$ ^DKIM.+$
                hp save ignore \
                        ^Delivered-To$ ^Envelope-To$ \
                        ^Original-.*$ ^X-.*$ \
                        ^ARC-.+$ ^Authentication-Results$ ^DKIM.+$ 
^Received-SPF$ \
                        \
                        ^X- \
                        \
                        ^IronPort ^MGA ^Spam \
                        \
                        ^(Accept|Content)-Language ^Thread-
        \en

        \if t
                \if $features =% ,+key-bindings,
                        \bind base $'\e',d mle-snarf-word-fwd
                        \bind base $'\e',$'\c?' mle-snarf-word-bwd
                        \bind base $'\e',f mle-go-word-fwd
                        \bind base $'\e',b mle-go-word-bwd
                        \bind base $'\cL' mle-clear-screen

                        \bind default :kf1 Fi%
                        \bind default :kf2 Fi'&'
                        \bind default :kf3 Fi+download
                        \bind default :kf4 Fi+gmane
                        \bind default :kf5 Fi+sent
                        \bind default :kf6 Fi~/traffic/.spam~
                        \bind default :kf12 fi%
                        \bind default :kf11 fi'&'
                        \bind default :kf10 fi+download
                        \bind default :kf9 fi+gmane
                        #\bind default :kf8 fi+sent

                        \bind compose :kf1 "${escape}v"
                        \bind compose :kf2 "${escape}p"
                \en

                \if "$HOSTNAME" == kent && "$TERM" != tmux-256color
                        \se termcap='Co#256,kUP5=\E[1;5A,kDN5=\E[1;5B,\
                                        
kLFT5=\E[1;5D,kRIT5=\E[1;5C,kLFT3=\E[1;3D,kRIT3=\E[1;3C,\
                                        kLFT=\E[1~,kRIT=\E[1;5F,\
                                        
kUP=\E[1;2A,kDN=\E[1;2B,kHOM=\E[1;2H,kEND=\E[1;2F'
                \elif "$HOSTNAME" == wales
                        \se 
termcap='Co#256,kHOM=\E[H,kEND=\E[F,kUP5=\E[5A,kDN5=\E[5B'
                \en

                # pipe- things unless mailcap available
                \if $version-hexnum -lt 0x0E009010 || $features !% ,+mailcap,
                        \if "$OSTYPE" == darwin
                                \se pipe-application/pdf='?=&?\
                                        trap "rm -f 
\"${MAILX_FILENAME_TEMPORARY}\"" EXIT;\
                                        trap "trap \"\" INT QUIT TERM; exit 1" 
INT QUIT TERM;\
                                        
/Applications/Preview.app/Contents/MacOS/Preview \
                                                "${MAILX_FILENAME_TEMPORARY}"'
                        \el
                                \se pipe-application/pdf='?=&?\
                                        trap "rm -f 
\"${MAILX_FILENAME_TEMPORARY}\"" EXIT;\
                                        trap "trap \"\" INT QUIT TERM; exit 1" 
INT QUIT TERM;\
                                        mupdf "${MAILX_FILENAME_TEMPORARY}"'
                        \en

                        \if $features !% ,+filter-html-tagsoup,
                                \se pipe-text/html='?* lynx -stdin -dump 
-force_html'
                        \en
                        \se pipe-message/external-body='?* echo 
$MAILX_EXTERNAL_BODY_URL'
                \en

                # Here to be able to use new-style `if' things; COLUMNS
                \if $COLUMNS -gt 110
                        \se datefield='%G-%m-%d %R' 
datefield-markout-older=%G-%m-%d \
                                headline='%>%a%L%4m %-33f %-16d %5l/%7o %i%-s'
                \en

                # Adjustment of $LESS moved to v14_10

                \call bg_dark
        \en

        # Otherwise (formerly) in v14_8 (not commented out)
        \if "$tls-features" != ''
                \se tls-ca-file=~/sec.arena/tls.git/cacert.pem 
tls-ca-no-defaults
                \if $tls-features =% ,+ctx-set-maxmin-proto,
                        \se tls-config-pairs='CipherString = 
EECDH+AESGCM:EECDH+AES256:EDH+AESGCM:CHACHA20, MinProtocol = TLSv1.3'
                \el
                        \se 
tls-config-pairs='CipherString=EECDH+AESGCM:EECDH+AES256:EDH+AESGCM:CHACHA20, 
Protocol=-ALL\,TLSv1.3'
                \en
        \el
                \se ssl-config-pairs='CipherString=TLSv1.3:!aNULL:!eNULL'
        \en

        #\if $version-hexnum -lt 0x0E00900B
        #       \return
        #\en

        #*-inject-* -> v14_10
        #on-history-addition -> v14_10

        \if $version-hexnum -lt 0x0E00900F
                \return
        \en

        \se followup-to-add-cc

        \if $version-hexnum -lt 0x0E009010
                \return
        \en

        \se forward-add-cc history-gabby=all quote-add-cc

        \if $version-hexnum -lt 0x0E009011
                \return
        \en

        \se reply-to-swap-in=mlist

        \if $version-hexnum -lt 0x0E009014
                \return
        \en

        \se quote=allbodies

        # And then it slowly started to make fun!
        \if $version-hexnum -ge 0x0E00A000 || [ $version-hexnum -ge 0x0E009018 
&& $features =% ,+devel, ]
                \xcall v14_10
        \en
}
# }}}

# v14_8 {{{
#define v14_8 {
        # Replaced with on-mailbox-event in v14.10
        # (Only +XY was new in v14.8, aka under *folder*)
                        #folder-hook-+download=fh-thread-nocollapse
                        #folder-hook-+gmane=fh-thread-nocollapse
                        #folder-hook-+sent=fh-sortdate-showlast
        set followup-to \
                        followup-to-honour=ask-yes \
                reply-to-honour=ask-yes

        # Otherwise in v14_9
        #if [ "$ssl-features" == '' ]
        #       set ssl-ca-file=~/sec.arena/tls.git/cacert.pem 
ssl-ca-no-defaults \
        #               ssl-cipher-list=TLSv1.2:!aNULL:!eNULL:@STRENGTH \
        #               ssl-protocol=-ALL,TLSv1.2
        #en

        set spam-interface=filter spam-maxsize=500000 \
                spamc-arguments='-U /tmp/.spamsock' spamc-user= \
                spamfilter-ham='bogofilter -n' \
                        spamfilter-noham='bogofilter -N' \
                        spamfilter-nospam='bogofilter -S' \
                        spamfilter-rate='bogofilter -TTu 2>/dev/null' \
                        spamfilter-spam='bogofilter -s' \
                        spamfilter-rate-scanscore='1;^(.+)$'
        # filter-html-tagsoup check in v14_9 to avoid `if !@' obsoletion warning

        # Avoid ASCII "propagates to 8-bit" when scripting
        if [ ! t ] && [ "$LC_ALL" != C ] && [ "$LC_CTYPE" != C ]
                set sendcharsets-else-ttycharset
        end
#}
# }}}

## -- >8 -- 8< -- ##

#{{{ ar-sea:
#@ . "call ar-sea-init" from within an `account' so any settings are covered
#@   by the account's scope.
#@ Search by "call ar-sea SEARCHSPEC".
#@ May need to "call ar-sea-gut" explicitly to cleanup temporary mailbox.

define ar-sea-init {
        \se ar-sea-glob= ar-sea-file
}

define ar-sea-gut {
        \if -n $ar-sea-file
                \remove "$ar-sea-file"
                \uns ar-sea-file
        \en
}

define ar-sea {
        \call age

        \if -z $ar-sea-glob; \local se ar-sea-glob=+*; \en

        \eval local >x fop glob "$ar-sea-glob"
        \if $? -ne 0 #&& $^# -gt 0
                \echoerr 'No files to search'
                \return 1
        \en

        \call ar-sea-gut

        \>ar-sea-file fop mktemp
        \if $? -ne 0
                \echoerr 'Cannot create temporary search result storage file'
                \return 1
        \en

        # TODO we need loops!! we need arrays!! could be done MUCH better
        \local se x=$(($# + 1)) ombf=$mailbox-resolved ombro=$mailbox-read-only
        \our se noanym  noheader
        \our call .ar-sea-each "$x" "$@" "$^@"

        \if -N anym
                \File "$ar-sea-file"
                \h
                \ec 'Search result in $ar-sea-file='"$ar-sea-file"'; remove via 
"call ar-sea-gut"'
        \else
                \>x fop rm "$ar-sea-file"
                \if $? -eq 0
                        \uns ar-sea-gut
                \el
                        \echoerr 'Cannot unlink $ar-sea-file='"$ar-sea-file"': 
'"$^ERRDOC"
                \en
        \en

        \if -n $ombf && $ombf != $mailbox-resolved
                \echon 'Switch back to '"$ombf"'? [yY/else] '
                \read x
                \if $x =~? ^y
                        \se x=file
                        \if -n $ombro; \se x=File; \en
                        \eval $x "$ombf"
                \en
        \en
}

define .ar-sea-each {
        \call .ar-sea-one "$@"
        \shift -1
        \if $# -gt $1; \xcall .ar-sea-each "$@"; \en
}

define .ar-sea-one {
        \eval local se mbf=\$$#
        \local se dec=$(($# - $1))
        \shift -$dec
        \shift 1

        \File "$mbf"
        \local >r = "$@"
        \if $? -eq 0
                \if -N verbose; \ec "Found in $mbf: $r"; \en
                \se anym
                # TODO should annotate where message came from; header 
injection?
                \eval copy "$r" \"$ar-sea-file\"
        \elif -N verbose
                ec "Nothing in $mbf"
        \en
}
# }}}

# bg_* {{{
define bg_dark {
        if ! [ t && $features =% ,+mle, && $features =% ,+colour, && 
$version-hexnum -ge 0x0E009010 ]
                \return
        \en

        \col 256 mle-position fg=203,ft=reverse
        \col 256 mle-prompt fg=203
        \col 256 mle-error bg=124

        \col iso mle-position fg=brown,ft=bold
        \col iso mle-prompt fg=brown
        \col iso mle-error bg=red

        \col mono mle-position ft=reverse
        \col mono mle-prompt ft=bold
        \col mono mle-error ft=reverse

        \col 256 sum-dotmark fg=204,ft=bold dot
        \col 256 sum-header fg=39 older
        \col 256 sum-header fg=39,ft=reverse dot
        \col 256 sum-header fg=45
        \col 256 sum-thread fg=39,ft=bold,ft=reverse dot
        \col 256 sum-thread fg=172

        \col iso sum-dotmark ft=reverse,fg=brown dot
        \col iso sum-header fg=brown dot
        \col iso sum-thread fg=brown dot
        \col iso sum-thread fg=magenta

        \col mono sum-dotmark ft=bold,ft=reverse dot
        \col mono sum-header ft=bold dot
        \col mono sum-thread ft=bold dot

        \col 256 view-from_ fg=142
        \col 256 view-header fg=214,ft=bold from,subject
        \col 256 view-header fg=214 author,cc,sender,to
        \col 256 view-header fg=217 reply-to,mail-followup-to,user-agent
        \col 256 view-header fg=219
        \col 256 view-msginfo fg=76,ft=bold
        \col 256 view-partinfo fg=76 #161

        \col iso view-from_ fg=red
        \col iso view-header fg=white author,from,sender,subject
        \col iso view-header fg=brown
        \col iso view-msginfo fg=green
        \col iso view-partinfo fg=brown

        \col mono view-header ft=bold author,from,sender,subject
        \col mono view-msginfo ft=reverse,ft=underline
        \col mono view-partinfo  ft=bold,ft=underline
}

define bg_light {
        if ! [ t && $features =% ,+mle, && $features =% ,+colour, && 
$version-hexnum -ge 0x0E009010 ]
                \return
        \en

        \col 256 mle-position fg=202
        \col 256 mle-prompt fg=red
        \col 256 mle-error bg=124,fg=7

        \col iso mle-position ft=bold
        \col iso mle-prompt fg=red,fg=white

        \col mono mle-position ft=bold
        \col mono mle-prompt ft=bold
        \col mono mle-error ft=reverse

        \col 256 sum-dotmark ft=bold,fg=13 dot
        \col 256 sum-header fg=19 older
        \col 256 sum-header fg=16,bg=219 dot
        \col 256 sum-header fg=17
        \col 256 sum-thread ft=bold,fg=164,bg=219 dot
        \col 256 sum-thread fg=172

        \col iso sum-dotmark ft=reverse,fg=blue dot
        \col iso sum-header fg=blue dot
        \col iso sum-thread fg=blue dot
        \col iso sum-thread fg=magenta

        \col mono sum-dotmark ft=bold,ft=reverse dot
        \col mono sum-header ft=bold dot
        \col mono sum-thread ft=bold dot

        \col 256 view-from_ fg=142
        \col 256 view-header ft=bold,fg=red from,subject
        \col 256 view-header fg=124 author,cc,sender,to
        \col 256 view-header fg=203 reply-to,mail-followup-to,user-agent
        \col 256 view-header fg=88
        \col 256 view-msginfo fg=green
        \col 256 view-partinfo fg=brown

        \col iso view-from_ fg=brown
        \col iso view-header ft=bold,fg=red author,from,sender,subject
        \col iso view-header fg=red
        \col iso view-msginfo fg=green
        \col iso view-partinfo fg=brown

        \col mono view-header ft=bold from,subject
        \col mono view-msginfo ft=reverse,ft=underline
        \col mono view-partinfo  ft=bold,ft=underline
}
# }}}

define foreach_call {
        \if $# -le 1; \retu; \en
        \call "$1" "$2"
        \local se f="$1"
        \shift 2
        \xcall foreach_call "$f" "$@"
}

define ombe-sortdate-showlast {
        \if $1 == open
                \se autosort=date showlast
        \en
}
define ombe-thread-nocollapse {
        \if $1 == open
                \se noautocollapse autosort=thread
        \en
}

define gmane {
        \local se noheader
        #File%
        \!exec gmane-fetch.pl
        \if $? -eq 0
                \file+gmane
                \headers
        \en
}

define kb-clear {
        \unbind * *;\
        \bind base $'\n' mle-commit;\
        \bind base $'\c?' mle-del-bwd;\
        \bind base $'\cE' mle-go-end
}

define mboxfix {
        \local se mbox-rfc4155; \File "$1"; \copy * "$2"
}

#{{{ oauth-check-token:
#@ . "call oauth-check-token-init" from within an `account' so any settings
#@   are covered by the account's scope.  (You surely want to do so for
#@   anything set (later) in $on-oauth-password-change!)
#@
#@ . $oauth-helper
#@   A script to invoke for fetching an OAuth 2.0 access token.
#@   It must output one line of only the token on standard output upon success.
#@
#@ . $oauth-helper-times (optional)
#@   Expected to point to an (s-nail) oauth-helper.py configuration file.
#@   Or anything readable with per line KEY=VALUE directives, with at least
#@   timestamp= and timeout= lines that hold UNIX epoch seconds.
#@   If not set, or not parsable, $oauth-helper is invoked once per tick!
#@
#@ . $on-oauth-password-change (optional)
#@   Called without arguments on error, or, whenever $oauth-helper announces
#@   an updated OAuth 2.0 access token, with the token as an argument.
#@
#@ So for example an `account' could "\call oauth-activate" as follows:
#@
#@     define oauth-activate { # [$1=account-name]
#@      \local se a=$1
#@      \if -z $a; \se a=$account; \en
#@      \se password \
#@                      on-main-loop-tick=oauth-check-token \
#@                      on-compose-enter=oauth-check-token
#@      # PLUS: actual usage of xoauth2/oauthbearer authentication
#@      \call oauth-check-token-init
#@      \se oauth-helper='$HOME/src/toolbox.git/oauth-helper.py \
#@                              --resource $HOME/sec.arena/mail/.'$a'.oauth' \
#@                      oauth-helper-times=$HOME/sec.arena/mail/.$a.oauth \
#@                      on-oauth-password-change=_oauth-on-new-token
#@     }
#@     
#@     define _oauth-on-new-token {
#@      \if -n $1
#@              \echoe ' .. updating password to OAuth token '"$1"
#@              \se password=$1
#@              # 'Could be -Z mailbox-resolved: quote!
#@              \if $mailbox-resolved =~ ^imaps?://
#@                      \echoe ' .. reconnecting IMAP after password change'
#@                      \disco
#@                      \conn
#@              \en
#@      \el
#@              \echoe ' .. deleting password'
#@              \uns password
#@      \en
#@     }

define oauth-check-token-init {
        \se oauth-helper oauth-helper-times on-oauth-password-change  
_oauth-pass _oauth-timeout
}

define oauth-check-token {
        \call age
        \if -Z oauth-helper; \return; \en

        \if -n $_oauth-timeout
                \local >sec vexpr seconds
                \if $((sec + 600)) -lt $_oauth-timeout
                        \return
                \en
                \uns _oauth-timeout
        \en

        \eval local >i ! $oauth-helper # eval to resolve $VARs
        \local se j=$? d=$?/$!/$^ERRDOC
        \if $j -ne 0
                \echoerr '! $oauth-helper exec failed, unsetting: '"$d: 
$oauth-helper"
                \uns oauth-helper
                \call_if "$on-oauth-password-change"
                \return
        \en

        \>i csop trim "$i"
        \if $_oauth-pass != $i
                \se _oauth-pass=$i
                \if -N verbose
                        \echoerr 'I Have a new Oauth 2.0 access token'
                \en
                \if -N on-oauth-password-change
                        \call_if "$on-oauth-password-change" "$_oauth-pass"
                \el
                        \echoerr 'I .. but without $on-oauth-password-change 
noone will know'
                \en
        \en

        \if -n $oauth-helper-times
                \xcall .oauth-helper-times
        \en
}

define .oauth-helper-times {
        \eval readctl create "$oauth-helper-times" # eval to resolve $VARs
        \local se j=$? d=$^ERRDOC
        \if $j -ne 0
                \echoerr '! $oauth-helper-times inaccessible, unsetting: '"$d: 
$oauth-helper-times"
                \uns oauth-helper-times
                \return
        \en
        \local readall _oauth_args
        \eval readctl remove "$oauth-helper-times"

        \local se ifs=$'\n'; \vpospar evalset "$_oauth_args"; \uns ifs
        \our call .oauth-check-token-recur "$@"

        \if -N _oauth_ts && -N _oauth_to
                : $((_oauth-timeout = _oauth_ts + _oauth_to))
                \if -N verbose
                        \local >sec vexpr seconds
                        \echoerr 'I OAuth password timeout at epoch 
'"$_oauth-timeout\
                                , now $sec, to-go $((_oauth-timeout - sec))"
                \en
        \el
                \echoerr '! $oauth-helper-times content bogus, unsetting: 
'"$oauth-helper-times"
                \uns oauth-helper-times
        \en
}

define .oauth-check-token-recur {
        \if $# -eq 0; \return; \en
        \if $1 =~ 
^[[:space:]]*time(stamp|out)[[:space:]]*=[[:space:]]*([[:digit:]]+).*
                \if $^1 == stamp; \se _oauth_ts=$^2; \el; \se _oauth_to=$^2; \en
        \en
        \shift
        \xcall .oauth-check-token-recur "$@"
}
# }}}

# on-compose-leave {{{
define on-compose-leave {
        \call age

        \if -N smime-sign && -N _smime-sign-cert
                \local >_smime-sign-cert fop expand "$_smime-sign-cert"
                \if -r $_smime-sign-cert
                        \dig - atta ins "$_smime-sign-cert"
                        \if $^0 -eq 210
                                \dig - atta attribute-set-at "$^1" \
                                        content-description S/MIME certificate 
for [email protected]
                                \ec "S/MIME: $^0"
                        \el
                                \ec "S/MIME error $^0: $^*"
                        \en
                \en
        \en

        \local >sec vexpr seconds
        \if $? -ne 0; \return; \en
        \local pp : $((e = sec / 60 % 60))
        \if $e -eq 42
                : $((e = -((sec % 60) - 60)))
                \ec "Minute 42, sleeping $e seconds"
                \sleep "$e"
        \el
                : $((e = sec % 60))
                \if $e -eq 42
                        \ec 'Second 42, sleeping a second'
                        \sleep 1
                \en
        \en
}
# }}}

# on-history-addition {{{
define on-history-addition {
        \if ${2} == fuzz || ${2} == errors
                \return 1
        \en
        \if ${#} -eq 3
                \if " ${3}" =% ' alias ' || " ${3}" =% ' csop ' || \
                                " ${3}" =% ' digmsg ' || " ${3}" =% ' fop ' || 
" ${3}" =% vexpr
                        \return 2
                \en
                \if ${3} =~ [[:space:]]*[^[:space:]]+codec[[:space:]]+
                        \return 2
                \en

                \if ${3} =~ [[:space:]]*[+&]?[[:digit:]]
                        \return 2
                \en
        \el
                \if ${3} == alias || ${3} == csop || ${3} == digmsg || ${3} == 
fop || ${3} == vexpr
                        \return 2
                \en
                \if ${3} =% codec
                        \return 2
                \en

                \shift 4
                \if ${*} =~ [[:space:]]*[+&]?[[:digit:]]
                        \return 2
                \en
        \en
}
# }}}

define showhtml {
  \local se mime-alternative-favour-rich pipe-text/html=?h?; \t "$@"
}

# V {{{
define V {
        \local se pipe-text/plain=$'?*#++=?\
                < "${MAILX_FILENAME_TEMPORARY}" awk \
                                -v TMPFILE="${MAILX_FILENAME_TEMPORARY}" \'\
                        BEGIN{done=0}\
                        /^-----BEGIN PGP SIGNED MESSAGE-----/,/^$/ {\
                                if(done++ != 0)\
                                        next;\
                                print "--- GPG --verify ---";\
                                system("gpg --verify " TMPFILE " 2>&1");\
                                print "--- GPG --verify ---";\
                                print "";\
                                next;\
                        }\
                        /^-----BEGIN PGP SIGNATURE-----/,/^-----END PGP 
SIGNATURE-----/ {\
                                next;\
                        }\
                        {print}\
                        \'';\
                print
}
# }}}

# xarith {{{
define xarith {
        \call age
        \if t && $* =~ [[:alnum:]]-[[:alnum:]]
                \echoerr 'Expression *could* contain VAR-NAME meant as I-J 
contraction!'
        \end
        #\if true
                \ignerr local pp : $((r=($@)))
                \local se e=$?
                \if $e -eq 0; \vexpr = "$r"; \en
        #\el
                #\ignerr local pp local se r="$(($@))"
                #\local se e=$?
                #\if $e -ne -1; \vexpr = $r; \en
        #\end
        \return $e
}
# }}}

define xdebug {
        \call age
        \local se debug; eval ignerr local pp "$@"; \return $?
}
define xverbose {
        \call age
        \local se verbose; eval ignerr local pp "$@"; \return $?
}

## -- >8 ~/.mailrc (overrides) 8< -- ## {{{

# environ set, but..
set \
        DEAD='${TMPDIR}/${LOGNAME}-dead.letter' \
        EDITOR=ed \
        PAGER=less \
        LISTER='ls -latr' \
        MBOX=+mbox \
        VISUAL="vim -c ':set filetype=mail'"

# v14.9.13: default: sendwait
# v14.10: default: hold, keep, keepsave; dropped: append
set \
        append asksub \
        folder=sec.arena/mail \
        header hold \
        indentprefix=' |' \
        keep keepsave \
        outfolder \
        nosave \
        sendwait

#retain blahblahblah date from to cc subject message-id \
#       mail-followup-to openpgp reply-to user-agent

#set mailx-extra-rc=~/.s-mailrc-private
## }}}

## -- >8 -- 8< -- ## mailx-extra-rc {{{

# Some may become overwritten by the macros above
#termcap-ca-mode
set \
        autocollapse autosort=thread \
        crt \
        editalong=v editheaders emptystart escape=! \
        fullnames \
        headline-bidi= headline='%>%a%L%4m %-18f %-11d %4l/%5o %i%-s' \
                history-file=~/traffic/.s-mailhist history-gabby \
        ignoreeof \
        markanswered \
                mime-alternative-favour-rich mime-counter-evidence=0b1111 \
                mime-encoding=qp mimetypes-load-control \
        netrc-lookup netrc-pipe='gpg -qd ~/.netrc.gpg' \
        on-compose-leave=on-compose-leave \
        prompt='#?\${?}!\${!}/\${^ERRNAME}#\${^ERRQUEUE-EXISTS}\
                        |\${account}:\${mailbox-display}? ' \
        quote= quote-fold=79\ 69\ 72 \
        recipients-in-cc record-files record-resent reply-in-same-charset \
                rfc822-body-from_ \
        showname showto \
                smime-ca-file=~/sec.arena/tls.git/cacert.pem 
smime-ca-no-defaults \
                smime-sign-digest=SHA512 \
        toplines=-1 topsqueeze \
        umask= \
        writebackedited

#call v14_8
if [ "$version" >= v14.9.0 ]
        \call v14_9
else
        retain blahblahblah date from to cc subject message-id \
                mail-followup-to openpgp reply-to user-agent
        fwdretain date from to cc subject reply-to mail-followup-to list-id
        ghost ca ghost
endif
undefine v14_9 v14_10

alias ich 'Steffen Nurpmeso <[email protected]>'

ca foreach '\call foreach_call'
ca H spamham
ca html '\call showhtml'
ca q 'ec You do not want to quit, do you?'
ca R spamrate
ca S spamspam
# }}}

# s-itt-mode

Reply via email to