emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Pretty org-entities in org-mode buffers


From: Eric S Fraga
Subject: Re: [Orgmode] Pretty org-entities in org-mode buffers
Date: Fri, 07 May 2010 16:01:37 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

On Wed, 05 May 2010 10:19:44 -0600, "Eric Schulte" <address@hidden> wrote:
> 
> Hi,
> 
> Recently I've been making use of org-entites for exporting my greek/math
> heavy class notes to HTML.  I'm really loving the results.
> 
> This morning I've started playing around with the below function
> `org-pretty-entities', which is adapted from Phil Hagelberg's
> `pretty-lambdas'[1].  Calling this function in an org-mode buffer will
> have the effect of fontifying all org-entities text strings as the
> character which they represent, so \Delta is replaced with Δ, \lambda
> with λ, \in with ∈, and so forth.
> 
> I've just started playing with this, and I make no guarantees as to it's
> safety or utility, but I was very pleasantly surprised by the simplicity
> of the function, and how nice it's been to see my special characters
> appear in org-mode buffers as I type.
> 
> #+begin_src emacs-lisp :results silent
>   (defun org-pretty-entities ()
>     (interactive)
>     (font-lock-add-keywords
>      nil (mapcar
>           (lambda (el)
>             (list
>              (concat "(?\\(" (regexp-quote "\\") (nth 0 el) "[\s]" "\\)")
>              `(0 (progn (compose-region (match-beginning 1) (- (match-end 1) 
> 1)
>                                         ,(nth 6 el)) nil))))
>           org-entities)))
>   
>   (org-pretty-entities)
> #+end_src
> 
> To try this out, just evaluate the above code block inside of an
> org-mode buffer, then starting typing out org-entities.
> 
> Hope others find this useful.

Eric,

I am indeed finding this useful (as my notes are often math heavy as
well).  One question: I don't fully understand the regexp above,
especially as I would have expected a specific character after the \s,
so is it possible to make the mapping take effect if I type, say
"\alpha."?  Note the punctuation instead of a space, say.

Other than that, it works really nicely and fits in very well with the
org philosophy (e.g. links) in that the underlying representation is
still simple text.  I've added this to my org-mode-hook and so far
everything is fine.

Thanks,
eric
-- 
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29  570D C891 93D8 FFFC F67D

reply via email to

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