Skip to Content.
Sympa Menu

texmacs-users - [TeXmacs] Re: Highlighting source code using "highlight".

Subject: mailing-list for TeXmacs Users

List archive

[TeXmacs] Re: Highlighting source code using "highlight".


Chronological Thread 
  • From: Lukasz Stafiniak <address@hidden>
  • To: address@hidden
  • Subject: [TeXmacs] Re: Highlighting source code using "highlight".
  • Date: Mon, 27 Feb 2012 14:40:28 +0100
  • Authentication-results: mr.google.com; spf=pass (google.com: domain of address@hidden designates 10.180.101.37 as permitted sender) smtp.mail=address@hidden; dkim=pass header.i=address@hidden

On Sun, Feb 26, 2012 at 9:19 PM, Lukasz Stafiniak <address@hidden> wrote:
> Hi,
>
> I use the attached code to "highlight" (using the command of this
> name) a code sample in Emacs and copy it to TeXmacs. Most of the work
> is done in Emacs since I studied Emacs more (long, long ago) and it is
> better at self documenting.

I'm sorry, a tiny bug crept into "prepare-highlight.el", using
`assoc-default'. The main function should be:


(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
(or (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) 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.

Top of Page