Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bracketed paste - chopping trailing newlines



On Aug 31,  5:47am, Daniel Shahaf wrote:
}
} So, to clarify, you are proposing:
} 
} - A trailing newline will be stripped if preceded by a non-newline and
}   RBUFFER is not empty...

I think stripped if RBUFFER *is* empty, rather than not, because if
RBUFFER is left sitting there not empty then it's obvious that the
paste did not result in a command line being accepted.

} - but will be re-added if immediately followed by another paste.
} 
} I don't like the sound of this, for several reasons:
} 
} - The second clause constitutes state: <paste>f<backspace><paste> and
}   <paste><paste> behave differently.  I think state should be minimized.

I agree.

} As I've stated in other threads, my preferred option is to simply never
} munge the user data at all, to minimize surprising behaviour and
} maximize compatibility with other places that accept pastes.

Of course the problem is that "least surprise" for a current user of zsh
is for the newlines to be accept-line, whereas for a person expecting
the behavior of a text editor the newlines should just be inserted.

My suggestion of accept-line for a final newline only when RBUFFER is
empty was meant as the least objectionable hybrid of the two.

} The problem of user not realizing the command hasn't started to run
} could be solved by having zle_highlight=(paste:...) and/or a 'zle -M'
} message by default.

On further reflection I don't think highlighting the paste is sufficient
to solve this.  Yes, it lets you know that a paste has occurred, but it
doesn't help with realizing that a paste doesn't result in accept-line
if you aren't already familiar with that.

} We could even make <accept-line> strip the final newline for cosmetic
} reasons if it had been inserted by a paste and is syntactically
} whitespace.

I find myself ambivalent about that.

} Is there any other place accepting pastes that removes the final
} newline?  Everywhere I can think of just pastes the final newline if it
} was part of the copied text.

This is also considered by my hybrid suggestion -- the newline is not
removed; it is part of the paste.  It just means something different at
the end of the line (it means what a newline usually means at the end
of a line).



Messages sorted by: Reverse Date, Date, Thread, Author