Compare commits

..

2 Commits

Author SHA1 Message Date
c3ed08e42f note deletion with bang 2026-02-28 22:31:10 +01:00
040d6397cb documentation: updated to current version 2026-02-28 22:23:53 +01:00
4 changed files with 202 additions and 95 deletions

View File

@@ -70,10 +70,27 @@ references to that note.
[pattern](https://vimhelp.org/quickfix.txt.html#%3Avimgrep). [pattern](https://vimhelp.org/quickfix.txt.html#%3Avimgrep).
_Adding notes:_ Run `:DenoteNew {title}` to add a new note with the given _Adding notes:_ Run `:DenoteNew {title}` to add a new note with the given
title. title. You may also copy a file (any file) to your denote directory. To do so,
run `:DenoteCopy {file}`.
_Managing entries:_ You can change the title of denote entries using
`:DenoteSetTitle {newtitle}`. Also, you can add and remove tags using
`:DenoteTagAdd {tag}` and `:DenoteTagRm {tag}`, respectively. These latter two
commands offer auto completion for the tags. Also, they accept line ranges that
may be given via, e.g., visual selection. Finally, denote entries are deleted
using `:DenoteDelete`. This command again accepts line ranges.
[^1]: Run `:help g:denote_directories` for more information. [^1]: Run `:help g:denote_directories` for more information.
### Basic keys
The denote location-list window comes with a set of keys:
- `q`: close the list
- `r`: reload the list
- `C`: rename the selected entry
- `+`: add a tag to the entry (also in visual mode)
- `-`: remove a tag from the entry (also in visual mode)
- `dd`: delete the selected entry (also in visual mode, using a single `d`)
### Example setup ### Example setup
You get a possibly useful setup with a single default denote directory at You get a possibly useful setup with a single default denote directory at
`~/Documents/notes/` by placing these lines in your vimrc file: `~/Documents/notes/` by placing these lines in your vimrc file:
@@ -91,14 +108,12 @@ using the `<Leader>d` key, move forwards and backwards in the list using the
`<Leader>D` key (again, you can jump around the references using `[l` and `<Leader>D` key (again, you can jump around the references using `[l` and
`]l`). `]l`).
### Customization ### Customization
You can customize the behavior of this package using several You can customize the behavior of this package using several
global variables. Customization is explained in the [help global variables. Customization is explained in the [help
file](doc/denote.txt), also accessible through `:help denote-settings`. file](doc/denote.txt), also accessible through `:help denote-settings`.
### Future features These features are planned: ### Future features
- Tag manipulation
- Title manipulation
- Signature handling? - Signature handling?
- Note deletion? - Subdirectories
- Denote query links

View File

@@ -45,7 +45,7 @@ function denote#ft#qf()
command! -nargs=1 -range -buffer DenoteSetTitle :call denote#notes#settitle(<line1>, <q-args>) command! -nargs=1 -range -buffer DenoteSetTitle :call denote#notes#settitle(<line1>, <q-args>)
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagAdd :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:true) command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagAdd :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:true)
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagRm :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:false) command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagRm :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:false)
command! -range -buffer DenoteDelete :call denote#notes#rm(<line1>, <line2>) command! -range -buffer -bang DenoteDelete :call denote#notes#rm(<line1>, <line2>, <bang>0)
nnoremap <buffer> C :DenoteSetTitle nnoremap <buffer> C :DenoteSetTitle
nnoremap <buffer> + :DenoteTagAdd nnoremap <buffer> + :DenoteTagAdd
nnoremap <buffer> - :DenoteTagRm nnoremap <buffer> - :DenoteTagRm

View File

@@ -146,7 +146,8 @@ function denote#notes#copy(origfile)
endfunction endfunction
" Delete notes from denote directory " Delete notes from denote directory
function denote#notes#rm(line1, line2) function denote#notes#rm(line1, line2, bang)
echom "bang set to:"..a:bang
let l:items = getloclist(0, {'items': 1})['items'] let l:items = getloclist(0, {'items': 1})['items']
if empty(l:items) if empty(l:items)
return return
@@ -156,10 +157,12 @@ function denote#notes#rm(line1, line2)
let l:bufnr = l:item['bufnr'] let l:bufnr = l:item['bufnr']
let l:filename = bufname(l:bufnr) let l:filename = bufname(l:bufnr)
let l:title = denote#meta#noteTitleFromFile(l:filename) let l:title = denote#meta#noteTitleFromFile(l:filename)
if a:bang == v:false
let l:answer = confirm('Are you sure you want to delete the note "' .. l:title .. '"?', "&Yes\n&No\n", 2, 'Question') let l:answer = confirm('Are you sure you want to delete the note "' .. l:title .. '"?', "&Yes\n&No\n", 2, 'Question')
if l:answer != 1 if l:answer != 1
continue continue
endif endif
endif
" Wipe buffer, if it exists " Wipe buffer, if it exists
if bufexists(l:filename) if bufexists(l:filename)
exe 'silent bwipe ' .. fnameescape(l:filename) exe 'silent bwipe ' .. fnameescape(l:filename)

