emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using org-entities to escape symbols
@ 2016-05-10 19:26 drymer
  2016-05-10 19:38 ` Kaushal Modi
  0 siblings, 1 reply; 14+ messages in thread
From: drymer @ 2016-05-10 19:26 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1905 bytes --]

Hi,

So I saw this thread (first link at the very bottom) which response was
to use a couple of functions. So the thing is that I evaluated the
functions, and supposedly it should something like \ast when executing
C-u *, but it doesn't happen. Any idea on what I could be doing wrong?

The functions are:

(defun modi/org-entity-get-name (char)
  "Return the entity name for CHAR. For example, return \"ast\" for *."
  (let ((ll (append org-entities-user
                    org-entities))
        e name utf8)
    (catch 'break
      (while ll
        (setq e (pop ll))
        (when (not (stringp e))
          (setq utf8 (nth 6 e))
          (when (string= char utf8)
            (setq name (car e))
            (throw 'break name)))))))

(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 (this-command-keys))
        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))))

(advice-add 'org-self-insert-command :around
#'modi/org-insert-org-entity-maybe)


https://emacs.stackexchange.com/questions/16688/how-can-i-escape-the-in-org-mode-to-prevent-bold-fontification

Regards

[-- Attachment #1.1.2: 0x5DDFDAAD.asc --]
[-- Type: application/pgp-keys, Size: 6235 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 19:26 Using org-entities to escape symbols drymer
@ 2016-05-10 19:38 ` Kaushal Modi
  2016-05-10 19:53   ` Kaushal Modi
  0 siblings, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 19:38 UTC (permalink / raw)
  To: drymer, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 894 bytes --]

On Tue, May 10, 2016 at 3:28 PM drymer <drymer@autistici.org> wrote:

> Hi,
>
> So I saw this thread (first link at the very bottom) which response was
> to use a couple of functions. So the thing is that I evaluated the
> functions, and supposedly it should something like \ast when executing
> C-u *, but it doesn't happen. Any idea on what I could be doing wrong?
>


>
> https://emacs.stackexchange.com/questions/16688/how-can-i-escape-the-in-org-mode-to-prevent-bold-fontification


Thanks for trying that out.

So what "doesn't happen"? Do you get an error? Or do you see "\ast{}" being
inserted verbatim?

If it's the former, please provide your emacs or org mode versions and the
error you see.

If it's the latter, the solution is easy :). Simply add below to your
config too.

(setq org-pretty-entities t)

I will update the emacs.SE solution with the same too.
-- 

-- 
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1651 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 19:38 ` Kaushal Modi
@ 2016-05-10 19:53   ` Kaushal Modi
  2016-05-10 20:25     ` drymer
  0 siblings, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 19:53 UTC (permalink / raw)
  To: drymer, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

>
> On Tue, May 10, 2016 at 3:28 PM drymer <drymer@autistici.org> wrote:
>
>> I evaluated the
>> functions, and supposedly it should something like \ast when executing
>> C-u *, but it doesn't happen.
>>
>
I reread your initial email.. so look like you see nothing getting inserted
when in do "C-u *"? That is odd.

Can you do the following and see if things work as intended? If they do,
then there's something conflicting with your config:

1. Launch emacs -Q
2. Paste the whole code block from
http://emacs.stackexchange.com/a/16746/115 to the *scratch* buffer and
evaluate it.
3. Do C-x b something.org
4. M-x org-mode
5. Hit "C-u *"
6. You should see an asterisk being displayed, which is actually a
prettified version of "\ast{}" which is what actually got inserted.

Also, please report your emacs and org-mode versions. I am using the latest
build of emacs-25 branch from git and the latest build of org-mode master
branch git.
-- 

-- 
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1700 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 19:53   ` Kaushal Modi
@ 2016-05-10 20:25     ` drymer
  2016-05-10 20:31       ` John Kitchin
  2016-05-10 20:33       ` Kaushal Modi
  0 siblings, 2 replies; 14+ messages in thread
From: drymer @ 2016-05-10 20:25 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1236 bytes --]

Hi
I didn't explain myself. It inserts four *, as it didn't find the
entity. I'm using emacs 24.5.3 and org-mode 8.34, which is the maint
branch. I've also tried with plain emacs without configuration.

