zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@sunsite.dk>
Subject: Re: promptsubst and empty variables
Date: Sun, 14 Sep 2008 09:43:22 -0700	[thread overview]
Message-ID: <080914094322.ZM22699@torch.brasslantern.com> (raw)
In-Reply-To: <20080914092459.GK2182@fsst.voodoo.lan>

On Sep 14, 11:24am, Frank Terbeck wrote:
}
} I am seeing some weirdness using prompt_subst and empty variables in
} RPS1 (from zsh -f):
} 
} [snip]
} setopt promptsubst
} RPROMPT='${foo}'

I get the misplaced cursor right here; there doesn't need to be a value
assigned to PROMPT with or without a substitution in it.

} This results in the following cursor position:
} 
} ~%_
}   ^- At the underscore, that's where the cursor is. Note, the missing
}      trailing space.
} 
}     + it is in every version starting from 3.1.6 except:
}         - 4.3.1 and 4.3.2
}         - it's back in 4.3.3 and remains to be in the CVS HEAD
}           version.

I can't follow how any of the 4.3.0->4.3.1 changes could have affected
this, but anyway ...

The problem is that singsub() called from promptexpand() is returning
nulstring, which is the Nularg token followed by a NUL byte.

This is incorrectly being interpreted by promptexpand() as a so-called
"glitch" space passed down from the caller, and is therefore counted
as one space in the width of the prompt.

Unfortunately having learned this much, I have very little idea how to
proceed with fixing it.  One possibility might be to do a first pass
over the string counting and removing all "glitches" before making the
call to singsub(), so that Nularg introduced by substitution could be
ignored in a second pass.  Another might be to introduce a real token
for the "glitch" space rather than overloading Nularg, but that may
have pretty wide-ranging ramifications.

Wayne, this is mostly your baby.  What to do?


  reply	other threads:[~2008-09-14 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-14  9:24 Frank Terbeck
2008-09-14 16:43 ` Bart Schaefer [this message]
2008-09-15 14:34   ` Peter Stephenson
2008-09-15 15:28     ` Frank Terbeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=080914094322.ZM22699@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).