summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-21 16:52:05 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-21 16:53:27 +0200
commitc69fd5bf61e84804679d04062c85bd6a177bcb72 (patch)
treefb1e622356c18895af5d6ca708273767fdf1e22f
parent27c5cf153f9b58f0905cbc8600d0f563a4a521d3 (diff)
downloadorg-mode-c69fd5bf61e84804679d04062c85bd6a177bcb72.tar.gz
org-entities: Tiny refactoring
* lisp/org-entities.el (org-entities--user-safe-p): Use pattern matching and strengthen check for name.
-rw-r--r--lisp/org-entities.el18
1 files changed, 8 insertions, 10 deletions
diff --git a/lisp/org-entities.el b/lisp/org-entities.el
index 435245b..dec5064 100644
--- a/lisp/org-entities.el
+++ b/lisp/org-entities.el
@@ -37,16 +37,14 @@
(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.