runtime(hlyamk): Allow to highlight put regions using TextPutPost

Commit: 
https://github.com/vim/vim/commit/f45ed6465dd6d219b72c61758158dd4038a5ef95
Author: Foxe Chen <[email protected]>
Date:   Mon May 11 17:19:19 2026 +0000

    runtime(hlyamk): Allow to highlight put regions using TextPutPost
    
    closes: https://github.com/vim/vim/issues/20196
    
    Signed-off-by: Foxe Chen <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index 56e7fb9e7..4a3444b61 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -1,4 +1,4 @@
-*usr_05.txt*   For Vim version 9.2.  Last change: 2026 Feb 14
+*usr_05.txt*   For Vim version 9.2.  Last change: 2026 May 11
 
 
                     VIM USER MANUAL    by Bram Moolenaar
@@ -509,6 +509,16 @@ To highlight in visual mode, use: >
 To disable the effect of the plugin after it has been loaded: >
        au! hlyank
 
+Additionally, the plugin can also highlight regions that are put using the
+|TextPutPost| autocommand.  This is by default disabled and can be enabled
+using: >
+       :let g:hlput_enable = v:true
+<
+The following configuration variables can be used are "g:hlput_hlgroup" and
+"g:hlput_duration", which have the same effect as their yank counterparts: >
+       :let g:hlput_hlgroup = 'IncSearch'
+       :let g:hlput_duration = 300
+
 ------------------------------------------------------------------------------
 Adding the osc52 package               *osc52-install* *package-osc52*
 ------------------------------------------------------------------------------
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 45a25b08b..5121fe90c 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt* For Vim version 9.2.  Last change: 2026 May 10
+*version9.txt* For Vim version 9.2.  Last change: 2026 May 11
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -52627,6 +52627,8 @@ Other ~
 - |:command-completion-customlist| can return a list of dictionaries with
   kind/menu/info/abbr for the popup menu.
 - |C-indenting| detects comments better.
+- The |package-hlyank| can now optionally highlight the last put region as
+  well.
 
 Platform specific ~
 -----------------
diff --git a/runtime/pack/dist/opt/hlyank/plugin/hlyank.vim 
b/runtime/pack/dist/opt/hlyank/plugin/hlyank.vim
index 3e0cdb9bf..27e2a032e 100644
--- a/runtime/pack/dist/opt/hlyank/plugin/hlyank.vim
+++ b/runtime/pack/dist/opt/hlyank/plugin/hlyank.vim
@@ -1,7 +1,7 @@
 vim9script
 
 # Highlight Yank plugin
-# Last Change: 2026 Apr 11
+# Last Change: 2026 May 11
 
 def HighlightedYank()
 
@@ -36,8 +36,34 @@ def HighlightedYank()
   endif
 enddef
 
+export def HighlightedPut()
+    if !get(g:, "hlput_enable", false)
+      return
+    endif
+
+    var hlgroup = get(g:, "hlput_hlgroup", "IncSearch")
+    var duration = min([get(g:, "hlput_duration", 300), 3000])
+
+    var [beg, end] = [getpos("'["), getpos("']")]
+    var type = v:event.regtype ?? 'v'
+    var pos = getregionpos(beg, end, {type: type, exclusive: false})
+
+    var m = matchaddpos(hlgroup, pos->mapnew((_, v) => {
+        var col_beg = v[0][2] + v[0][3]
+        var col_end = v[1][2] + v[1][3] + 1
+        return [v[0][1], col_beg, col_end - col_beg]
+    }))
+    var winid = win_getid()
+    timer_start(duration, (_) => {
+        if winbufnr(winid) != -1
+            m->matchdelete(winid)
+        endif
+    })
+enddef
+
 augroup hlyank
   autocmd!
   autocmd TextYankPost * HighlightedYank()
+  autocmd TextPutPost * HighlightedPut()
 augroup END
 # vim:sts=2:sw=2:et:

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wMUSG-00HNUG-Ay%40256bit.org.

Raspunde prin e-mail lui