summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-04-21 09:35:13 -0600
committerEric Schulte <schulte.eric@gmail.com>2010-04-21 09:35:13 -0600
commit927ff1125babb47b9ca9c90b2fb7e94d03520ebb (patch)
tree938075a0d8644aa7311000b0ed30d87274a84c6e
parente84998ada85419921fdc68c0d9950918ccb25ad0 (diff)
downloadorg-mode-927ff1125babb47b9ca9c90b2fb7e94d03520ebb.tar.gz
babel: `org-babel-ref-index-list' now converts trivial lists to scalars
Thanks to Darlan Cavalcante Moreira for this suggestion.
-rw-r--r--contrib/babel/lisp/org-babel-ref.el28
1 files changed, 15 insertions, 13 deletions
diff --git a/contrib/babel/lisp/org-babel-ref.el b/contrib/babel/lisp/org-babel-ref.el
index b8fd1a1..8eb200f 100644
--- a/contrib/babel/lisp/org-babel-ref.el
+++ b/contrib/babel/lisp/org-babel-ref.el
@@ -169,19 +169,21 @@ which case the entire range is returned."
(let ((length (length lis))
(portion (match-string 1 index))
(remainder (substring index (match-end 0))))
- (flet ((wrap (num) (if (< num 0) (+ length num) num)))
- (mapcar
- (lambda (sub-lis) (org-babel-ref-index-list remainder sub-lis))
- (if (string-match "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\*\\)"
- portion)
- (mapcar (lambda (n) (nth n lis))
- (apply 'number-sequence
- (if (match-string 2 portion)
- (list
- (wrap (string-to-number (match-string 2 portion)))
- (wrap (string-to-number (match-string 3 portion))))
- (list (wrap 0) (wrap -1)))))
- (list (nth (wrap (string-to-number portion)) lis))))))
+ (flet ((wrap (num) (if (< num 0) (+ length num) num))
+ (open (lis) (if (and (listp lis) (= (length lis) 1)) (car lis) lis)))
+ (open
+ (mapcar
+ (lambda (sub-lis) (org-babel-ref-index-list remainder sub-lis))
+ (if (string-match "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\*\\)"
+ portion)
+ (mapcar (lambda (n) (nth n lis))
+ (apply 'number-sequence
+ (if (match-string 2 portion)
+ (list
+ (wrap (string-to-number (match-string 2 portion)))
+ (wrap (string-to-number (match-string 3 portion))))
+ (list (wrap 0) (wrap -1)))))
+ (list (nth (wrap (string-to-number portion)) lis)))))))
lis))
(defun org-babel-ref-split-args (arg-string)