"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "vil96w32/which.rc" of archive vile-w32.zip:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 ;; $Header: /usr/build/vile/vile/macros/RCS/which.rc,v 1.15 2006/10/25 22:37:36 tom Exp $
    2 ;;
    3 ;; Show where vile looks for keyword file, and where it finds it.  If we
    4 ;; always implemented built-in filters, the natural place for this would be
    5 ;; within filters/filters.c - and no need for a macro.  But we may have
    6 ;; configured with external filters.  Rather than maintain two chunks of
    7 ;; similar C code, this is implemented as a macro (as an exercise ;-.
    8 
    9 store-procedure WhichFilename f='Filename'
   10 	~local %flag
   11 	newline
   12 	~if &rd $1
   13 		insert-string '* '
   14 		setv %found="yes"
   15 	~else
   16 		insert-string '  '
   17 	~endif
   18 	insert-string $1
   19 ~endm
   20 
   21 store-procedure which-filter major="MajorMode" "Prompt for, and display location of filter program"
   22 	~if &seq '' $1
   23 		~return
   24 	~endif
   25 	~local $autocolor $majormode
   26 	~local %mybuffer %filtername %long %short %path %index %found
   27 
   28 	setv %long=$1
   29 	setv %short=&left $1 &sub &len $1 4
   30 
   31 	setv %mybuffer='[Which Filter]'
   32 	~if &isa buffer %mybuffer
   33 		~force select-buffer %mybuffer
   34 		setl noreadonly noview
   35 		~if &greater $bchars 0
   36 			goto-beginning-of-file
   37 			delete-lines-til end-of-file
   38 		~endif
   39 	~else
   40 		edit-buffer %mybuffer
   41 	~endif
   42 	setl noai
   43 
   44 	; turn off autocolor
   45 	set autocolor=0
   46 	; set the majormode so we can see what the filtername is
   47 	~hidden setl %long
   48 	; filtername is set only when it is not the default for the mode.
   49 	; Capture a copy of its value, which may be ERROR.
   50 	setv %filtername=$filtername
   51 	~hidden unsetl %long
   52 
   53 	; If $filtername was not set, we can still make a good guess.
   54 	~if &error %filtername
   55 		setv %filtername=&cat 'vile-' &cat %short '-filt'
   56 	~elseif &seq %filtername ''
   57 		setv %filtername=&cat 'vile-' &cat %short '-filt'
   58 	~else
   59 		setv %filtername=&cat &word 0 %filtername
   60 	~endif
   61 	setv %filtername=&cat %filtername $exec-suffix
   62 
   63 	;
   64 	insert-string 'Show which filter-files are tested for:'
   65 	newline
   66 	insert-string &cat &chr 9 %long
   67 	newline
   68 	insert-string '(* marks found-files)'
   69 	2 newline
   70 	;
   71 	insert-string '$PATH'
   72 	setv %index=0
   73 	~while true
   74 		setv %path=&token %index $pathlist-separator &env 'PATH'
   75 		~if &seq %path ''
   76 			~break
   77 		~endif
   78 		WhichFilename &pcat %path %filtername
   79 		setv %index=&add %index 1
   80 	~endwhile
   81 	;
   82 	newline
   83 	insert-string '$cwd'
   84 	WhichFilename %filtername
   85 	;
   86 	newline
   87 	insert-string '$libdir-path'
   88 	setv %index=0
   89 	~while true
   90 		setv %path=&token %index $pathlist-separator $libdir-path
   91 		~if &seq %path ''
   92 			~break
   93 		~endif
   94 		WhichFilename &pcat %path %filtername
   95 		setv %index=&add %index 1
   96 	~endwhile
   97 	;
   98 	unmark-buffer
   99 	setl readonly view
  100 	goto-beginning-of-file
  101 
  102 	~if &filter %short
  103 		write-message &cat 'Filter for ' &cat %long ' is built-in'
  104 	~else
  105 		write-message &cat 'Filter name: ' %filtername
  106 	~endif
  107 ~endm
  108 
  109 store-procedure which-keywords major="MajorMode" "Prompt for, and display location of keyword files"
  110 	~if &seq '' $1
  111 		~return
  112 	~endif
  113 	~local %path %leaf %suffix %pathdot %dothides %index %mybuffer %found %long %short
  114 	setv %found="no"
  115 	~local $report $terse
  116 	setv $report=0
  117 	set terse
  118 
  119 	setv %long=$1
  120 	setv %short=&left $1 &sub &len $1 4
  121 	;
  122 	setv %mybuffer='[Which Keywords]'
  123 	~force select-buffer %mybuffer
  124 	~if $status
  125 		setl noreadonly noview
  126 		~if &greater $bchars 0
  127 			goto-beginning-of-file
  128 			delete-lines-til end-of-file
  129 		~endif
  130 	~else
  131 		edit-buffer %mybuffer
  132 	~endif
  133 	setl noai
  134 	;
  135 	insert-string 'Show which keyword-files are tested for:'
  136 	newline
  137 	insert-string &cat &chr 9 %long
  138 	newline
  139 	insert-string '(* marks found-files)'
  140 	2 newline
  141 	;
  142 	setv %suffix='.keywords'
  143 	~if &seq $os "win32"
  144 		setv %dothides=''
  145 		setv %pathdot='.'
  146 	~elseif &seq $os "vms"
  147 		setv %dothides=''
  148 		setv %pathdot='[]'
  149 	~else
  150 		setv %dothides='.'
  151 		setv %pathdot='.'
  152 	~endif
  153 	;
  154 	setv %leaf=&cat %short %suffix
  155 	insert-string '$cwd'
  156 	WhichFilename &pcat %pathdot &cat %dothides %leaf
  157 	;
  158 	newline
  159 	insert-string '$HOME'
  160 	WhichFilename &pcat '~' &cat %dothides %leaf
  161 	WhichFilename &pcat '~' &cat %dothides &pcat 'vile' %leaf
  162 	;
  163 	newline
  164 	insert-string '$startup-path'
  165 	setv %index=0
  166 	~while true
  167 		setv %path=&token %index $pathlist-separator $startup-path
  168 		~if &seq %path ''
  169 			~break
  170 		~endif
  171 		WhichFilename &pcat %path %leaf
  172 		setv %index=&add %index 1
  173 	~endwhile
  174 	;
  175 	unmark-buffer
  176 	setl readonly view
  177 	goto-beginning-of-file
  178 ~endm
  179 
  180 ~if &seq $progname "xvile"
  181 store-procedure which-menu "Display location of menu file"
  182 	~local %path %leaf %suffix %pathdot %dothides %index %mybuffer %found %dotname
  183 	setv %found="no"
  184 	~local $report $terse
  185 	set report=0
  186 	set terse
  187 	;
  188 	setv %mybuffer='[Which Menufile]'
  189 	~force select-buffer %mybuffer
  190 	~if $status
  191 		setl noreadonly noview
  192 		~if &greater $bchars 0
  193 			goto-beginning-of-file
  194 			delete-lines-til end-of-file
  195 		~endif
  196 	~else
  197 		edit-buffer %mybuffer
  198 	~endif
  199 	setl noai
  200 	;
  201 	insert-string 'Show which menu-files are tested for:'
  202 	newline
  203 	insert-string &cat &chr 9 $menu-file
  204 	newline
  205 	insert-string '(* marks found-files)'
  206 	2 newline
  207 	;
  208 	~if &seq $os "win32"
  209 		setv %dothides=''
  210 		setv %pathdot='.'
  211 	~elseif &seq $os "vms"
  212 		setv %dothides=''
  213 		setv %pathdot='[]'
  214 	~else
  215 		setv %dothides='.'
  216 		setv %pathdot='.'
  217 	~endif
  218 	;
  219 	; Look for $menu-file in the current and home-directories
  220 	setv %leaf=$menu-file
  221 	insert-string '$cwd'
  222 	WhichFilename &pcat %pathdot %leaf
  223 	;
  224 	newline
  225 	insert-string '$HOME'
  226 	WhichFilename &pcat '~' %leaf
  227 	;
  228 	; If dot hides a name, and $menu-file begins with a dot, we are done
  229 	; with it.  Use "vilemenu.rc" in the other places.  If it does not
  230 	; begin with a dot, continue using it.
  231 	setv %dotname &left %leaf 1
  232 	~if &and \
  233 		&seq %dothides '.' \
  234 		&seq %dotname '.'
  235 		setv %leaf='vilemenu.rc'
  236 	~endif
  237 	;
  238 	newline
  239 	insert-string '$startup-path'
  240 	setv %index=0
  241 	~while true
  242 		setv %path=&token %index $pathlist-separator $startup-path
  243 		~if &seq %path ''
  244 			~break
  245 		~endif
  246 		WhichFilename &pcat %path %leaf
  247 		setv %index=&add %index 1
  248 	~endwhile
  249 	;
  250 	unmark-buffer
  251 	setl readonly view
  252 	goto-beginning-of-file
  253 ~endm
  254 ~endif