[vim/vim] Add support for here document in :let statement (#4386)

30 views
Skip to first unread message

Yegappan Lakshmanan

unread,
May 18, 2019, 1:25:17 AM5/18/19
to vim/vim, Subscribed

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/4386

Commit Summary

  • Add support for here document in :let statement

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Codecov

unread,
May 18, 2019, 1:45:42 AM5/18/19
to vim/vim, Subscribed

Codecov Report

Merging #4386 into master will increase coverage by 0.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@

##           master    #4386      +/-   ##

==========================================

+ Coverage   80.35%   80.37%   +0.01%     

==========================================

  Files         109      109              

  Lines      142608   142638      +30     

==========================================

+ Hits       114591   114640      +49     

+ Misses      28017    27998      -19
Impacted Files Coverage Δ
src/eval.c 85.96% <83.33%> (-0.02%) ⬇️
src/screen.c 81.54% <0%> (-0.05%) ⬇️
src/message.c 76.65% <0%> (+0.04%) ⬆️
src/channel.c 83.58% <0%> (+0.07%) ⬆️
src/ex_cmds2.c 87.9% <0%> (+0.11%) ⬆️
src/gui_gtk_x11.c 48.74% <0%> (+0.49%) ⬆️
src/gui.c 57.99% <0%> (+0.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8055d17...2ef9cfc. Read the comment docs.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or mute the thread.

Yegappan Lakshmanan

unread,
May 18, 2019, 3:13:29 AM5/18/19
to vim/vim, Push

@yegappan pushed 1 commit.

  • 9a21e8e Add support for stripping tab characters at the beginning of lines


You are receiving this because you are subscribed to this thread.

View it on GitHub

chdiza

unread,
May 18, 2019, 9:41:29 AM5/18/19
to vim/vim, Subscribed

What is this for? We can already do e.g. :let foo="oof\nbar\tbaz", right?

In particular I see no need for the stripping aspect. When using :let inside a script we can also already use line continuation. So just do

let foo="one
    \two
    \three
\four"

Yegappan Lakshmanan

unread,
May 18, 2019, 10:07:56 AM5/18/19
to vim_dev, reply+ACY5DGFOICUYKGNW6U...@reply.github.com, vim/vim, Subscribed
Hi,

On Sat, May 18, 2019 at 6:41 AM chdiza <vim-dev...@256bit.org> wrote:
>
> What is this for? We can already do e.g. :let foo="oof\nbar\tbaz", right?
>

When you want to assign a lot of lines with indentation (for example, a code
snippet) to a variable, it is more readable and maintainable to use the
list of lines without quotes and "\" at the beginning of the line for line
continuation. This is used in various places in the Vim test scripts.
Using a string with embedded newlines or a list with line continuation and
quotation makes it harder to read and understand what the test is doing.

>
> In particular I see no need for the stripping aspect. When using :let inside
> a script we can also already use line continuation. So just do
>

When using the here document syntax, you may want to align the lines in
the here document with the surrounding code. The support for stripping
the leading indentation is meant for aligning the lines.

https://riptutorial.com/bash/example/2135/indenting-here-documents

- Yegappan

vim-dev ML

unread,
May 18, 2019, 10:08:16 AM5/18/19
to vim/vim, vim-dev ML, Your activity

Houl

unread,
May 18, 2019, 11:16:17 AM5/18/19
to vim/vim, vim-dev ML, Comment

What about making {marker} optional and use . per default (a single dot on its own line)? This is expected from :i, :a etc.


You are receiving this because you commented.

Bram Moolenaar

unread,
May 18, 2019, 12:52:30 PM5/18/19
to vim...@googlegroups.com, Houl

> What about making `{marker}` optional and use `.` per default (a
> single dot on its own line)? This is expected from `:i`, `:a` etc.

Hmm, that's possible, but I think having the explicit marker is clearer.
It's not like it is much text to type.

--
Git catch 22: "merge is not possible because you have unmerged files."

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
May 18, 2019, 3:16:29 PM5/18/19
to vim/vim, vim-dev ML, Push

@yegappan pushed 1 commit.

  • 4a1af2c Support the 'trim' argument for removing the leading indentation. Support the default '.' marker


You are receiving this because you are subscribed to this thread.

View it on GitHub

Yegappan Lakshmanan

unread,
May 18, 2019, 3:29:53 PM5/18/19
to vim/vim, vim-dev ML, Push

@yegappan pushed 1 commit.

  • 1d30ba4 Add additional test cases


You are receiving this because you are subscribed to this thread.

View it on GitHub

Yegappan Lakshmanan

unread,
May 18, 2019, 4:08:28 PM5/18/19
to vim/vim, vim-dev ML, Push

@yegappan pushed 1 commit.

  • bb5ad34 Remove the unnecessary check


You are receiving this because you are subscribed to this thread.

View it on GitHub

Bram Moolenaar

unread,
May 19, 2019, 12:42:18 PM5/19/19
to vim/vim, vim-dev ML, Comment

Closed #4386 via f5842c5.


You are receiving this because you commented.

ichizok

unread,
May 19, 2019, 1:04:28 PM5/19/19
to vim/vim, vim-dev ML, Comment

There are some patterns cannot work: e.g. a line starts with endfunc append python...

func Foo()
  let x =<<
endfunc
..
endfunc

E193: :endfunction not inside a function

func Foo()
  let x =<<END
a
END
endfunc

E126: Missing :endfunction

func Foo()
  let x =<<END
python <<EOS
END
endfunc

E126: Missing :endfunction


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
May 19, 2019, 1:42:11 PM5/19/19
to vim_dev, reply+ACY5DGDLPMNQM6FUUT...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Sun, May 19, 2019 at 10:04 AM ichizok <vim-dev...@256bit.org> wrote:
>
> There are some patterns cannot work: e.g. a line starts with endfunc append python...
>

The Vim script parser is interpreting the "endfunc" text within a here document
as a statement instead of treating simply as a text string. I don't
have a fix for this
currently.

- Yegappan

vim-dev ML

unread,
May 19, 2019, 1:42:29 PM5/19/19
to vim/vim, vim-dev ML, Your activity

Houl

unread,
May 19, 2019, 3:11:52 PM5/19/19
to vim/vim, vim-dev ML, Comment

Btw, when I need some heredoc data, I put a finish line in the code, followed by a data section in heredoc notation which is later at "runtime" extracted with a bit of Vimscript into a dict.


You are receiving this because you commented.

Bram Moolenaar

unread,
May 19, 2019, 3:37:44 PM5/19/19
to vim...@googlegroups.com, Yegappan Lakshmanan, reply+ACY5DGDLPMNQM6FUUT...@reply.github.com

Yegappan wrote:

> On Sun, May 19, 2019 at 10:04 AM ichizok <vim-dev...@256bit.org> wrote:
> >
> > There are some patterns cannot work: e.g. a line starts with endfunc append python...
> >
>
> The Vim script parser is interpreting the "endfunc" text within a here document
> as a statement instead of treating simply as a text string. I don't
> have a fix for this
> currently.

We handle this for "python << END", we can do something similar.

--
It doesn't really matter what you are able to do if you don't do it.
(Bram Moolenaar)

vim-dev ML

unread,
May 19, 2019, 3:38:00 PM5/19/19
to vim/vim, vim-dev ML, Your activity

Yegappan Lakshmanan

unread,
May 19, 2019, 3:46:08 PM5/19/19
to vim_dev, reply+ACY5DGCUWMTKM44OMN...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Sun, May 19, 2019 at 12:11 PM Houl <vim-dev...@256bit.org> wrote:
>
> Btw, when I need some heredoc data, I put a finish line in the code, followed
> by a data section in heredoc notation which is later at "runtime" extracted
> with a bit of Vimscript into a dict.
>

Hopefully the new heredoc feature will simplify this use case. Let us know
if you see any issues with this feature.

- Yegappan

vim-dev ML

unread,
May 19, 2019, 3:46:32 PM5/19/19
to vim/vim, vim-dev ML, Your activity
Reply all
Reply to author
Forward
0 new messages