From 4357dde36240525f0f834b76256ec995a94396c4 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 7 Jun 2014 15:32:47 +0200 Subject: [PATCH] org-element: Small fix * lisp/org-element.el (org-element--cache-generate-key): Small fix. Check if UPPER is non nil before comparing its car with 1. This is a safety feature, though, as a key shouldn't end on 0 anyway. --- lisp/org-element.el | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index d02f9075d..e768aac7d 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4794,22 +4794,21 @@ the following rules: (while (and upper (zerop (car upper))) (push 0 key) (setq upper (cdr upper))) - ;; (n) is equivalent to (n 0 0 0 0 ...) so we want to avoid - ;; ending on a sequence of 0. - (if (= (car upper) 1) - (progn (push 0 key) - (push org-element--cache-default-key key)) - (push (if upper (ash (car upper) -1) org-element--cache-default-key) - key))) + ;; (n) is equivalent to (n 0 0 0 0 ...) so we forbid ending + ;; sequences on 0. + (cond ((not upper) (push org-element--cache-default-key key)) + ((= (car upper) 1) + (push 0 key) + (push org-element--cache-default-key key)) + (t (push (ash (car upper) -1) key)))) ((not upper) (while (and lower (= (car lower) most-positive-fixnum)) (push most-positive-fixnum key) (setq lower (cdr lower))) - (push (if lower - (let ((n (car lower))) - (+ (ash (if (zerop (mod n 2)) n (1+ n)) -1) - org-element--cache-default-key)) - org-element--cache-default-key) + (push (if (not lower) org-element--cache-default-key + (let ((n (car lower))) + (+ (ash (if (zerop (mod n 2)) n (1+ n)) -1) + org-element--cache-default-key))) key)))) ;; Ensure we don't return a list with a single element. (if (cdr key) (nreverse key) (car key))))) -- 2.11.4.GIT