From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: latex export R code syntax highlighting with minted Date: Fri, 16 Mar 2012 17:47:14 -0400 Message-ID: <7779.1331934434@alphaville> References: Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:33473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ezX-0007W7-O4 for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 17:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8ezV-0006p4-Pc for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 17:47:19 -0400 Received: from g1t0027.austin.hp.com ([15.216.28.34]:37089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ezV-0006ov-Ir for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 17:47:17 -0400 In-Reply-To: Message from Ista Zahn of "Fri, 16 Mar 2012 16:36:38 EDT." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ista Zahn Cc: nicholas.dokos@hp.com, emacs-orgmode Mailinglist Ista Zahn wrote: > Hi all, > > I'm having trouble modifying the example at > http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-12-3 > to highlight R code blocks. The trouble seems to be that org-mode > identifies R blocks using uppercase R, while pygments looks for > lowercase r. > > For example, org exports > > \begin{minted}{R} > 2+2 > \end{minted} > > but pygments doesn't know how to highlight R. If I change to > > \begin{minted}{r} > 2+2 > \end{minted} > > (note the lower case r) then it works, but of course I don't want to > have to perform a find-and-replace every time. > > Do you know how to either a) make org-mode identify R blocks with a > lowercase r, or b) make pygments recognize uppercase R, or c) some > other solution I've overlooked? > Christophe provided the org solution a) and obviously that's the way to go (maybe one of you could provide a patch to change the default value of org-export-latex-minted-langs to add the R setting?) For completeness, and of theoretical interest only, here's how to do b). o Find the directory where pygments is installed. I just started python imported pygments and asked for help: ,---- | $ python | Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) | [GCC 4.5.2] on linux2 | Type "help", "copyright", "credits" or "license" for more information. | >>> import pygments | >>> help(pygments) | Help on package pygments: | | NAME | pygments | | FILE | /usr/lib/python2.7/dist-packages/pygments/__init__.py | ... `---- o cd /path/to/pygments/lexers, edit the file math.py (you probably have to be root) and add the 'R' alias for 'S': ,---- | ... | name = 'S' | aliases = ['splus', 's', 'r', 'R'] | filenames = ['*.S', '*.R'] | mimetypes = ['text/S-plus', 'text/S', 'text/R'] | ... `---- o run (as root) the _mapping.py script to regenerate stuff: ,---- | $ sudo python _mapping.py `---- Nick