summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-06-07 15:32:47 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-06-07 15:32:47 +0200
commit4357dde36240525f0f834b76256ec995a94396c4 (patch)
tree7270fe210538a91773533079620bb007dfca80d2
parent73bada5d84fc22dd024bc3ca4feefccf299f46d0 (diff)
downloadorg-mode-4357dde36240525f0f834b76256ec995a94396c4.tar.gz
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.
-rw-r--r--lisp/org-element.el23
1 files changed, 11 insertions, 12 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index d02f907..e768aac 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)))))