bugfix: use of funcref in settings
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ 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 '/'
|
||||||
|
|||||||
Reference in New Issue
Block a user