emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Nice python listings colors, or solution to beamer + m


From: Chris Malone
Subject: Re: [Orgmode] Re: Nice python listings colors, or solution to beamer + minted brokenness?
Date: Tue, 22 Feb 2011 22:21:24 -0500

Hi Chris

Just for completeness - and because I had little previous experience with using =org-babel= stuff - I attempted to write a small =sh= source block that parses the current =org-mode= file and builds an appropriate "emph" entry in the listings =lstset=:

==========================================================================================
#+startup: beamer                                                                                
#+LaTeX_CLASS: beamer                                                                            
#+BEAMER_HEADER_EXTRA: \usetheme{Madrid}\usecolortheme{default}                                  

#+source: parse-classes                                                                                                 
#+begin_src sh :var fileName=(buffer-file-name) :exports none :results output latex              
  for class in `sed -n 's/.*class \([a-zA-Z0-9_]*\)(.*):/\1/p' $fileName`; do                    
      str="$str,$class"                                                                          
  done                                                                                           
  cat <<EOF                                                                                      
  \\definecolor{keywords}{RGB}{255,0,90}                                                         
  \\definecolor{comments}{RGB}{60,179,113}                                                       
  \\lstset{                                                                                      
  language=Python,                                                                               
  keywordstyle=\\color{keywords},                                                                
  commentstyle=\\color{comments},                                                                
  procnamestyle=\\color{blue}\bfseries,                                                          
  emph={${str:1}},                                                                               
  emphstyle=\\color{blue}\bfseries                                                               
  }                                                                                              
  EOF                                                                                            
#+end_src                                                                                        
                                                                                                 
* test                                                                                           
** Panels in the UI (part 1)                                                                     
                                                                                                 
Scripting the UI is pretty much the same as scripting the operator,                              
but it goes to a separate location..                                                             
                                                                                                 
*** Panel operator                                                  :B_block:                    
   :PROPERTIES:                                                                                  
   :BEAMER_env: block                                                                            
   :END:                                                                                         
                                                                                                 
#+BEGIN_SRC python :exports code                                                                 
class ReferenceDeskPanel(bpy.types.Panel):                                                       
   pass                                                                                          
#+END_SRC                                                                                        
                                                                                                 
#+BEGIN_SRC python :exports code                                                                 
class ReferenceDeskPanel23(bpy.types.Panel):                                                     
   pass                                                                                          
#+END_SRC
==========================================================================================

There are two somewhat inconvenient issues with this approach:

- One has to evaluate the =parse-classes= source block before export, via a =C-c C-c=.  This allows the results to be added directly to buffer as LaTeX source code.  This was the only way I could figure out how to get it to work - maybe someone else has a clever work around? 

Part of the problem is that by the point that the code would be evaluated, you are already within the body of the LaTeX document.  It would be nice if there were a =#+begin_latex_document= command which would allow for anything before this command to be in the document's preamble, and anything afterwords to follow the LaTeX command =\begin{document}=.  Maybe this is a feature request?

- One cannot use listings ability to use /class numbers/ to mark particular emphasis because they get interpreted by =org-mode= as footnotes.  For example, say you wanted all the /class/ emphasis words to be blue, but you wanted all /def/ emphasis words to be red.  In LaTeX one could write

#+begin_latex
  \lstset{
    emph={def}, emphstyle=\color{red},
    emph={[2]class}, emphstyle=\color{blue}
#+end_latex

This can't be done with the above =parse-classes= code.

Anyway, it's a bit long-winded and probably moot seeing as how you decided to use =minted=, but I thought I'd give it a shot.

Chris
On Mon, Feb 14, 2011 at 11:12 AM, Christopher Allan Webber <address@hidden> wrote:
Dan, all this information is super helpful.  Thanks!  My presentation is
going to look great now, I think!

I really appreciate your help!
 - cwebb

--
𝓒𝓱𝓻𝓲𝓼𝓽𝓸𝓹𝓱𝓮𝓻 𝓐𝓵𝓵𝓪𝓷 𝓦𝓮𝓫𝓫𝓮𝓻

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]