From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Using org-entities to escape symbols Date: Tue, 10 May 2016 23:00:40 +0000 Message-ID: References: <3f18c497-dae3-1cf4-8c48-d7efab07a766@autistici.org> <449ae934-b1a1-4fc3-278e-e3ed4e2ad34c@autistici.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c092f6c6e954d053284e529 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Ge5-0008GI-Dz for emacs-orgmode@gnu.org; Tue, 10 May 2016 19:00:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0Ge3-0007Zv-2I for emacs-orgmode@gnu.org; Tue, 10 May 2016 19:00:52 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:32783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Ge2-0007Zq-RM for emacs-orgmode@gnu.org; Tue, 10 May 2016 19:00:51 -0400 Received: by mail-oi0-x22c.google.com with SMTP id v145so40683790oie.0 for ; Tue, 10 May 2016 16:00:50 -0700 (PDT) In-Reply-To: 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" To: drymer , emacs-orgmode@gnu.org --94eb2c092f6c6e954d053284e529 Content-Type: text/plain; charset=UTF-8 On Tue, May 10, 2016 at 6:51 PM Kaushal Modi wrote: > I will see if I can find a workaround for it on 24.5. > Here's a final try .. Please replace the advising function with this one: (defun modi/org-insert-org-entity-maybe (orig-fun &rest args) "When the universal prefix C-u is used before entering any character, insert the character's `org-entity' name if available." (let ((pressed-key (char-to-string (elt (this-single-command-keys) 0))) entity-name) (when (and (listp args) (eq 4 (car args))) (setq entity-name (modi/org-entity-get-name pressed-key)) (when entity-name (setq entity-name (concat "\\" entity-name "{}")) (insert entity-name) (message (concat "Inserted `org-entity' " (propertize entity-name 'face 'font-lock-function-name-face) " for the symbol " (propertize pressed-key 'face 'font-lock-function-name-face) ".")))) (when (null entity-name) (apply orig-fun args)))) The only change is in this line: (let ((pressed-key (char-to-string (elt (this-single-command-keys) 0))) I have quickly verified it to work the same in both emacs 24.5 and emacs 25.x. Let me know. Thanks for testing the code. -- -- Kaushal Modi --94eb2c092f6c6e954d053284e529 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Tue, May 10= , 2016 at 6:51 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
I will see if I can find = a workaround for it on 24.5.=C2=A0

<= /div>
Here's a final try ..

Please replace= the advising function with this one:

(defun modi/= org-insert-org-entity-maybe (orig-fun &rest args)
=C2=A0 &quo= t;When the universal prefix C-u is used before entering any character,
insert the character's `org-entity' name if available."<= /div>
=C2=A0 (let ((pressed-key (char-to-string (elt (this-single-comma= nd-keys) 0)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 entity-name)
= =C2=A0 =C2=A0 (when (and (listp args) (eq 4 (car args)))
=C2=A0 = =C2=A0 =C2=A0 (setq entity-name (modi/org-entity-get-name pressed-key))
=C2=A0 =C2=A0 =C2=A0 (when entity-name
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 (setq entity-name (concat "\\" entity-name "{}&qu= ot;))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert entity-name)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message (concat "Inserted `org-entity'= ; "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(propertize entity-name
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'face 'font-loc= k-function-name-face)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0" for the symbol "= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(propertize pressed-key
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'face 'font-lock-funct= ion-name-face)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"."))))
=C2=A0= =C2=A0 (when (null entity-name)
=C2=A0 =C2=A0 =C2=A0 (apply orig= -fun args))))

The only change is in this line:

=C2=A0(let ((= pressed-key (char-to-string (elt (this-single-command-keys) 0)))

I have quickly verified it to work the same in =C2=A0= both emacs 24.5 and emacs 25.x.

Let me know. Thank= s for testing the code.
--

--
Kaushal Modi

--94eb2c092f6c6e954d053284e529--