home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / LaTeXinfo.shar.3 / scheme-fmt.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  9.3 KB  |  330 lines

  1. (require 'latexinfo)
  2.  
  3. (defun scheme-fmt-hook ()
  4.   (message "Running Scheme formatting hooks...") (sit-for 1)
  5.   (let ((case-fold-search nil)
  6.     (alist scheme-alist))
  7.     (strip-percents)
  8.     (setq alist scheme-delete-list)
  9.     (while alist
  10.       (goto-char (point-min))
  11.       (delete-matching-lines (car alist))
  12.       (setq alist (cdr alist)))
  13.  
  14.     (setq alist scheme-alist)
  15.     (while alist
  16.       (goto-char (point-min))
  17.       (replace-regexp (car (car alist)) (cdr (car alist)) nil)
  18.       (setq alist (cdr alist))))
  19.   (message "Running Scheme formatting hooks... done.") (sit-for 1)
  20.   )
  21.  
  22. (setq scheme-alist
  23.       '(
  24.     ("{ }" . "{}")
  25.     ("{\\\\it " . "\\\\i{")
  26.     ("{\\\\tt " . "\\\\code{")
  27.     ("{\\\\tt(" . "\\\\code{(")
  28.     ("\\\\item \\[" . "\\\\item[")
  29.     ("\\\\vest " . "")
  30.     ("{\\\\cf " . "\\\\code{")
  31.     ("{\\\\em " . "\\\\b{")
  32.     ("{\\\\em{}" . "\\\\b{")
  33.     ("\\\\verb|#|" . "#")
  34.     ("\\\\#{}" . "#")
  35.     ("\\\\#" . "#")
  36.  
  37.     ("\\\\nopagebreak{}" . "")
  38.     ("\\\\nopagebreak" . "")
  39.     ("\\\\unsection{}" . "")
  40.     ("\\\\unsection" . "")
  41.     ("\\\\unpenalty{}" . "")
  42.     ("\\\\unpenalty" . "")
  43.     ("\\\\nobreak{}" . "")
  44.     ("\\\\nobreak" . "")
  45.     ("\\\\rm." . ".")
  46.     
  47.     ("\\\\lambdaexp{}" . "lambda expression")
  48.     ("\\\\lambdaexp" . "lambda expression")
  49.     ("\\\\Lambdaexp{}" . "Lambda expression")
  50.     ("\\\\Lambdaexp" . "Lambda expression")
  51.     ("\\\\exprtype" . "syntax")
  52.     
  53.     ("^\\\\proto{\\(.*\\)}{\\(.*\\)}{\\([^}]*\\)}" .
  54.      "\\\\head{\\1}{}{\\3}
  55. {(\\\\fb{\\1}\\2)}")
  56.  
  57.     ("^\\\\vproto{\\(.*\\)}{\\([^}]*\\)}" .
  58.      "\\\\head{\\1}{}{\\2}
  59. {\\\\vb{\\1}}")
  60.  
  61.     ("^\\\\pproto{\\(.*\\)}{\\([^}]*\\)}" .
  62.      "\\\\head{}{}{\\2}
  63. {\\1}")
  64.  
  65.     ("^\\\\rproto{\\(.*\\)}{\\(.*\\)}{\\(.*\\)}$" .
  66.      "\\\\head{\\1}{}{\\3}
  67. {(\\\\code{\\1}\\2)}")
  68.     
  69.     ("\\\\dotsfoo{}" . "\\\\dots{}")
  70.     ("\\\\dotsfoo" . "\\\\dots")
  71.  
  72.     ("\\\\schfalse{}" . "\\\\code{#f}")
  73.     ("\\\\schfalse" . "\\\\code{#f}")
  74.     ("\\\\schtrue{}" . "\\\\code{#t}")
  75.     ("\\\\schtrue" . "\\\\code{#t}")
  76.     ("\\\\backquote{}" . "`")
  77.     ("\\\\backquote" . "`")
  78.     ("\\\\backwhack{}" . "\\\\back")
  79.     ("\\\\backwhack" . "\\\\back")
  80.     ("\\\\atsign" . "@")
  81.     ("\\\\sharpsign" . "#")
  82.     ("\\\\verticalbar" . "|")
  83.     ("~\\\\cite{" . " \\\\cite{")
  84.     ))
  85.  
  86. (setq scheme-delete-list
  87.       '())
  88.  
  89. (defun strip-percents ()
  90.   (while (search-forward "%" nil t)
  91.     (forward-char -1)
  92.     (if (bobp)
  93.     (kill-line nil)
  94.     (if (save-excursion
  95.           (forward-char -1)
  96.           (looking-at "\\\\"))
  97.         (forward-char 1)
  98.       (kill-line nil)))))
  99.  
  100. (put 'meta 'texinfo-format 'latexinfo-hyper)
  101. (put 'hyper 'texinfo-format 'latexinfo-hyper)
  102. (defun latexinfo-hyper ()
  103.   (insert "\\var{<" (texinfo-parse-arg-discard) ">}")
  104.   (goto-char texinfo-command-start))
  105.  
  106. (put 'hyperi 'texinfo-format 'latexinfo-hyperi)
  107. (defun latexinfo-hyperi ()
  108.   (insert "\\var{<" (texinfo-parse-arg-discard) "-1>}")
  109.   (goto-char texinfo-command-start))
  110.  
  111. (put 'hyperii 'texinfo-format 'latexinfo-hyperii)
  112. (defun latexinfo-hyperii ()
  113.   (insert "\\var{<" (texinfo-parse-arg-discard) "-2>}")
  114.   (goto-char texinfo-command-start))
  115.  
  116. (put 'hyperj 'texinfo-format 'latexinfo-hyperj)
  117. (defun latexinfo-hyperj ()
  118.   (insert "\\var{<" (texinfo-parse-arg-discard) "-i>}")
  119.   (goto-char texinfo-command-start))
  120.  
  121. (put 'hypern 'texinfo-format 'latexinfo-hypern)
  122. (defun latexinfo-hypern ()
  123.   (insert "\\var{<" (texinfo-parse-arg-discard) "-n>}")
  124.   (goto-char texinfo-command-start))
  125.  
  126. (put 'vari 'texinfo-format 'latexinfo-vari)
  127. (defun latexinfo-vari ()
  128.   (insert "\\var{" (texinfo-parse-arg-discard) "-1}")
  129.   (goto-char texinfo-command-start))
  130.  
  131. (put 'varii 'texinfo-format 'latexinfo-varii)
  132. (defun latexinfo-varii ()
  133.   (insert "\\var{" (texinfo-parse-arg-discard) "-2}")
  134.   (goto-char texinfo-command-start))
  135.  
  136. (put 'variii 'texinfo-format 'latexinfo-variii)
  137. (defun latexinfo-variii ()
  138.   (insert "\\var{" (texinfo-parse-arg-discard) "-3}")
  139.   (goto-char texinfo-command-start))
  140.  
  141. (put 'variv 'texinfo-format 'latexinfo-variv)
  142. (defun latexinfo-variv ()
  143.   (insert "\\var{" (texinfo-parse-arg-discard) "-4}")
  144.   (goto-char texinfo-command-start))
  145.  
  146. (put 'varj 'texinfo-format 'latexinfo-varj)
  147. (defun latexinfo-varj ()
  148.   (insert "\\var{" (texinfo-parse-arg-discard) "-i}")
  149.   (goto-char texinfo-command-start))
  150.  
  151. (put 'varn 'texinfo-format 'latexinfo-var-n)
  152. (defun latexinfo-var-n ()
  153.   (insert "\\var{" (texinfo-parse-arg-discard) "-n}")
  154.   (goto-char texinfo-command-start))
  155.  
  156. (put 'vr 'texinfo-format 'latexinfo-vr)
  157. (defun latexinfo-vr ()
  158.   (insert "\\var{" (texinfo-parse-arg-discard) "}")
  159.   (goto-char texinfo-command-start))
  160.  
  161. (put 'vri 'texinfo-format 'latexinfo-vri)
  162. (defun latexinfo-vri ()
  163.   (insert "\\var{" (texinfo-parse-arg-discard) "-1}")
  164.   (goto-char texinfo-command-start))
  165.  
  166. (put 'vrii 'texinfo-format 'latexinfo-vrii)
  167. (defun latexinfo-vrii ()
  168.   (insert "\\var{" (texinfo-parse-arg-discard) "-2}")
  169.   (goto-char texinfo-command-start))
  170.  
  171. (put 'vriii 'texinfo-format 'latexinfo-vriii)
  172. (defun latexinfo-vriii ()
  173.   (insert "\\var{" (texinfo-parse-arg-discard) "-3}")
  174.   (goto-char texinfo-command-start))
  175.  
  176. (put 'vriv 'texinfo-format 'latexinfo-vriv)
  177. (defun latexinfo-vriv ()
  178.   (insert "\\var{" (texinfo-parse-arg-discard) "-4}")
  179.   (goto-char texinfo-command-start))
  180.  
  181. (put 'vrj 'texinfo-format 'latexinfo-vrj)
  182. (defun latexinfo-vrj ()
  183.   (insert "\\var{" (texinfo-parse-arg-discard) "-i}")
  184.   (goto-char texinfo-command-start))
  185.  
  186. (put 'vrn 'texinfo-format 'latexinfo-vr-n)
  187. (defun latexinfo-vr-n ()
  188.   (insert "\\var{" (texinfo-parse-arg-discard) "-n}")
  189.   (goto-char texinfo-command-start))
  190.  
  191. (put 'defining 'texinfo-format 'latexinfo-defining)
  192. (defun latexinfo-defining ()
  193.   (insert "\\emph{" (texinfo-parse-arg-discard) "}")
  194.   (goto-char texinfo-command-start))
  195.  
  196. (put 'ide 'texinfo-format 'texinfo-format-noop)
  197.  
  198. (put 'mainschindex 'texinfo-format 'texinfo-parse-arg-discard)
  199. (put 'mainindex 'texinfo-format 'texinfo-parse-arg-discard)
  200. (put 'schindex 'texinfo-format 'texinfo-parse-arg-discard)
  201. (put 'sharpindex 'texinfo-format 'texinfo-parse-arg-discard)
  202. (put 'index 'texinfo-format 'texinfo-parse-arg-discard)
  203.  
  204. (put 'domain 'texinfo-format 'texinfo-format-noop)
  205. (put 'nodomain 'texinfo-format 'texinfo-parse-arg-discard)
  206. (put 'todo 'texinfo-format 'texinfo-parse-arg-discard)
  207.  
  208. (put 'ev 'texinfo-format 'latexinfo-format-ev)
  209.  
  210. (defun latexinfo-format-ev ()
  211.   (texinfo-parse-noarg)
  212.   (insert "        => "))
  213.  
  214. (put 'lev 'texinfo-format 'latexinfo-format-lev)
  215. (defun latexinfo-format-lev ()
  216.   (texinfo-parse-noarg)
  217.   (insert "\n    => "))
  218.  
  219. (put 'unspecified 'texinfo-format 'latexinfo-format-unspecified)
  220. (defun latexinfo-format-unspecified ()
  221.   (texinfo-parse-noarg)
  222.   (insert "\\emph{unspecified}")
  223.   (goto-char texinfo-command-start))
  224.  
  225. (put 'error 'texinfo-format 'latexinfo-format-error)
  226. (defun latexinfo-format-error ()
  227.   (texinfo-parse-noarg)
  228.   (insert "\\emph{error}"))
  229.  
  230. (put 'schemenoindent 'texinfo-format 'texinfo-format-schemenoindent)
  231. (defun texinfo-format-schemenoindent ()
  232.   (texinfo-push-stack 'example nil)
  233.   (texinfo-discard-line))
  234.  
  235. (put 'schemenoindent 'texinfo-end 'texinfo-end-schemenoindent)
  236. (defun texinfo-end-schemenoindent ()
  237.   (texinfo-discard-command)
  238.   (let ((stacktop
  239.      (texinfo-pop-stack 'example)))
  240.     (texinfo-do-itemize (nth 1 stacktop))))
  241.  
  242. (put 'tabular 'texinfo-format 'texinfo-format-tabbing)
  243. (put 'tabbing 'texinfo-format 'texinfo-format-tabbing)
  244. (defun texinfo-format-tabbing ()
  245.   (texinfo-push-stack 'example nil)
  246.   (texinfo-discard-line-with-args)
  247.   )
  248.  
  249. (put 'tabular 'texinfo-end 'texinfo-end-tabbing)
  250. (put 'tabbing 'texinfo-end 'texinfo-end-tabbing)
  251. (defun texinfo-end-tabbing ()
  252.   (texinfo-discard-line)
  253.   (let ((stacktop
  254.      (texinfo-pop-stack 'example)))
  255.     (texinfo-do-tabbing (nth 1 stacktop))))
  256.  
  257. (defun texinfo-do-tabbing (from)
  258.   (let ((end (point)))
  259.     (save-excursion
  260.       (goto-char from)
  261.       (while (search-forward "&" end t)
  262.     (if (save-excursion
  263.           (bobp)
  264.           (forward-char -2)
  265.           (not (looking-at "\\\\")))
  266.         (progn
  267.           (delete-char -1)
  268.           (insert "\t")
  269.           ))))))
  270.  
  271. (put 'scheme 'texinfo-format 'texinfo-format-example)
  272. (put 'scheme 'texinfo-end 'texinfo-end-example)
  273.  
  274. (put 'rationale 'texinfo-format 'texinfo-format-rationale)
  275. (put 'rationale 'texinfo-end 'texinfo-discard-command)
  276. (defun texinfo-format-rationale ()
  277.   (texinfo-discard-line)
  278.   (insert "Rationale: "))
  279.  
  280. (put 'note 'texinfo-format 'texinfo-format-note)
  281. (put 'note 'texinfo-end 'texinfo-discard-command)
  282. (defun texinfo-format-note ()
  283.   (texinfo-discard-line)
  284.   (insert "Note: "))
  285.  
  286. (put 'header 'texinfo-format 'texinfo-format-header)
  287. (put 'header 'texinfo-end 'texinfo-discard-command)
  288. (defun texinfo-format-header ()
  289.   (save-excursion
  290.     (forward-char 1)
  291.     (forward-sexp 1)
  292.     (delete-char -1))
  293.   (goto-char texinfo-command-start)
  294.   (delete-region (point) (progn (forward-line 1) (point))))
  295.  
  296.  
  297. (put 'evalsto 'texinfo-format 'latexinfo-format-arrow)
  298. (put 'unsection 'texinfo-format 'texinfo-parse-noarg)
  299.  
  300. (defun latexinfo-format-syntax ()
  301. (put 'syntax 'texinfo-format 'latexinfo-format-syntax)  
  302.   (texinfo-parse-noarg)
  303.   (insert "\\b{Syntax:} ")
  304.   (goto-char texinfo-command-start))
  305.  
  306. (defun latexinfo-format-semantics ()
  307. (put 'semantics 'texinfo-format 'latexinfo-format-semantics)  
  308.   (texinfo-parse-noarg)
  309.   (insert "\\b{Semantics:} ")
  310.   (goto-char texinfo-command-start))
  311.  
  312.  
  313. (defun find-entry (byte)
  314.   (goto-char byte)
  315.   (if (looking-at "(")
  316.       (setq byte (1+ byte)))
  317.   (buffer-substring byte
  318.             (progn
  319.               (skip-chars-forward "^\n\b)")
  320.               (point))))
  321.  
  322. (put 'modeline 'texinfo-format 'texinfo-format-code)
  323.  
  324. (put 'f 'texinfo-format 'texinfo-format-noop)
  325. (put 'v 'texinfo-format 'texinfo-format-noop)
  326. (put 'fb 'texinfo-format 'texinfo-format-noop)
  327. (put 'vb 'texinfo-format 'texinfo-format-noop)
  328. (put 'ide 'texinfo-format 'texinfo-format-noop)
  329.  
  330.