diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-14 17:59:43 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-14 17:59:43 -0700 |
commit | 2f178148f9686687e540786ace56e3562922f6e4 (patch) | |
tree | 2a3a398d9730641c04960b46774c987f22cd0280 | |
parent | fb72ef7809f0acc098b02c77f75c80a0c98ca156 (diff) | |
download | org-mode-2f178148f9686687e540786ace56e3562922f6e4.tar.gz |
ob-ref: fixed error caused by missing count function, now using org-count
* lisp/ob-ref.el (org-babel-ref-resolve-reference): removed an error
introduced while fixing compiler warnings -- required mirroring of
the count cl-seqs function under the org-mode namespace.
* lisp/org.el (org-count): adding an org-mode version of the cl-seqs
count function
-rw-r--r-- | lisp/ob-ref.el | 10 | ||||
-rw-r--r-- | lisp/org.el | 11 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 4ed70be..776d027 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -41,7 +41,7 @@ ;; same file would be ;; #+TBLNAME: sandbox -;; | 1 | 2 | 3 | +;; | 1 | 2 | 3 | ;; | 4 | org-babel | 6 | ;; ;; #+begin_src emacs-lisp :var table=sandbox @@ -55,6 +55,7 @@ (declare-function org-remove-if-not "org" (predicate seq)) (declare-function org-at-table-p "org" (&optional table-type)) +(declare-function org-count "org" (CL-ITEM CL-SEQ)) (defun org-babel-ref-variables (params) "Convert PARAMS to variable names and values. @@ -108,13 +109,10 @@ return nil." (let ((case-fold-search t) type args new-refere new-referent result lob-info split-file split-ref index index-row index-col) - ;; if ref is indexed grab the indices -- beware nested indicies + ;; if ref is indexed grab the indices -- beware nested indices (when (and (string-match "\\[\\(.+\\)\\]" ref) (let ((str (substring ref 0 (match-beginning 0)))) - (= (length (org-remove-if-not - (lambda (el) (equal ?( el)) (string-to-list "((eric))"))) - (length (org-remove-if-not - (lambda (el) (equal ?) el)) (string-to-list "((eric))")))))) + (= (org-count ?( str) (org-count ?) str)))) (setq index (match-string 1 ref)) (setq ref (substring ref 0 (match-beginning 0)))) ;; assign any arguments to pass to source block diff --git a/lisp/org.el b/lisp/org.el index 6a492d8..62df6e9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18223,6 +18223,17 @@ for the search purpose." (setq list (delete (pop elts) list))) list) +(defun org-count (cl-item cl-seq) + "Count the number of occurrences of ITEM in SEQ. +Taken from `count' in cl-seq.el with all keyword arguments removed." + (let ((cl-end (length cl-seq)) (cl-start 0) (cl-count 0) cl-x) + (when (consp cl-seq) (setq cl-seq (nthcdr cl-start cl-seq))) + (while (< cl-start cl-end) + (setq cl-x (if (consp cl-seq) (pop cl-seq) (aref cl-seq cl-start))) + (if (equal cl-item cl-x) (setq cl-count (1+ cl-count))) + (setq cl-start (1+ cl-start))) + cl-count)) + (defun org-remove-if (predicate seq) "Remove everything from SEQ that fulfills PREDICATE." (let (res e) |