emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: drymer <drymer@autistici.org>, emacs-orgmode@gnu.org
Subject: Re: Using org-entities to escape symbols
Date: Tue, 10 May 2016 21:46:47 +0000	[thread overview]
Message-ID: <CAFyQvY1f4a1ne9E=vSamsao1p_-dsLnSJ9CKAVz3sa-LxundsQ@mail.gmail.com> (raw)
In-Reply-To: <449ae934-b1a1-4fc3-278e-e3ed4e2ad34c@autistici.org>


[-- 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)

  reply	other threads:[~2016-05-10 21:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFyQvY1f4a1ne9E=vSamsao1p_-dsLnSJ9CKAVz3sa-LxundsQ@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=drymer@autistici.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).