From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Pretty org-entities in org-mode buffers Date: Sat, 8 May 2010 07:15:41 +0200 Message-ID: <720C576A-F0BF-44CE-9554-E0C94C1114BE@gmail.com> References: <87zl0e2ue7.fsf@gmail.com> <871vdng2a7.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OAcOD-0003W5-15 for emacs-orgmode@gnu.org; Sat, 08 May 2010 01:15:49 -0400 Received: from [140.186.70.92] (port=48450 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAcOB-0003VP-Hi for emacs-orgmode@gnu.org; Sat, 08 May 2010 01:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAcO9-0007Sk-CL for emacs-orgmode@gnu.org; Sat, 08 May 2010 01:15:47 -0400 Received: from ey-out-1920.google.com ([74.125.78.144]:26887) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAcO9-0007Sg-32 for emacs-orgmode@gnu.org; Sat, 08 May 2010 01:15:45 -0400 Received: by ey-out-1920.google.com with SMTP id 13so180219eye.34 for ; Fri, 07 May 2010 22:15:44 -0700 (PDT) In-Reply-To: <871vdng2a7.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Org Mode On May 7, 2010, at 5:27 PM, Eric Schulte wrote: > Carsten Dominik 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 =20 >> 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 There is now a special user variable that can be used to add your own entities, if you want to avoid messing with this constant. But I guess this is a matter of taste. I will also accept patches that will add to org-entities, in a limited =20= way. - Carsten > '("supseteq" "\\supseteq" t "⊇" "[superset of or =20 > equal to]" > "[superset of or equal to]" "=E2=8A=87")) > (add-to-list 'org-entities > '("subseteq" "\\subseteq" t "⊆" "[subset of or =20 > equal to]" > "[subset of or equal to]" "=E2=8A=86")) > (add-to-list 'org-entities > '("subseteq" "\\subseteq" t "⊆" "[subset of or =20 > equal to]" > "[subset of or equal to]" "=E2=8A=86")) > (add-to-list 'org-entities > '("leq" "\\leq" t "≤" "<=3D" "<=3D" "=E2=89=A4")) > (add-to-list 'org-entities > '("geq" "\\geq" t "≥" ">=3D" ">=3D" "=E2=89=A5")) > --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=3D\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) =20 > "[^[:alnum:]]" "\\)") > `(0 (progn (compose-region (match-beginning 1) (- (match-=20 > 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 =20 > 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 =20= >>> will >>> have the effect of fontifying all org-entities text strings as the >>> character which they represent, so \Delta is replaced with =CE=94, =20= >>> \lambda >>> with =CE=BB, \in with =E2=88=88, 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-de= funs.el#L135 >>> >>> >>> _______________________________________________ >>> Emacs-orgmode mailing list >>> Please use `Reply All' to send replies to the list. >>> Emacs-orgmode@gnu.org >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >> >> - Carsten - Carsten