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 " Identifier creation
function denote#meta#identifier_generate() function denote#meta#identifier_generate()
if g:denote_identifier_fun
return execute 'call ' .. g:denote_identifier_fun .. '()'
endif
return exists('*strftime') return exists('*strftime')
\ ? strftime('%Y%m%dT%H%M%S') \ ? strftime('%Y%m%dT%H%M%S')
\ : rand() \ : rand()

View File

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

View File

@@ -125,15 +125,22 @@ g:denote_fm_md_type string
let g:denote_fm_md_type = 'yaml' let g:denote_fm_md_type = 'yaml'
< <
*g:denote_identifier_fun* *g:Denote_identifier_fun*
g:denote_identifier_fun Funcref g:Denote_identifier_fun Funcref
Denote allows the use of custom identifiers. This variable, if set, Denote allows the use of custom identifiers. This variable, if set,
points to a function that generates identifiers for newly created points to a function that generates identifiers for newly created
notes. The function is supposed to return a unique string. By default, 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: vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

View File

@@ -2,7 +2,7 @@
" List of denote directories " List of denote directories
if !exists('g:denote_directories') if !exists('g:denote_directories')
let g:denote_directories=[] let g:denote_directories = []
endif endif
call map(g:denote_directories, {_, d -> fnamemodify(d, ':p')}) call map(g:denote_directories, {_, d -> fnamemodify(d, ':p')})
" If only one directory has been specified, use that as denote directory " If only one directory has been specified, use that as denote directory
@@ -12,28 +12,28 @@ call map(g:denote_directories, {_, d -> fnamemodify(d, ':p')})
" Restrict basic operations to these files " Restrict basic operations to these files
if !exists('g:denote_note_file_extensions') if !exists('g:denote_note_file_extensions')
let g:denote_note_file_extensions=['md', 'org', 'txt'] let g:denote_note_file_extensions = ['md', 'org', 'txt']
endif endif
" Number of columns used for the title in the location window " Number of columns used for the title in the location window
if !exists('g:denote_loc_title_columns') if !exists('g:denote_loc_title_columns')
let g:denote_loc_title_columns=40 let g:denote_loc_title_columns = 40
endif endif
" Default filetype for newly created denote entries " Default filetype for newly created denote entries
if !exists('g:denote_new_ft') if !exists('g:denote_new_ft')
let g:denote_new_ft='md' let g:denote_new_ft = 'md'
endif endif
" Default front-matter type for markdown notes, may be one of 'yaml' or 'toml' " Default front-matter type for markdown notes, may be one of 'yaml' or 'toml'
if !exists('g:denote_fm_md_type') if !exists('g:denote_fm_md_type')
let g:denote_fm_md_type='yaml' let g:denote_fm_md_type = 'yaml'
endif endif
" By using the following global variable, the user may specify a custom " By using the following global variable, the user may specify a custom
" function for creating identifiers. " function for creating identifiers.
if !exists('g:denote_identifier_fun') if !exists('g:Denote_identifier_fun')
let g:denote_identifier_fun='' let g:Denote_identifier_fun = function('denote#meta#identifier_generate')
endif endif
" Transform full path into canonical form WITH trailing '/' " Transform full path into canonical form WITH trailing '/'