bugfix: use of funcref in settings

This commit is contained in:
2026-02-26 13:44:44 +01:00
parent d6bc3cbb04
commit 7a82fe32db
4 changed files with 20 additions and 16 deletions

View File

@@ -35,9 +35,6 @@ endfunction
" Identifier creation
function denote#meta#identifier_generate()
if g:denote_identifier_fun
return execute 'call ' .. g:denote_identifier_fun .. '()'
endif
return exists('*strftime')
\ ? strftime('%Y%m%dT%H%M%S')
\ : rand()

View File

@@ -26,7 +26,7 @@ endfunction
" This creates a new denote entry with the given title and of the given
" filetype. The title may be empty.
function denote#notes#new(title, ft=g:denote_new_ft)
let l:identifier=denote#meta#identifier_generate()
let l:identifier=g:Denote_identifier_fun()
let l:fn=l:identifier .. '--' .. a:title
\ ->tolower()
\ ->substitute('[^[:fname:]]\|/', '-', 'g')

View File

@@ -125,15 +125,22 @@ g:denote_fm_md_type string
let g:denote_fm_md_type = 'yaml'
<
*g:denote_identifier_fun*
g:denote_identifier_fun Funcref
*g:Denote_identifier_fun*
g:Denote_identifier_fun Funcref
Denote allows the use of custom identifiers. This variable, if set,
points to a function that generates identifiers for newly created
notes. The function is supposed to return a unique string. By default,
the identifiers are computed with
the variable set as
>
strftime('%Y%m%dT%H%M%S')
let g:Denote_identifier_fun = function('denote#meta#identifier_generate')
<
or with |rand()| if the function |strftime()| is unavailable.
which calls |strftime('%Y%m%dT%H%M%S')| if |strftime()| is available, and
|rand()| otherwise. Another reasonable setting would be to use some uuid
generator and to specify, e.g.,
>
let g:Denote_identifier_fun = { -> system('uuidgen')
\ ->substitute('[^[:xdigit:]]', '', 'g') }
<
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

View File

@@ -32,8 +32,8 @@ endif
" By using the following global variable, the user may specify a custom
" function for creating identifiers.
if !exists('g:denote_identifier_fun')
let g:denote_identifier_fun=''
if !exists('g:Denote_identifier_fun')
let g:Denote_identifier_fun = function('denote#meta#identifier_generate')
endif
" Transform full path into canonical form WITH trailing '/'