From ec84430cf4e09ba25ec675debdf802bc28111e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Delafond?= Date: Mon, 7 Nov 2016 10:41:54 +0100 Subject: Imported Upstream version 9.0 --- lisp/org-entities.el | 112 ++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 63 deletions(-) (limited to 'lisp/org-entities.el') diff --git a/lisp/org-entities.el b/lisp/org-entities.el index 89c5962..79b28e2 100644 --- a/lisp/org-entities.el +++ b/lisp/org-entities.el @@ -1,4 +1,4 @@ -;;; org-entities.el --- Support for special entities in Org-mode +;;; org-entities.el --- Support for Special Entities -*- lexical-binding: t; -*- ;; Copyright (C) 2010-2016 Free Software Foundation, Inc. @@ -30,29 +30,24 @@ (declare-function org-toggle-pretty-entities "org" ()) (declare-function org-table-align "org-table" ()) -(eval-when-compile - (require 'cl)) - (defgroup org-entities nil - "Options concerning entities in Org-mode." + "Options concerning entities in Org mode." :tag "Org Entities" :group 'org) (defun org-entities--user-safe-p (v) "Non-nil if V is a safe value for `org-entities-user'." - (or (null v) - (and (listp v) - (= (length v) 7) - (stringp (nth 0 v)) - (stringp (nth 1 v)) - (booleanp (nth 2 v)) - (stringp (nth 3 v)) - (stringp (nth 4 v)) - (stringp (nth 5 v)) - (stringp (nth 6 v))))) + (pcase v + (`nil t) + (`(,(and (pred stringp) + (pred (string-match-p "\\`[a-zA-Z][a-zA-Z0-9]*\\'"))) + ,(pred stringp) ,(pred booleanp) ,(pred stringp) + ,(pred stringp) ,(pred stringp) ,(pred stringp)) + t) + (_ nil))) (defcustom org-entities-user nil - "User-defined entities used in Org-mode to produce special characters. + "User-defined entities used in Org to produce special characters. Each entry in this list is a list of strings. It associates the name of the entity that can be inserted into an Org file as \\name with the appropriate replacements for the different export backends. The order @@ -93,6 +88,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("aacute" "\\'{a}" nil "á" "a" "á" "á") ("Acirc" "\\^{A}" nil "Â" "A" "Â" "Â") ("acirc" "\\^{a}" nil "â" "a" "â" "â") + ("Amacr" "\\bar{A}" nil "Ā" "A" "Ã" "Ã") + ("amacr" "\\bar{a}" nil "ā" "a" "ã" "ã") ("Atilde" "\\~{A}" nil "Ã" "A" "Ã" "Ã") ("atilde" "\\~{a}" nil "ã" "a" "ã" "ã") ("Auml" "\\\"{A}" nil "Ä" "Ae" "Ä" "Ä") @@ -168,7 +165,7 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("beta" "\\beta" t "β" "beta" "beta" "β") ("Gamma" "\\Gamma" t "Γ" "Gamma" "Gamma" "Γ") ("gamma" "\\gamma" t "γ" "gamma" "gamma" "γ") - ("Delta" "\\Delta" t "Δ" "Delta" "Gamma" "Δ") + ("Delta" "\\Delta" t "Δ" "Delta" "Delta" "Δ") ("delta" "\\delta" t "δ" "delta" "delta" "δ") ("Epsilon" "E" nil "Ε" "Epsilon" "Epsilon" "Ε") ("epsilon" "\\epsilon" t "ε" "epsilon" "epsilon" "ε") @@ -208,8 +205,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("upsih" "\\Upsilon" t "ϒ" "upsilon" "upsilon" "ϒ") ("upsilon" "\\upsilon" t "υ" "upsilon" "upsilon" "υ") ("Phi" "\\Phi" t "Φ" "Phi" "Phi" "Φ") - ("phi" "\\phi" t "φ" "phi" "phi" "φ") - ("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "ɸ") + ("phi" "\\phi" t "φ" "phi" "phi" "ɸ") + ("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "φ") ("Chi" "X" nil "Χ" "Chi" "Chi" "Χ") ("chi" "\\chi" t "χ" "chi" "chi" "χ") ("acutex" "\\acute x" t "´x" "'x" "'x" "𝑥́") @@ -265,8 +262,9 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." "* Other" "** Misc. (often used)" - ("circ" "\\^{}" nil "ˆ" "^" "^" "ˆ") + ("circ" "\\^{}" nil "ˆ" "^" "^" "∘") ("vert" "\\vert{}" t "|" "|" "|" "|") + ("vbar" "|" nil "|" "|" "|" "|") ("brvbar" "\\textbrokenbar{}" nil "¦" "|" "¦" "¦") ("S" "\\S" nil "§" "paragraph" "§" "§") ("sect" "\\S" nil "§" "paragraph" "§" "§") @@ -285,7 +283,7 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("ddag" "\\ddag{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡") "** Whitespace" - ("nbsp" "~" nil " " " " " " " ") + ("nbsp" "~" nil " " " " "\x00A0" "\x00A0") ("ensp" "\\hspace*{.5em}" nil " " " " " " " ") ("emsp" "\\hspace*{1em}" nil " " " " " " " ") ("thinsp" "\\hspace*{.2em}" nil " " " " " " " ") @@ -514,9 +512,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'." ("loz" "\\lozenge" t "◊" "[lozenge]" "[lozenge]" "⧫")) ;; Add "\_ "-entity family for spaces. (let (space-entities html-spaces (entity "_")) - (dotimes (n 20 (nreverse space-entities)) - (let ((n (+ 1 n)) - (spaces (make-string n ?\s))) + (dolist (n (number-sequence 1 20) (nreverse space-entities)) + (let ((spaces (make-string n ?\s))) (push (list (setq entity (concat entity " ")) (format "\\hspace*{%sem}" (* n .5)) nil @@ -539,29 +536,22 @@ This first checks the user list, then the built-in list." (defun org-entities-create-table () "Create an Org mode table with all entities." (interactive) - (let ((pos (point)) e latex mathp html latin utf8 name ascii) + (let ((pos (point))) (insert "|Name|LaTeX code|LaTeX|HTML code |HTML|ASCII|Latin1|UTF-8\n|-\n") - (mapc (lambda (e) (when (listp e) - (setq name (car e) - latex (nth 1 e) - mathp (nth 2 e) - html (nth 3 e) - ascii (nth 4 e) - latin (nth 5 e) - utf8 (nth 6 e)) - (if (equal ascii "|") (setq ascii "\\vert")) - (if (equal latin "|") (setq latin "\\vert")) - (if (equal utf8 "|") (setq utf8 "\\vert")) - (if (equal ascii "=>") (setq ascii "= >")) - (if (equal latin "=>") (setq latin "= >")) - (insert "|" name - "|" (format "=%s=" latex) - "|" (format (if mathp "$%s$" "$\\mbox{%s}$") - latex) - "|" (format "=%s=" html) "|" html - "|" ascii "|" latin "|" utf8 - "|\n"))) - org-entities) + (dolist (e org-entities) + (pcase e + (`(,name ,latex ,mathp ,html ,ascii ,latin ,utf8) + (if (equal ascii "|") (setq ascii "\\vert")) + (if (equal latin "|") (setq latin "\\vert")) + (if (equal utf8 "|") (setq utf8 "\\vert")) + (if (equal ascii "=>") (setq ascii "= >")) + (if (equal latin "=>") (setq latin "= >")) + (insert "|" name + "|" (format "=%s=" latex) + "|" (format (if mathp "$%s$" "$\\mbox{%s}$") latex) + "|" (format "=%s=" html) "|" html + "|" ascii "|" latin "|" utf8 + "|\n")))) (goto-char pos) (org-table-align))) @@ -570,31 +560,27 @@ This first checks the user list, then the built-in list." "Create a Help buffer with all available entities." (interactive) (with-output-to-temp-buffer "*Org Entity Help*" - (princ "Org-mode entities\n=================\n\n") + (princ "Org mode entities\n=================\n\n") (let ((ll (append '("* User-defined additions (variable org-entities-user)") org-entities-user org-entities)) - e latex mathp html latin utf8 name ascii (lastwasstring t) (head (concat "\n" " Symbol Org entity LaTeX code HTML code\n" " -----------------------------------------------------------\n"))) - (while ll - (setq e (pop ll)) - (if (stringp e) - (progn - (princ e) - (princ "\n") - (setq lastwasstring t)) - (if lastwasstring (princ head)) - (setq lastwasstring nil) - (setq name (car e) - latex (nth 1 e) - html (nth 3 e) - utf8 (nth 6 e)) - (princ (format " %-8s \\%-16s %-22s %-13s\n" - utf8 name latex html)))))) + (dolist (e ll) + (pcase e + (`(,name ,latex ,_ ,html ,_ ,_ ,utf8) + (when lastwasstring + (princ head) + (setq lastwasstring nil)) + (princ (format " %-8s \\%-16s %-22s %-13s\n" + utf8 name latex html))) + ((pred stringp) + (princ e) + (princ "\n") + (setq lastwasstring t)))))) (with-current-buffer "*Org Entity Help*" (org-mode) (when org-pretty-entities -- cgit v1.2.3