Hi Eric,

Eric Schulte <schulte.e...@gmail.com> writes:

> Oh, I did not realize `subseq' was part of the cl library.  Since it
> seems subseq is a generally useful utility, would there be any appetite
> for implementing an org-subseq function?

There was already org-sublist, which I adapted to mimic the behavior
of subseq.

Can you try the attached patch and see if it works as advertized?

Thanks,

Changes in stash@{0}^2^..stash@{0}
3 files changed, 10 insertions(+), 9 deletions(-)
 lisp/ob-lob.el    |  4 ++--
 lisp/org-table.el |  4 ++--
 lisp/org.el       | 11 ++++++-----

	Modified   lisp/ob-lob.el
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index c93198a..210dbb4 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -148,12 +148,12 @@ if so then run the appropriate source block from the Library."
 		      ;; hash evaluation, since for a call line :var
 		      ;; extension *is* execution.
 		      (let ((params (nth 2 pre-info)))
-			(append (subseq pre-info 0 2)
+			(append (org-subseq pre-info 0 2)
 				(list
 				 (cons
 				  (cons :c-var (cdr (assoc :var params)))
 				  (assq-delete-all :var (copy-tree params))))
-				(subseq pre-info 3))))))
+				(org-subseq pre-info 3))))))
 	 (old-hash (when cache-p (org-babel-current-result-hash pre-info)))
 	 (org-babel-current-src-block-location (point-marker)))
     (if (and cache-p (equal new-hash old-hash))
	Modified   lisp/org-table.el
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 520ac8a..38a9171 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2698,8 +2698,8 @@ not overwrite the stored one."
 		(replace-match
 		 (save-match-data
 		   (org-table-make-reference
-		    (org-sublist
-		     fields (string-to-number (match-string 1 form))
+		    (org-subseq
+		     fields (1- (string-to-number (match-string 1 form)))
 		     (string-to-number (match-string 2 form)))
 		    keep-empty numbers lispp))
 		 t t form)))
	Modified   lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index 41fb22c..32f27b1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -22059,12 +22059,13 @@ so values can contain further %-escapes if they are define later in TABLE."
 	  (setq string (replace-match sref t t string)))))
     string))
 
-(defun org-sublist (list start end)
+;; This reimplements subseq from cl-subseq
+(defun org-subseq (list start &optional end)
   "Return a section of LIST, from START to END.
-Counting starts at 1."
-  (let (rtn (c start))
-    (setq list (nthcdr (1- start) list))
-    (while (and list (<= c end))
+END is optional and counting starts at 0."
+  (let ((c start) (end (or end (length list))) rtn)
+    (setq list (nthcdr start list))
+    (while (and list (< c end))
       (push (pop list) rtn)
       (setq c (1+ c)))
     (nreverse rtn)))

-- 
 Bastien

Reply via email to