Kaushal Modi:
>>
>> On Tue, May 10, 2016 at 3:28 PM drymer <drymer@autistici.org> wrote:
>>
>>> I evaluated the
>>> functions, and supposedly it should something like \ast when executing
>>> C-u *, but it doesn't happen.
>>>
>>
> I reread your initial email.. so look like you see nothing getting inserted
> when in do "C-u *"? That is odd.
> 
> Can you do the following and see if things work as intended? If they do,
> then there's something conflicting with your config:
> 
> 1. Launch emacs -Q
> 2. Paste the whole code block from
> http://emacs.stackexchange.com/a/16746/115 to the *scratch* buffer and
> evaluate it.
> 3. Do C-x b something.org
> 4. M-x org-mode
> 5. Hit "C-u *"
> 6. You should see an asterisk being displayed, which is actually a
> prettified version of "\ast{}" which is what actually got inserted.
> 
> Also, please report your emacs and org-mode versions. I am using the latest
> build of emacs-25 branch from git and the latest build of org-mode master
> branch git.
> 

[-- Attachment #1.1.2: 0x5DDFDAAD.asc --]
[-- Type: application/pgp-keys, Size: 6235 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 20:25     ` drymer
@ 2016-05-10 20:31       ` John Kitchin
  2016-05-10 21:02         ` Thomas S. Dye
  2016-05-10 20:33       ` Kaushal Modi
  1 sibling, 1 reply; 14+ messages in thread
From: John Kitchin @ 2016-05-10 20:31 UTC (permalink / raw)
  To: drymer; +Cc: emacs-orgmode, Kaushal Modi

you might find this approach helpful:
http://kitchingroup.cheme.cmu.edu/blog/2015/11/21/Insert-org-entities-into-org-mode-with-helm/

drymer writes:

> Hi
> I didn't explain myself. It inserts four *, as it didn't find the
> entity. I'm using emacs 24.5.3 and org-mode 8.34, which is the maint
> branch. I've also tried with plain emacs without configuration.
>
> Kaushal Modi:
>>>
>>> On Tue, May 10, 2016 at 3:28 PM drymer <drymer@autistici.org> wrote:
>>>
>>>> I evaluated the
>>>> functions, and supposedly it should something like \ast when executing
>>>> C-u *, but it doesn't happen.
>>>>
>>>
>> I reread your initial email.. so look like you see nothing getting inserted
>> when in do "C-u *"? That is odd.
>>
>> Can you do the following and see if things work as intended? If they do,
>> then there's something conflicting with your config:
>>
>> 1. Launch emacs -Q
>> 2. Paste the whole code block from
>> http://emacs.stackexchange.com/a/16746/115 to the *scratch* buffer and
>> evaluate it.
>> 3. Do C-x b something.org
>> 4. M-x org-mode
>> 5. Hit "C-u *"
>> 6. You should see an asterisk being displayed, which is actually a
>> prettified version of "\ast{}" which is what actually got inserted.
>>
>> Also, please report your emacs and org-mode versions. I am using the latest
>> build of emacs-25 branch from git and the latest build of org-mode master
>> branch git.
>>


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 20:25     ` drymer
  2016-05-10 20:31       ` John Kitchin
@ 2016-05-10 20:33       ` Kaushal Modi
  2016-05-10 21:24         ` drymer
  1 sibling, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 20:33 UTC (permalink / raw)
  To: drymer; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]

On Tue, May 10, 2016 at 4:25 PM drymer <drymer@autistici.org> wrote:

> Hi
> I didn't explain myself. It inserts four *, as it didn't find the
> entity. I'm using emacs 24.5.3 and org-mode 8.34, which is the maint
> branch. I've also tried with plain emacs without configuration.
>

Those emacs and org versions are fine.

It could be one of two things:
1. You forgot to evaluate

    (advice-add 'org-self-insert-command :around
#'modi/org-insert-org-entity-maybe)

    What do you see when you do C-h f org-self-insert-command after
evaluating that whole code block?

I see

org-self-insert-command is an interactive compiled Lisp function in
`org.el'.

(org-self-insert-command N)

For more information check the manuals.

:before-until advice: ‘modi/org-insert-org-entity-maybe’

Like ‘self-insert-command’, use overwrite-mode for whitespace in tables.
If the cursor is in a table looking at whitespace, the whitespace is
overwritten, and the table is not marked as requiring realignment.

The ":before-until advice: ‘modi/org-insert-org-entity-maybe’" part in
there is important. Do you see the same?

2. If from above you see org-self-insert-command being advised correctly,
then can you let me know what you get when you do

M-: (modi/org-entity-get-name "*")

You should get "ast" in return when you evaluate that.

Also I am confused why you cannot recreate what I see in emacs -Q. Are you
explicitly using "emacs -Q"? Note that that Q is capital (not emacs -q).
-- 

-- 
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2313 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 20:31       ` John Kitchin
@ 2016-05-10 21:02         ` Thomas S. Dye
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas S. Dye @ 2016-05-10 21:02 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode, drymer, Kaushal Modi

Aloha John,

Nice!

I had to (require 's) in order to evaluate the function
(s-starts-with?).

All the best,
Tom

John Kitchin writes:

> you might find this approach helpful:
> http://kitchingroup.cheme.cmu.edu/blog/2015/11/21/Insert-org-entities-into-org-mode-with-helm/
>
> drymer writes:
>
>> Hi
>> I didn't explain myself. It inserts four *, as it didn't find the
>> entity. I'm using emacs 24.5.3 and org-mode 8.34, which is the maint
>> branch. I've also tried with plain emacs without configuration.
>>
>> Kaushal Modi:
>>>>
>>>> On Tue, May 10, 2016 at 3:28 PM drymer <drymer@autistici.org> wrote:
>>>>
>>>>> I evaluated the
>>>>> functions, and supposedly it should something like \ast when executing
>>>>> C-u *, but it doesn't happen.
>>>>>
>>>>
>>> I reread your initial email.. so look like you see nothing getting inserted
>>> when in do "C-u *"? That is odd.
>>>
>>> Can you do the following and see if things work as intended? If they do,
>>> then there's something conflicting with your config:
>>>
>>> 1. Launch emacs -Q
>>> 2. Paste the whole code block from
>>> http://emacs.stackexchange.com/a/16746/115 to the *scratch* buffer and
>>> evaluate it.
>>> 3. Do C-x b something.org
>>> 4. M-x org-mode
>>> 5. Hit "C-u *"
>>> 6. You should see an asterisk being displayed, which is actually a
>>> prettified version of "\ast{}" which is what actually got inserted.
>>>
>>> Also, please report your emacs and org-mode versions. I am using the latest
>>> build of emacs-25 branch from git and the latest build of org-mode master
>>> branch git.
>>>


-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 20:33       ` Kaushal Modi
@ 2016-05-10 21:24         ` drymer
  2016-05-10 21:46           ` Kaushal Modi
  0 siblings, 1 reply; 14+ messages in thread
From: drymer @ 2016-05-10 21:24 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1966 bytes --]

I'll try the other approach if we can't make this work, because I like
it more x)
I've evaluated all of it, even re-opened emacs.

