summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-21 16:40:08 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-21 16:40:08 +0200
commit27c5cf153f9b58f0905cbc8600d0f563a4a521d3 (patch)
treec691922511bb4f88a77702c597c68a277e6d2a2d
parent4f63cfabb38d92e83f1c3e2f8aa2f33bafbdd1d8 (diff)
downloadorg-mode-27c5cf153f9b58f0905cbc8600d0f563a4a521d3.tar.gz
org-entities: Use lexical binding
* lisp/org-entities.el (org-entities): (org-entities-create-table): (org-entities-help): Silence byte-compiler.
-rw-r--r--lisp/org-entities.el75
1 files changed, 30 insertions, 45 deletions
diff --git a/lisp/org-entities.el b/lisp/org-entities.el
index 44b1d54..435245b 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,9 +30,6 @@
(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."
:tag "Org Entities"
@@ -515,9 +512,8 @@ packages to be loaded, add these packages to `org-latex-packages-alist'."
("loz" "\\lozenge" t "&loz;" "[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
@@ -540,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)))
@@ -575,27 +564,23 @@ This first checks the user list, then the built-in list."
(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