From 066649053a871f5e17b6e1663e550fca94695e4a Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sun, 25 Mar 2018 10:25:32 +0200 Subject: [PATCH] Add ingo#funcref#AsString() In contrast to ingo#funcref#ToString(), this can be useful when concatenating Funcrefs (and keep them as Funcrefs, i.e. with the function(...)) with other types, avoiding "E729: using Funcref as a String". --- README.md | 1 + autoload/ingo/funcref.vim | 6 +++++- doc/ingo-library.txt | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9314d50..4c82cbf 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ HISTORY - Add ingo/workingdir.vim module. - Add ingo/selection/virtcols.vim module. - Add ingo/str/list.vim module. +- Add ingo#funcref#AsString(). ##### 1.034 13-Feb-2018 - Add ingo/regexp/split.vim module. diff --git a/autoload/ingo/funcref.vim b/autoload/ingo/funcref.vim index 02852bb..1e3f633 100644 --- a/autoload/ingo/funcref.vim +++ b/autoload/ingo/funcref.vim @@ -2,7 +2,7 @@ " " DEPENDENCIES: " -" Copyright: (C) 2013-2017 Ingo Karkat +" Copyright: (C) 2013-2018 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat @@ -15,4 +15,8 @@ function! ingo#funcref#ToString( Funcref ) return (empty(l:functionName) ? '' . a:Funcref : l:functionName) endfunction +function! ingo#funcref#AsString( Funcref ) + return (type(a:Funcref) == 2 ? string(a:Funcref) : a:Funcref) +endfunction + " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : diff --git a/doc/ingo-library.txt b/doc/ingo-library.txt index fe127c9..5b91eaf 100644 --- a/doc/ingo-library.txt +++ b/doc/ingo-library.txt @@ -100,6 +100,7 @@ HISTORY *ingo-library-history* - Add ingo/workingdir.vim module. - Add ingo/selection/virtcols.vim module. - Add ingo/str/list.vim module. +- Add ingo#funcref#AsString(). 1.034 13-Feb-2018 - Add ingo/regexp/split.vim module.