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

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