created January 19, 2003 · complexity basic · author Suresh Govindachar · version 6.0
To enhance Calendar script#52 with display of special dates:
Step 1. Create a file called "holidays" in the directory assigned to g:calendar_diary (default value for g:calendar_diary is ~/diary).
This file will contain the special dates. Essence of contents of the holidays file is the special dates encoded as (10000+(month*100)+day).
Example contents of file g:calendar_diary/holidays
List of holidays: ^(10000 + ((month * 100)+day)) Encoded Sign Color Description Date 10101 n blue Jan 01 (Wed) - New Year's Day 10217 p blue Feb 17 (Mon) - President's Day 10214 v red Feb 14 (Fri) - Valentine's Day 10414 s green Apr 14 (Mon) - Spring Break 10526 m blue May 26 (Mon) - Memorial Day 10703 i gold 10704 i gold Jul 3&4 (Thu & Fri)- Independence Day + 1 day 10901 l blue Sep 01 (Mon) - Labor Day 11127 t blue Nov 27&28(Thu & Fri)- Thanksgiving Day + 1 day 11128 t blue 11225 c silver Dec 25&26(Thu & Fri)- Christmas Day + 1 day 11226 c silver Dec 25&26(Thu & Fri)- Christmas Day + 1 day
Step 2. Add the following to your vimrc file:
let calendar_sign = 'MyGetSpecialDay' function! MyGetSpecialDay(day, month, year) let l:m100d = 10000 + (a:month * 100 ) + a:day let l:holidays = expand(g:calendar_diary) . "/holidays" exe "split " . l:holidays let l:found = search(l:m100d) if l:found let l:found = 'h' endif quit return l:found endfunction
Note: The preceding constitutes basic support for display of special dates. With this basic support, all special dates are shown with the same sign (viz. +) and the same highlight color. An enhancement would be to pick up the sign and the highlight color from the holidays file. (Also, I suspect management of buffer for the holidays file can be speeded up, perhaps by opening it only once, keeping it in the background and searching with warp-around flag ('w').)