Add support for evaluating Vim expressions in a heredoc#10138
Add support for evaluating Vim expressions in a heredoc#10138yegappan wants to merge 1 commit intovim:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10138 +/- ##
==========================================
+ Coverage 80.95% 83.67% +2.72%
==========================================
Files 161 154 -7
Lines 185383 176636 -8747
Branches 41905 39726 -2179
==========================================
- Hits 150076 147806 -2270
+ Misses 22765 16789 -5976
+ Partials 12542 12041 -501
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
c604d73 to
3d5bcb3
Compare
|
Let's leave this open a few days to allow for comments. I'm not sure if we should use The help is not clear: can the expression span multiple lines? So I could use |
|
Hi Bram,
On Sun, Apr 10, 2022 at 11:25 AM Bram Moolenaar ***@***.***> wrote:
Let's leave this open a few days to allow for comments.
I'm not sure if we should use =expr or just expr. Compared to other
places in Vim =expr would be more common,
but compared to any other language expr would be preferred.
The help is not clear: can the expression span multiple lines? So I could
use
An expression must be within a single line and cannot span multiple lines.
I will update the help to reflect this.
Regards,
Yegappan
… some literal text `=
expr line
expr line
` more literal text
|
8838a23 to
806fa19
Compare
Yes, I suggested |
|
Hi Bram,
On Sun, Apr 10, 2022 at 8:53 PM lacygoill ***@***.***> wrote:
I'm not sure if we should use =expr or just expr. Compared to other places
in Vim =expr would be more common,
but compared to any other language expr would be preferred.
Yes, I suggested backtick equal to be as consistent as possible with the
existing syntax, but in practice I suspect it's hardly ever used. Dropping
the equal sign might make it easier for people coming from other languages
to assimilate this new syntax.
Should we support using only backtick for expanding the Vim expression in a
heredoc?
Thanks,
Yegappan
|
|
On Sun, Apr 10, 2022 at 11:25 AM Bram Moolenaar ***@***.***>
wrote:
> Let's leave this open a few days to allow for comments.
>
> I'm not sure if we should use =expr or just expr. Compared to other
> places in Vim =expr would be more common,
> but compared to any other language expr would be preferred.
>
> The help is not clear: can the expression span multiple lines? So I could
> use
An expression must be within a single line and cannot span multiple lines.
I will update the help to reflect this.
I suppose that will cover most use cases. I expect most use will just
be a variable or something like "shellescape(bufname(bnr))".
…--
ARTHUR: Be quiet! I order you to shut up.
OLD WOMAN: Order, eh -- who does he think he is?
ARTHUR: I am your king!
OLD WOMAN: Well, I didn't vote for you.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
98ea5a8 to
6b707d2
Compare
|
The help says "If the expression evaluation fails, then it is replaced with an empty string." |
I have updated the PR to fail the assignment if an expression evaluation fails. |
a43a70f to
5e57b51
Compare
|
I have not seen comments objecting to using the " |
|
When adding another test I found that this doesn't work: This will require more work, since "x" would have to be evaluated at runtime. Let's do that in a followup change. |
|
Hi Bram,
On Sun, Apr 17, 2022 at 3:51 AM Bram Moolenaar ***@***.***> wrote:
I have not seen comments objecting to using the "=expr" form, including
the equal sign. So I guess it should be OK that way.
If you think using a single backquote will be easier and less confusing
than using "`=",
then we can still change this.
Regards,
Yegappan
|
|
I've never use vimscript, or the |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@cecamp for the highlighting |
Problem: Cannot easily mix expression and heredoc. Solution: Support in heredoc. (Yegappan Lakshmanan, closes vim/vim#10138) vim/vim@efbfa86 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Cannot easily mix expression and heredoc. Solution: Support in heredoc. (Yegappan Lakshmanan, closes vim/vim#10138) vim/vim@efbfa86 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
No description provided.