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 Schulte
Subject: Re: [Orgmode] Pretty org-entities in org-mode buffers
Date: Fri, 07 May 2010 09:27:44 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Carsten Dominik <address@hidden> writes:

> Dear Eric,
>
> this is fantastic.

Great, Thanks

> This is kind of like X-symbol, only that I can just write my trusted
> LaTeX macros and get all those characters.  Makes me think that I need
> to add a few more symbols that I commonly use in math expressions.
>

Yea, I have the following org-entites customization in my setup which
covers some of the symbol names I commonly expect.  It's been growing
the more I use org-entities.

--8<---------------cut here---------------start------------->8---
(add-to-list 'org-entities
             '("supseteq" "\\supseteq" t "&supe;" "[superset of or equal to]"
               "[superset of or equal to]" "⊇"))
(add-to-list 'org-entities
             '("subseteq" "\\subseteq" t "&sube;" "[subset of or equal to]"
               "[subset of or equal to]" "⊆"))
(add-to-list 'org-entities
             '("subseteq" "\\subseteq" t "&sube;" "[subset of or equal to]"
               "[subset of or equal to]" "⊆"))
(add-to-list 'org-entities
             '("leq" "\\leq" t "&le;" "<=" "<=" "≤"))
(add-to-list 'org-entities
             '("geq" "\\geq" t "&ge;" ">=" ">=" "≥"))
--8<---------------cut here---------------end--------------->8---

>
> I am wondering if we could be a bit more generous with the regular
> expression.  For example, I would love for $\alpha=\beta$ to show the
> symbols as well.

agreed, maybe this would be better (using [:alnum:])?  The only reason
for the restriction is to keep symbols from appearing mid way through
typing out some other symbol or word.

--8<---------------cut here---------------start------------->8---
(defun org-pretty-entities ()
  (font-lock-add-keywords
   nil (mapcar
        (lambda (el)
          (list
           (concat "(?\\(" (regexp-quote "\\") (nth 0 el) "[^[:alnum:]]" "\\)")
           `(0 (progn (compose-region (match-beginning 1) (- (match-end 1) 1)
                                      ,(nth 6 el)) nil))))
        org-entities)))
--8<---------------cut here---------------end--------------->8---

> 
> Also there should be a switch for turning this on and off.
>
> I would like to integrate this code into org-entities.el.
>

Those both sound great.  It would take a little bit of effort to look
into how to remove font-lock keywords.  If you have the time and
inclination please go ahead with this, otherwise I should be able to
take a shot at it myself in the next week or two -- I'm in the middle of
my final exams right now.

>
> Thanks for all your contributions, which continue to make Org-mode so
> much richer.
>

It's my Pleasure -- Eric

>
> - Carsten
>
>
> On May 5, 2010, at 6:19 PM, Eric Schulte 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.
>>
>> Best -- Eric
>>
>> Footnotes:
>> [1]  
>> http://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-defuns.el#L135
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
> - Carsten




reply via email to

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