View File

@@ -1,4 +1,6 @@
*denote.txt* For Vim version 9.0. Last change: 2026 Feb 26 *denote.txt* Handling denote entries the vim way
Last change: 2026 Feb 28
This is the documentation for the denote plugin. This is the documentation for the denote plugin.
@@ -7,12 +9,14 @@ CONTENTS *vim-denote* *denote*
1. Introduction |denote-intro| 1. Introduction |denote-intro|
2. Commands |denote-commands| 2. Commands |denote-commands|
2.1 Universal commands |denote-universal-commands|
2.2 Note command |denote-note-command|
2.3 Denote-list commands |denote-list-commands|
3. Settings |denote-settings| 3. Settings |denote-settings|
4. Keys |denote-keys| 4. Keys |denote-keys|
============================================================================== ==============================================================================
*denote-intro* INTRODUCTION *denote-intro*
Introduction ~
Denote is a file-naming scheme developed by Protesilaos Stavrou and an Emacs Denote is a file-naming scheme developed by Protesilaos Stavrou and an Emacs
tool for handling such files. Notes and other files that follow this scheme tool for handling such files. Notes and other files that follow this scheme
@@ -21,24 +25,35 @@ do adjusting the tags or changing the title of a note. The official manual is
available online: available online:
https://protesilaos.com/emacs/denote https://protesilaos.com/emacs/denote
The denote plugin adds denote functionality to vim --- the vim way. We are The denote plugin adds denote functionality to vim the vim way. We are aware
aware of two other plugins, but we fear that these plugins are not flexible of two other plugins, but we fear that these plugins are not flexible enough,
enough, and more importantly, do not follow the vim philosophy for handling and more importantly, do not follow the vim philosophy for handling denote
denote notes. These mentioned plugins are available here: notes. These mentioned plugins are available here:
https://github.com/shuckster/denote-md https://github.com/shuckster/denote-md
https://git.sr.ht/~ashton314/vim-denote https://git.sr.ht/~ashton314/vim-denote
In contrast to these plugins, the present package relies on the In contrast to these plugins, the present package relies on the
|location-list| features for displaying denote entries, and on the options |location-list| features for displaying denote entries, and on the options
|'quickfixtextfunc'|, |'includeexpr'|, and |'omnifunc'|. With these, denote 'quickfixtextfunc', 'includeexpr', and 'omnifunc'. With these, denote links
links can be followed using |gf|, and completed using omni comletion (see, can be followed using |gf|, and completed using omni completion (see,
|compl-omni|). For link completion, press |i_CTRL-X_CTRL-O| after typing any |compl-omni|). For link completion, press |i_CTRL-X_CTRL-O| after typing any
prefix of a denote link. This completion also works with titles: by invoking prefix of a denote link. This completion also works with titles: by invoking
omni completion after typing "denote:foo", denote links are completed for omni completion after typing "denote:foo", denote links are completed for
entries containing "foo" in the title. entries containing "foo" in the title.
*denote-commands* ==============================================================================
Commands ~ COMMANDS *denote-commands*
After loading this package, only the first of the following commands is
available. This first command, as descried below, sets the directory to be
used for the denote entries. After that command has been issued, several other
commands become possible, such as |:DenoteTag|. Some command are available
within any window, others only in denote notes, and yet other again only in
the location-list that lists denote entries.
*denote-universal-commands*
Universal commands~
*:DenoteDirectory* *:DenoteDirectory*
*:DenoteDirectory!* *:DenoteDirectory!*
:DenoteDirectory[!] {path} :DenoteDirectory[!] {path}
@@ -48,19 +63,22 @@ Commands ~
system. Without the bang, only directories listed in the system. Without the bang, only directories listed in the
|g:denote_directories| variable are autocompleted. |g:denote_directories| variable are autocompleted.
After the denote directory has been specified, the following commands become
available. They all operate on that specified directory.
*:Denote* *:Denote*
:Denote [{keyword ..}] :Denote [{keyword ..}]
Populate the location list of the current window with the denote Populate the location list of the current window with the denote
entries present in the current directory. This command may be entries present in the specified directory. This command may be
supplemented with any number of arguments that filter the entries supplemented with any number of arguments that filter the entries
according to the appearance of the keywords in the file name. according to the appearance of the keywords in the file name.
*:DenoteTag* *:DenoteByTag*
:DenoteTag {tag} :DenoteByTag {tag}
This command takes as argument a tag, and populates the location list This command takes as argument a tag, and populates the location list
with all denote entries of that are tagged accordingly. The tags are with all denote entries of that are tagged accordingly. The tags are
autocompleted (see, |c_<Tab>|). Also fuzzy matching is possible when autocompleted (see, |c_<Tab>|). Also fuzzy matching is possible when
"fuzzy" is contained in |'wildoptions'|. "fuzzy" is contained in 'wildoptions'.
*:DenoteGrep* *:DenoteGrep*
:DenoteGrep /{pattern}/[g][j][f] :DenoteGrep /{pattern}/[g][j][f]
@@ -74,14 +92,67 @@ Commands ~
denote entry with the specified title. The entry file type is denote entry with the specified title. The entry file type is
controlled by the setting |g:denote_new_ft|. controlled by the setting |g:denote_new_ft|.
*:DenoteCopy*
:DenoteCopy {file}
With this, the specified file is copied into the denote directory. The
file name is taken as the title, and the identifier is freshly
generated. Any file, i.e., not only those specified using
|g:denote_note_file_extension| may be chosen.
*denote-note-command*
Note command~
This is the only command exclusive to the windows that hold denote note
entries, i.e., files with an extension in |g:denote_note_file_extension|.
*:DenoteBackReferences* *:DenoteBackReferences*
:DenoteBackReferences :DenoteBackReferences
This command populates the location list with all references to the This command populates the location list with all references to the
current note. This command can only be called from an opened denote current note. This command can only be called from an opened denote
note. note.
*denote-settings*
Settings ~ *denote-list-commands*
Denote-list commands~
The denote list may be opened using one of the commands |:Denote| or
|:DenoteByTag|. Also the commands |:DenoteGrep| and |:DenoteBackReferences|
open the location list, but not as a list of entries, but as a list of
matching patterns. The following commands are available in the denote list
(first case).
*:DenoteSetTitle*
:DenoteSetTitle {string}
The title of the selected entry is changed as specified.
*:DenoteTagAdd*
:DenoteTagAdd {tag}
With this, the provided tag is added to the list of tags of the
selected entry. The tag may be autocompleted. This command also
accepts a range, resulting in adding the tag to every entry within
that range.
*:DenoteTagRm*
:DenoteTagRm {tag}
Just as above, but for removing the specified tag.
*:DenoteDelete*
:DenoteDelete[!]
With this, the selected entry is deleted from the denote directory
(and from the disk). This command also accepts a range, to delete a
bunch of entries. After the deletion command has been invoked, the
user is asked to confirm the deletion. With the optional bang, no
confirmation will be asked.
==============================================================================
SETTINGS *denote-settings*
All settings described below are set to default values. For this package to
function, it is not necessary to specify a setting manually.
*g:denote_directories* *g:denote_directories*
g:denote_directories list g:denote_directories list
With this option, may may specify a list of your denote directories. With this option, may may specify a list of your denote directories.
@@ -135,20 +206,20 @@ g:Denote_identifier_fun Funcref
> >
let g:Denote_identifier_fun = function('denote#meta#identifier_generate') let g:Denote_identifier_fun = function('denote#meta#identifier_generate')
< <
which calls |strftime('%Y%m%dT%H%M%S')| if |strftime()| is available, and which calls |strftime('%Y%m%dT%H%M%S')| if |strftime()| is available,
|rand()| otherwise. Another reasonable setting would be to use some uuid and |rand()| otherwise. Another reasonable setting would be to use
generator and to specify, e.g., some uuid generator and to specify, e.g.,
> >
let g:Denote_identifier_fun = { -> system('uuidgen') let g:Denote_identifier_fun = { -> system('uuidgen')
\ ->substitute('[^[:xdigit:]]', '', 'g') } \ ->substitute('[^[:xdigit:]]', '', 'g') }
< <
*denote-keys* ==============================================================================
Keys ~ KEYS *denote-keys*
The location windows generated by the present package, e.g., through the The location lists generated by the present package, e.g., through the command
command |:DenoteGrep| or |:DenoteByTag|, has the following key key-bindings. |:DenoteGrep| or |:DenoteByTag|, have the following key key-bindings.
*denote-r* *denote-r*
r Reload the location list. r Reload the location list.
@@ -156,4 +227,22 @@ r Reload the location list.
*denote-q* *denote-q*
q Close the location list. q Close the location list.
In addition, denote lists (see |denote-list-commands|) come with the following
keys:
*denote-list-C*
C Change the title of the selected entry.
*denote-list-+*
+ Add a tag to the selected entries (also in visual mode).
*denote-list--*
- As |denote-list-+| but for removing tags.
*denote-list-dd*
dd Delete the selected entry.
{Visual}d Delete the visually selected entries.
vim:tw=78:sw=4:ts=8:noet:ft=help:norl: vim:tw=78:sw=4:ts=8:noet:ft=help:norl: