Skip to content
This repository
Browse code

Dynamically update note name highlighting

When switching windows the highlighting of note names will be updated
so that the names of newly created / renamed notes are highlighted.
  • Loading branch information...
commit a30b997ea2ad7042abd0363c62e858e73f789077 1 parent 9a044fb
Peter Odding authored December 24, 2010
7  autoload.vim
@@ -410,13 +410,14 @@ function! xolox#notes#indent_list(command, line1, line2) " {{{3
410 410
   normal $
411 411
 endfunction
412 412
 
413  
-function! xolox#notes#highlight_names(group) " {{{3
414  
-  " Highlight the names of all notes as {group}.
  413
+function! xolox#notes#highlight_names() " {{{3
  414
+  " Highlight the names of all notes as "notesName" (linked to "Underlined").
415 415
   let starttime = xolox#timer#start()
416 416
   let titles = filter(xolox#notes#get_titles(), '!empty(v:val)')
417 417
   call map(titles, 's:words_to_pattern(v:val)')
418 418
   call sort(titles, 's:sort_longest_to_shortest')
419  
-  execute 'syntax match' a:group '/\c\%>2l\%(' . escape(join(titles, '\|'), '/') . '\)/'
  419
+  syntax clear notesName
  420
+  execute 'syntax match notesName /\c\%>2l\%(' . escape(join(titles, '\|'), '/') . '\)/'
420 421
   call xolox#timer#stop("%s: Highlighted note names in %s.", s:script, starttime)
421 422
 endfunction
422 423
 
3  notes.vim
@@ -3,7 +3,7 @@
3 3
 " Last Change: December 24, 2010
4 4
 " URL: http://peterodding.com/code/vim/notes/
5 5
 " License: MIT
6  
-" Version: 0.7.10
  6
+" Version: 0.7.11
7 7
 
8 8
 " Support for automatic update using the GLVS plug-in.
9 9
 " GetLatestVimScripts: 3375 1 :AutoInstall: session.zip
@@ -59,6 +59,7 @@ augroup PluginNotes
59 59
   " to notes (which is IMHO better than always showing the E325 prompt).
60 60
   au BufReadCmd note:* nested call xolox#notes#shortcut()
61 61
   au SwapExists * call xolox#notes#swaphack()
  62
+  au WinEnter * if &ft == 'notes' | call xolox#notes#highlight_names() | endif
62 63
   call s:DefAutoCmd('BufWritePost', g:notes_directory, 'call xolox#notes#cleanup()')
63 64
 augroup END
64 65
 
2  syntax.vim
@@ -23,7 +23,7 @@ syntax cluster notesInline contains=notesName
23 23
 highlight def link notesHiddenMarker Ignore
24 24
 
25 25
 " Highlight note names as hyperlinks. {{{2
26  
-call xolox#notes#highlight_names('notesName')
  26
+call xolox#notes#highlight_names()
27 27
 syntax cluster notesInline add=notesName
28 28
 highlight def link notesName Underlined
29 29
 

0 notes on commit a30b997

Please sign in to comment.
Something went wrong with that request. Please try again.