; $Id: filters.rc,v 1.196 2004/11/03 21:02:24 tom Exp $ ; majormodes in this file are ordered alphabetically for convenience - the ; precedence used by vile is strictly alphabetic, counting case. ; This file depends upon modes.rc, which may have been source'd by vileinit.rc ; so we will check if it was not source'd. ~if &error %filters-modes source modes.rc ~elseif &seq %filters-modes '' source modes.rc ~endif unsetv %filters-modes define-mode cpp ~with define-submode cpp filtername 'vile-c-filt -k cpp' ~endwith define-mode csh ~with define-submode csh filtername 'vile-sh-filt -k csh' ~endwith define-mode java ~with define-submode java filtername 'vile-c-filt -j -p -k java' ~endwith define-mode js ~with define-submode js filtername 'vile-c-filt -j -s -p -k js' ~endwith define-mode latex ~with define-submode latex filtername 'vile-latex-filt -a' ~endwith define-mode nmake ~with define-submode nmake filtername 'vile-make-filt' ~endwith define-mode pc ~with define-submode pc filtername 'vile-tc-filt -k pc' ~endwith define-mode rb ~with define-submode rb filtername 'vile-ruby-filt -k rb' ~endwith define-mode RCS ~with define-submode RCS filtername 'vile-rcs-filt' ~endwith define-mode SCCS ~with define-submode SCCS filtername 'vile-sccs-filt' ~endwith define-mode tex ~with define-submode tex filtername 'vile-latex-filt -k tex' ~endwith define-mode vb ~with define-submode vb filtername 'vile-basic-filt -k vb' ~endwith define-mode vim ~with define-submode vim filtername 'vile-vile-filt -k vim' ~endwith store-procedure HighlightFilter 'Invoke syntax-highlighting filter on the current buffer' ~if ¬ $highlight ~return ~elseif &seq $majormode '' ~return ~elseif &filter $majormode ~local $curcol $curline ~hidden goto-beginning-of-file ~hidden attribute-directly end-of-file $majormode ~return ~else ~local $curcol $curline ~local %filtername %filterpath %filteropts ~hidden goto-beginning-of-file ~if &seq $filtername '' set-variable %filtername &cat &cat 'vile-' $majormode '-filt' ~else set-variable %filtername $filtername ~endif set-variable %filterpath &word 0 %filtername set-variable %filteropts &right %filtername &add 1 &len %filterpath ~if &seq '' &lookup e+p &cat %filterpath $exec-suffix set-variable %filterpath &lookup e+l &cat %filterpath $exec-suffix ~endif ~if ¬ &seq %filterpath '' ~hidden attribute-from-filter end-of-file &cat &pquote %filterpath &cat %filteropts &cat ' -t' $tabstop ~endif ~endif ~endm store-procedure HighlightFilterMsg 'Attach highlighting to the current buffer' HighlightFilter write-message '[Attaching attributes...]' ~endm bind-key HighlightFilterMsg ^X-q store-procedure HighlightClear 'Clear all highlighting from the current buffer' ~local $curcol $curline ~hidden goto-beginning-of-file ~hidden clear-attributes-til goto-char ~endm bind-key HighlightClear ^X-Q store-procedure set-highlighting ma 'Set a majormode and invoke highlighting' ; show-variables ~if &seq 'mode' &right $1 &sub &len $1 3 ; 9.4e write-message $1 ~force setl $1 ~else ; pre-9.4e write-message &cat $1 mode ~force setl &cat $1 mode ~endif HighlightFilter ~endm ; If we have built-in filters, and colors are available, simply turn on ; the syntax highlighting. ~if &and \ ¬ &error $filter-list \ ¬ &error $ncolors setv $read-hook HighlightFilter set autocolor=5000 setv $autocolor-hook HighlightFilter ~endif