Steffen Nurpmeso <stef...@sdaoden.eu> wrote:

> Z <zi...@sdf.org> wrote in
>  <61684b71.hlwju2xf9gm3gcoz%zi...@sdf.org>:
>  |Steffen Nurpmeso <stef...@sdaoden.eu> wrote:
>  |> Z <zi...@sdf.org> wrote in
>  |>  <61676f30.O/q/a8uppae86zoh%zi...@sdf.org>:
>  |>|I was wondering if there was a way to define a new internal variable
>  |>|that could then be updated as needed via folder hooks.  Specifially
>  |>|I'd like to isolate the IMAP [/path] value which is present in both
>  |>|the 'mailbox-displayed' and 'mailbox-resolved' internal variables
>  |>|whenever an IMAP mailbox is accessed.
>  |>|
>  |>|My end goal is to use the IMAP [/path] value in the s-mailx prompt
>  |>|along with the 'account' variable so as to always display the active
>  |>|IMAP account name and folder without showing the entire protocol:// URI.
>  |>
>  |> A bit ugly but could you use
>  |>
>  |>  vput vexpr prompt regex "$mailbox-resolved" ([^/]+)$ '\$1'
>  |>   if -z "$prompt"; set prompt=nada; endif
>  |>
>  |> If you put this in a folder hook this should work.
>  |
>  |Yes that seems to be what I was looking for but now I'm wondering
>  |if there is some way to do this within the 'set prompt=' assignment
>  |since prompt is basically a universal folder hook.  The following
>  |produces the prompt I'm after:
>  |
>  | vput vexpr prompt regex "$mailbox-resolved" ([^/]+)$ '[\$account/\$1] > '
>  |
>  |Can that be executed whenever the prompt is updated?
>
> No.  That is, not yet.  *prompt* is always shell-style evaluated
> "as if specified within $''" before it is displayed, but $'' does
> not yet support the envisaged \`{...} extension to execute
> commands.  For now *folder-hook* has to be used, which .. should
> satisfy your reported needs?  I mean we could introduce
> a *mailbox-basename* variable.  Ok i did that.  Be warned you got
> credited.

Well.. I hope I can handle the infamy. ;)  I'm not the admin on several
of the systems where I use s-mailx so making use of 'mailbox-basename'
will have to wait but thanks just the same.

Okay, so this is what I have in my ~/.mailrc file which appears to work
exactly as desired:

  # macro & folder-hook for custom prompt:
  define custom-prompt {
    localopts yes;
    vput vexpr prompt regex "$mailbox-resolved" ([^/]+)$ '[\$account/\$1] > ';
    }
    call custom-prompt
  set folder-hook=custom-prompt

Does that look right?  It seems to work just fine with or without the
"localopts yes" which I included because it's in the manpage example.

Regards,
Z of Denver Colorado, US

Reply via email to