<TeXmacs|1.0.7.14> <style|source> <\body> <assign|hlstd|<macro|codetext|<verbatim|<with|color|#000000|<arg|codetext>>>>> <assign|hlnum|<macro|codetext|<verbatim|<with|color|#000040|<arg|codetext>>>>> <assign|hlesc|<macro|codetext|<verbatim|<with|color|#BC8C8C|<arg|codetext>>>>> <assign|hlstr|<macro|codetext|<verbatim|<with|color|#BC8C8C|<arg|codetext>>>>> <assign|hlpps|<macro|codetext|<verbatim|<with|color|#BC8C8C|<arg|codetext>>>>> <assign|hlslc|<macro|codetext|<verbatim|<with|color|#AA2121|<arg|codetext>>>>> <assign|hlcom|<macro|codetext|<verbatim|<with|color|#AA2121|<arg|codetext>>>>> <assign|hlppc|<macro|codetext|<verbatim|<with|color|#000000|<arg|codetext>>>>> <assign|hlopt|<macro|codetext|<verbatim|<with|color|#404060|<arg|codetext>>>>> <assign|hllin|<macro|codetext|<verbatim|<with|color|#545454|<arg|codetext>>>>> <assign|hlkwa|<macro|codetext|<verbatim|<with|color|#9B21ED|<arg|codetext>>>>> <assign|hlkwb|<macro|codetext|<verbatim|<with|color|#218921|<arg|codetext>>>>> <assign|hlkwc|<macro|codetext|<verbatim|<with|color|#0000FF|<arg|codetext>>>>> <assign|hlkwd|<macro|codetext|<verbatim|<with|color|#000000|<arg|codetext>>>>> <assign|textunderscore|<macro|_>> <assign|textasciicircum|<macro|^>> <assign|hlline|<\macro|codeline> <arg|codeline><line-break> </macro>> <assign|hlendline|<macro|comment|<htab|5mm><small|<arg|comment>>>> </body> <\initial> <\collection> <associate|language|american> </collection> </initial>
(defun prepare-latex-highlight-code () "Preprocess a latex buffer produced by `highlihgt'." (interactive) (save-excursion (goto-char 0) (while (search-forward "\\textasciicircum " nil t) (replace-match "{\\textasciicircum}" t t)) (goto-char 0) (while (search-forward "\\textunderscore " nil t) (replace-match "{\\textunderscore}" t t)) (goto-char 0) (while (search-forward-regexp "^\\(.*\\)\\\\hspace\\*{\\\\fill}\\\\\\\\$" nil t) ;(replace-match "\\\\hlline{\\1}" t) (replace-match "\\1\\\\hlendline{}\\\\\\\\" t)) )) (defun latex-highlight-code-region (reg-start reg-end) "Copy a `highlight'ed in latex code sample, for insertion in TeXmacs using the `highlight' style package." (interactive "r") (save-excursion (let* ((file-ext (downcase (file-name-extension (buffer-name)))) (highlight-kind (assoc-default file-ext '(("lpr" . "pas") ("pp" . "pas") ("fp" . "pas") ("ml" . "ocaml") ("mli" . "ocaml") ("fs" . "fsharp") ("fsx" . "fsharp") ("hs" . "haskell") ("flx" . "felix") ) nil file-ext)) (hl-command (concat "highlight -Olatex -S" highlight-kind))) (shell-command-on-region reg-start reg-end hl-command)) (switch-to-buffer "*Shell Command Output*") (prepare-latex-highlight-code) (search-forward "\\ttfamily" nil t) (let ((hlres-beg (point))) (search-forward "\\mbox{}" nil t) (end-of-line 0) (let ((hlres-end (point))) (clipboard-kill-region hlres-beg hlres-end))) (kill-buffer "*Shell Command Output*") ))
Archive powered by MHonArc 2.6.19.