I am having troubles understanding details of the 'titlestring' option.
My 'titlestring' has become too complicated to maintain so I decided
to create a function for it and that's where my problems start.
I'll try to demonstrate them with some trivial examples rather then
taking my whole complex stuff. Here it is:

This works:

set titlestring=%{$LOGNAME}\ PWD=%<%{$PWD}

which sets the title to

"zs PWD=/xxx/ccc/vv/path"

the %< serves as a signal to clip the path at that point if the
xterm size isn't wide enough.

A few comments though:
- there can be no unescaped whitespace after the '=', (where is that
  in the doc)?
- why the whitespaces in the titlestring expression have to be esccaped
  anyway. It must be somewhere in the doc, couldn't find it.

Converting it to a function I have:

function! TitleString()
    let string="zs PWD=".$PWD
    return string
endfunction


Problems:
- ':h titlestring' will eventualy tell you to look in ':h statusline'
  for details, going there one finds the example

       set statusline=%!MyStatusLine()

  so I tried it

       set titlestring=%!TitleString()

  which creates the title '%!TitleString()', not what I expected.
  What am I doing wrong? Or what is wrong (doc?, bug?, ...?)

- but (using experimental programming techniques (TM) this works:

       set titlestring=%{TitleString()}

- so let's now try to introduce that "clipping", the doc says
  (under ':h statusline') that
  "...the result can contain %{} items that will be evaluated, too".
  I changed the string line to 'let string="zs PWD="."%<".$PWD' which
  doesn't work (the '%< is taken as normal characters and placed in
  the title, not *evaluated*).
  OK, I used '%<' not '%{}' but I assumed that this will be evaluated,
  too.
  What am I doing wrong? Badly reading the doc?

- To conform to the doc, I changed the string line to:

  let string="zs@"."%{hostname()}"." PWD=".$PWD

  the :echo string" will show:

  [EMAIL PROTECTED]()} PWD=/home/zs/tmp

  which is correct so now ':set titlestring=%{TitleString()}" should
  interpret that string, but it doesn't, it takes it literally and the title
  produced is just like the line above. It should be

  [EMAIL PROTECTED] PWD=path

  which is produced by ':set [EMAIL PROTECTED]()}\ PWD=%{$PWD}'
  which seems to me is the exact equivalent of the string in the function.

I believe I must be reading wrongly the doc (it's really not very talkative
around ':h statusline'), I can't believe this titlestring doesn't work.

Can someone put me on the right track, please?

---Zdenek

--
-----------------------------------------------------
Zdenek Sekera               | [EMAIL PROTECTED]
LHC Computing Grid Project  | tel:    +41-22-767.1068
CERN - IT Division          | mobile: +41-76-487.4971
CH-1211 Geneva 23           | fax:    +41-22-767.4900
Switzerland                 |
-----------------------------------------------------

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Raspunde prin e-mail lui