Uh, in my description of that function it doesn't say the same, it's the
regular one. I've executed toggle-debug-on-error and re-evaluated and
nothing. It seems that is not being evaluated.

Kaushal Modi:
> On Tue, May 10, 2016 at 4:25 PM drymer <drymer@autistici.org> wrote:
> 
>> Hi
>> I didn't explain myself. It inserts four *, as it didn't find the
>> entity. I'm using emacs 24.5.3 and org-mode 8.34, which is the maint
>> branch. I've also tried with plain emacs without configuration.
>>
> 
> Those emacs and org versions are fine.
> 
> It could be one of two things:
> 1. You forgot to evaluate
> 
>     (advice-add 'org-self-insert-command :around
> #'modi/org-insert-org-entity-maybe)
> 
>     What do you see when you do C-h f org-self-insert-command after
> evaluating that whole code block?
> 
> I see
> 
> org-self-insert-command is an interactive compiled Lisp function in
> `org.el'.
> 
> (org-self-insert-command N)
> 
> For more information check the manuals.
> 
> :before-until advice: ‘modi/org-insert-org-entity-maybe’
> 
> Like ‘self-insert-command’, use overwrite-mode for whitespace in tables.
> If the cursor is in a table looking at whitespace, the whitespace is
> overwritten, and the table is not marked as requiring realignment.
> 
> The ":before-until advice: ‘modi/org-insert-org-entity-maybe’" part in
> there is important. Do you see the same?
> 
> 2. If from above you see org-self-insert-command being advised correctly,
> then can you let me know what you get when you do
> 
> M-: (modi/org-entity-get-name "*")
> 
> You should get "ast" in return when you evaluate that.
> 
> Also I am confused why you cannot recreate what I see in emacs -Q. Are you
> explicitly using "emacs -Q"? Note that that Q is capital (not emacs -q).
> 

[-- Attachment #1.1.2: 0x5DDFDAAD.asc --]
[-- Type: application/pgp-keys, Size: 6235 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 21:24         ` drymer
@ 2016-05-10 21:46           ` Kaushal Modi
  2016-05-10 22:16             ` drymer
  0 siblings, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 21:46 UTC (permalink / raw)
  To: drymer, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1128 bytes --]

