From a3a9f86d4a11029542a94b00044b5a181a68c9cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Feb 2025 13:40:26 +0800 Subject: vim-patch:8.2.4594: need to write script to a file to be able to source them Problem: Need to write script to a file to be able to source them. Solution: Make ":source" use lines from the current buffer. (Yegappan Lakshmanan et al., closes vim/vim#9967) https://github.com/vim/vim/commit/36a5b6867bb6c0bd69c8da7d788000ab8a0b0ab0 Most code and test changes are reverted or modified again in patch 8.2.4603, so only port parts that are untouched in patch 8.2.4603. Co-authored-by: Yegappan Lakshmanan --- runtime/doc/repeat.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index e65caa72ed..4c95066998 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -192,14 +192,19 @@ Using Vim scripts *using-scripts* For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:so* *:source* *load-vim-script* -:[range]so[urce] [file] Runs |Ex-commands| or Lua code (".lua" files) from - [file]. - If no [file], the current buffer is used and treated - as Lua code if 'filetype' is "lua" or its filename - ends with ".lua". +:so[urce] {file} Runs |Ex-commands| or Lua code (".lua" files) from + {file}. Triggers the |SourcePre| autocommand. + +:[range]so[urce] Read Ex commands or Lua code from the [range] of lines + in the current buffer. The buffer is treated as Lua + code if 'filetype' is "lua" or its filename ends with + ".lua". When sourcing commands or Lua code from the + current buffer, the same script-ID || is used + even if the buffer is sourced multiple times. + *:source!* -:[range]so[urce]! {file} +:so[urce]! {file} Runs |Normal-mode| commands from {file}. When used after |:global|, |:argdo|, |:windo|, |:bufdo|, in a loop or when another command follows the display -- cgit From 6750d00fe96a04ab19cfc55fb406f6b40dbf970f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Apr 2024 16:20:19 +0800 Subject: vim-patch:8.2.4603: sourcing buffer lines is too complicated Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) https://github.com/vim/vim/commit/85b43c6cb7d56919e245622f4e42db6d8bee4194 This commit changes the behavior of sourcing buffer lines to always have a script ID, although sourcing the same buffer always produces the same script ID. vim-patch:9.1.0372: Calling CLEAR_FIELD() on the same struct twice Problem: Calling CLEAR_FIELD() on the same struct twice. Solution: Remove the second CLEAR_FIELD(). Move the assignment of cookie.sourceing_lnum (zeertzjq). closes: vim/vim#14627 https://github.com/vim/vim/commit/f68517c1671dfedcc1555da50bc0b3de6d2842f6 Co-authored-by: Yegappan Lakshmanan --- runtime/doc/repeat.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 4c95066998..d653a8f9fd 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -201,7 +201,9 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. code if 'filetype' is "lua" or its filename ends with ".lua". When sourcing commands or Lua code from the current buffer, the same script-ID || is used - even if the buffer is sourced multiple times. + even if the buffer is sourced multiple times. If a + buffer is sourced more than once, then the functions + in the buffer are redefined again. *:source!* :so[urce]! {file} @@ -394,10 +396,10 @@ An alternative is to put the commands in a file, and execute them with the ':source!' command. Useful for long command sequences. Can be combined with the ':map' command to put complicated commands under a function key. -The ':source' command reads Ex commands from a file line by line. You will -have to type any needed keyboard input. The ':source!' command reads from a -script file character by character, interpreting each character as if you -typed it. +The ':source' command reads Ex commands from a file or a buffer line by line. +You will have to type any needed keyboard input. The ':source!' command reads +from a script file character by character, interpreting each character as if +you typed it. Example: When you give the ":!ls" command you get the |hit-enter| prompt. If you ':source' a file with the line "!ls" in it, you will have to type the -- cgit From 7c6a9c55890f77fc7b571de649c232d70db3a01a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Feb 2025 14:00:30 +0800 Subject: vim-patch:8.2.4607: sourcing buffer lines may lead to errors for conflicts Problem: Sourcing buffer lines may lead to errors for conflicts. Solution: Add the ++clear argument. (Yegappan Lakshmanan, closes vim/vim#9991) https://github.com/vim/vim/commit/35dc17634dd6da5b90bd1b0160c4ed9e394f4b87 Documentation changes only. Vim9script is N/A. Cherry-pick another documentation change for :source from latest Vim. Co-authored-by: Yegappan Lakshmanan --- runtime/doc/repeat.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index d653a8f9fd..158ea6a4a1 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -197,13 +197,15 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Triggers the |SourcePre| autocommand. :[range]so[urce] Read Ex commands or Lua code from the [range] of lines - in the current buffer. The buffer is treated as Lua - code if 'filetype' is "lua" or its filename ends with - ".lua". When sourcing commands or Lua code from the - current buffer, the same script-ID || is used - even if the buffer is sourced multiple times. If a - buffer is sourced more than once, then the functions - in the buffer are redefined again. + in the current buffer. When [range] is omitted read + all lines. The buffer is treated as Lua code if its + 'filetype' is "lua" or its filename ends with ".lua". + + When sourcing commands or Lua code from the current + buffer, the same script-ID || is used even if the + buffer is sourced multiple times. If a buffer is + sourced more than once, then the functions in the + buffer are defined again. *:source!* :so[urce]! {file} -- cgit