zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: since 4.3.4, artifact-appearance at prompt
Date: Sun, 04 Nov 2007 09:48:03 -0800	[thread overview]
Message-ID: <071104094803.ZM22628@torch.brasslantern.com> (raw)
In-Reply-To: <20071104070008.15348.qmail@smasher.org>

On Nov 4,  8:00pm, Atom Smasher wrote:
}
} > On Sat, 3 Nov 2007, Russell Hoover wrote:
} > "%" on a blank line where I'm not sure it's doing me any good (when my 
} > prompt is already on the next line).

Note in passing:  You're not supposed to see the % on a blank line.  The
PROMPT_SP trick is supposed to emit just enough spaces so that, *if* the
line is blank, then when the PROMP_CR carriage return is printed, you'll
be returned to the position where the % appears and the normal prompt
will cover it up.

This is why I say you're either in a race condition -- e.g., zsh prints
the spaces but before it can backspace and print the prompt, you hit
enter again and the teminal advances to the next line [*] -- or there's
something unexpected about the right-margin auto-wrap behavior of your
terminal, such that the PROMPT_SP spaces cause a new line where one
should not be.

[*] I can't make this happen no matter how fast I hammer on the enter
key, so I suspect this is related to other problems with slow prompts.

Ok, that got windier than I intended.  Back to the real reply:

On Nov 4,  8:00pm, Atom Smasher wrote:
}
} would it be reasonable to have an SPPROMPT parameter, or something 
} similar, to control what's displayed there?

It wouldn't be unreasonable, but it would require the prompt_sp code to
be able to compute the exact visible width of that substitution -- that
is, users would have to be just as careful with %{ and %} as they are
in the prompt itself, maybe more so.

If you want to control what appears there, you can unsetopt prompt_sp
and insert the equivalent sequence into your PS1 string or precmd
function, as described in FAQ 3.23:

    # Skip defining precmd if the PROMPT_SP option is available.
    if ! eval '[[ -o promptsp ]] 2>/dev/null'; then
      function precmd {
        # An efficient version using termcap multi-right:
        print -nP '%B%S%#%s%b'      # Output % or #
        echotc RI $((COLUMNS - 3))
        echo -n '  '                # Output 2 spaces
      }
    fi

If you change the "print -nP" string to be wider, increase the "3" in the
echotc to compensate.  It should always be 2 more than the width of the
print output.

A suggestion I'll throw out in case someone feels like running with it:
Perhaps there should be a %-expando for PS1 that performs the "echotc RI"
of the correct width based on the current %(l..) value (if you see what
I mean), followed by the two spaces.  Suppose that's %P (not necessarily
the best choice, just the first unused letter to come to mind).  Then one
could just do

    PS1="%B%S%#%s%b%P$PS1"

and customize the part to the left of the %P any way they like.  Or %P
could take an "argument" like %D does, if that would be easier:

    PS1=%P{%B%S%#%s%b}$PS1"

Any thoughts from the -workers on that?


  reply	other threads:[~2007-11-04 17:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-03 23:43 Russell Hoover
2007-11-04  1:30 ` Bart Schaefer
2007-11-04  3:48   ` Russell Hoover
2007-11-04  7:00     ` Atom Smasher
2007-11-04 17:48       ` Bart Schaefer [this message]
2007-11-04 22:16         ` Wayne Davison
2007-11-04 23:48           ` Bart Schaefer
2007-11-05  6:01             ` Wayne Davison
2007-11-05 15:16               ` Bart Schaefer
2007-11-05 11:28         ` Oliver Kiddle
2007-11-05 15:35           ` Bart Schaefer
2007-11-04 22:18       ` Wayne Davison
2007-11-04 14:51 ` Benjamin Andresen

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=071104094803.ZM22628@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).