On Tue, May 10, 2016 at 5:25 PM drymer <drymer@autistici.org> wrote:

> I'll try the other approach if we can't make this work, because I like
> it more x)
> I've evaluated all of it, even re-opened emacs.
>
> Uh, in my description of that function it doesn't say the same, it's the
> regular one. I've executed toggle-debug-on-error and re-evaluated and
> nothing. It seems that is not being evaluated.
>

That's very strange. One thing is good that now it makes sense why "C-u *"
is inserting "****" in your emacs -Q session.. the advice isn't getting
applied in the first place!

Now it is difficult to tell why that advice isn't getting applied in the
first place. I wonder if the code is actually getting evaluated when you
think that it is getting evaluated. Can you describe the steps you take to
evaluate that code?

Here's one more try:

1. Download the attached modi-org-entity.el file
2. Run emacs -Q -l /PATH/TO/modi-org-entity.el --eval "(org-mode)" &
3. C-u * should then work as expected.

Make sure to replace "/PATH/TO/" above with the actual path where you
downloaded modi-org-entity.el.
-- 

-- 
Kaushal Modi

[-- Attachment #1.2: Type: text/html, Size: 1658 bytes --]

[-- Attachment #2: modi-org-entity.el --]
[-- Type: application/octet-stream, Size: 1497 bytes --]

;; Display "\ast{}" as "*", and so on ..
(setq org-pretty-entities t)

(defun modi/org-entity-get-name (char)
  "Return the entity name for CHAR. For example, return \"ast\" for *."
  (let ((ll (append org-entities-user
                    org-entities))
        e name utf8)
    (catch 'break
      (while ll
        (setq e (pop ll))
        (when (not (stringp e))
          (setq utf8 (nth 6 e))
          (when (string= char utf8)
            (setq name (car e))
            (throw 'break name)))))))

(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 (this-command-keys))
        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))))

(advice-add 'org-self-insert-command :around #'modi/org-insert-org-entity-maybe)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 21:46           ` Kaushal Modi
@ 2016-05-10 22:16             ` drymer
  2016-05-10 22:51               ` Kaushal Modi
  0 siblings, 1 reply; 14+ messages in thread
From: drymer @ 2016-05-10 22:16 UTC (permalink / raw)
  To: Kaushal Modi, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1490 bytes --]

Very strange. I have that piece of code in a file with other things, and
all of them (behind and after the snippet) is getting evaluated. Also,
what you're saying still doesn't work.

And now I see. I casually have installed emacs 25 and I just remembered
it. It works fine there.

Kaushal Modi:
> On Tue, May 10, 2016 at 5:25 PM drymer <drymer@autistici.org> wrote:
> 
>> I'll try the other approach if we can't make this work, because I like
>> it more x)
>> I've evaluated all of it, even re-opened emacs.
>>
>> Uh, in my description of that function it doesn't say the same, it's the
>> regular one. I've executed toggle-debug-on-error and re-evaluated and
>> nothing. It seems that is not being evaluated.
>>
> 
> That's very strange. One thing is good that now it makes sense why "C-u *"
> is inserting "****" in your emacs -Q session.. the advice isn't getting
> applied in the first place!
> 
> Now it is difficult to tell why that advice isn't getting applied in the
> first place. I wonder if the code is actually getting evaluated when you
> think that it is getting evaluated. Can you describe the steps you take to
> evaluate that code?
> 
> Here's one more try:
> 
> 1. Download the attached modi-org-entity.el file
> 2. Run emacs -Q -l /PATH/TO/modi-org-entity.el --eval "(org-mode)" &
> 3. C-u * should then work as expected.
> 
> Make sure to replace "/PATH/TO/" above with the actual path where you
> downloaded modi-org-entity.el.
> 

[-- Attachment #1.1.2: 0x5DDFDAAD.asc --]
[-- Type: application/pgp-keys, Size: 6235 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 22:16             ` drymer
@ 2016-05-10 22:51               ` Kaushal Modi
  2016-05-10 23:00                 ` Kaushal Modi
  0 siblings, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 22:51 UTC (permalink / raw)
  To: drymer, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]

On Tue, May 10, 2016 at 6:16 PM drymer <drymer@autistici.org> wrote:

> Very strange. I have that piece of code in a file with other things, and
> all of them (behind and after the snippet) is getting evaluated. Also,
> what you're saying still doesn't work.
>
> And now I see. I casually have installed emacs 25 and I just remembered
> it. It works fine there.
>

Bummer. Sorry for wasting your time and thank you for being patient with me!

Turns out a bug in emacs 24.5 is preventing that code from working
correctly:
http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-25&id=9d2b8e768f2015a89f7609dedf7b28ea5e8123b5

It has been fixed in 25.x.

I will see if I can find a workaround for it on 24.5.
-- 

-- 
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1265 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 22:51               ` Kaushal Modi
@ 2016-05-10 23:00                 ` Kaushal Modi
  2016-05-10 23:22                   ` Kaushal Modi
  2016-05-11  5:14                   ` drymer
  0 siblings, 2 replies; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 23:00 UTC (permalink / raw)
  To: drymer, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1407 bytes --]

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.
>

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

[-- Attachment #2: Type: text/html, Size: 2432 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 23:00                 ` Kaushal Modi
@ 2016-05-10 23:22                   ` Kaushal Modi
  2016-05-11  5:14                   ` drymer
  1 sibling, 0 replies; 14+ messages in thread
From: Kaushal Modi @ 2016-05-10 23:22 UTC (permalink / raw)
  To: drymer, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 135 bytes --]

I have updated the final version here:
http://emacs.stackexchange.com/a/16746/115

(also attached for reference)
-- 

-- 
Kaushal Modi

[-- Attachment #1.2: Type: text/html, Size: 283 bytes --]

[-- Attachment #2: modi-org-entity.el --]
[-- Type: application/octet-stream, Size: 2158 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Using org-entities to escape symbols
  2016-05-10 23:00                 ` Kaushal Modi
  2016-05-10 23:22                   ` Kaushal Modi
@ 2016-05-11  5:14                   ` drymer
  1 sibling, 0 replies; 14+ messages in thread
From: drymer @ 2016-05-11  5:14 UTC (permalink / raw)
  To: Kaushal Modi, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1591 bytes --]

It's working! Thank you very much for your time, this will be very useful.

Kaushal Modi:
> 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.
>>
> 
> 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.
> 

[-- Attachment #1.1.2: 0x5DDFDAAD.asc --]
[-- Type: application/pgp-keys, Size: 6235 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-05-11  5:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 19:26 Using org-entities to escape symbols drymer
2016-05-10 19:38 ` Kaushal Modi
2016-05-10 19:53   ` Kaushal Modi
2016-05-10 20:25     ` drymer
2016-05-10 20:31       ` John Kitchin
2016-05-10 21:02         ` Thomas S. Dye
2016-05-10 20:33       ` Kaushal Modi
2016-05-10 21:24         ` drymer
2016-05-10 21:46           ` Kaushal Modi
2016-05-10 22:16             ` drymer
2016-05-10 22:51               ` Kaushal Modi
2016-05-10 23:00                 ` Kaushal Modi
2016-05-10 23:22                   ` Kaushal Modi
2016-05-11  5:14                   ` drymer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).