Browse Source

Remove some home-grown copies of cl-lib functions.

* lisp/org.el (org-count, org-remove-if, org-remove-if-not):
(org-reduce, org-every, org-some): Obsolete, use cl-lib versions
everywhere.
(org-sublist): Reimplement in terms of `cl-subseq'; make obsolete.
Aaron Ecay 9 years ago
parent
commit
e4cd3dd22b

+ 2 - 3
contrib/lisp/ob-julia.el

@@ -38,7 +38,6 @@
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
 
 (defconst org-babel-header-args:julia
   '((width		 . :any)
@@ -150,9 +149,9 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-julia-assign-elisp (name value colnames-p rownames-p)
   "Construct julia code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let ((max (apply #'max (mapcar #'length (org-remove-if-not
+      (let ((max (apply #'max (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
-	    (min (apply #'min (mapcar #'length (org-remove-if-not
+	    (min (apply #'min (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
 	    (transition-file (org-babel-temp-file "julia-import-")))
         ;; ensure VALUE has an orgtbl structure (depth of at least 2)

+ 2 - 3
contrib/lisp/ob-stata.el

@@ -50,7 +50,6 @@
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
 
 (defconst org-babel-header-args:stata
   '((width		 . :any)
@@ -165,9 +164,9 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-stata-assign-elisp (name value colnames-p rownames-p)
   "Construct stata code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let ((max (apply #'max (mapcar #'length (org-remove-if-not
+      (let ((max (apply #'max (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
-	    (min (apply #'min (mapcar #'length (org-remove-if-not
+	    (min (apply #'min (mapcar #'length (cl-remove-if-not
 						#'sequencep value))))
 	    (transition-file (org-babel-temp-file "stata-import-")))
         ;; ensure VALUE has an orgtbl structure (depth of at least 2)

+ 1 - 1
contrib/lisp/org-contacts.el

@@ -593,7 +593,7 @@ description."
 (defun org-contacts-remove-ignored-property-values (ignore-list list)
   "Remove all ignore-list's elements from list and you can use
    regular expressions in the ignore list."
-    (org-remove-if (lambda (el)
+    (cl-remove-if (lambda (el)
 		     (org-find-if (lambda (x)
 				    (string-match-p x el))
 				  ignore-list))

+ 1 - 1
contrib/lisp/ox-bibtex.el

@@ -169,7 +169,7 @@ to `org-bibtex-citation-p' predicate."
       (outline-previous-visible-heading 1)
       t)))
 
-(let ((jump-fn (car (org-remove-if-not #'fboundp '(ebib org-bibtex-goto-citation)))))
+(let ((jump-fn (car (cl-remove-if-not #'fboundp '(ebib org-bibtex-goto-citation)))))
   (org-add-link-type "cite" jump-fn))
 
 

+ 2 - 4
lisp/ob-R.el

@@ -28,7 +28,7 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (declare-function orgtbl-to-tsv "org-table" (table params))
 (declare-function R "ext:essd-r" (&optional start-args))
@@ -38,8 +38,6 @@
 (declare-function ess-wait-for-process "ext:ess-inf"
 		  (proc &optional sec-prompt wait force-redisplay))
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-remove-if-not "org" (predicate seq))
-(declare-function org-every "org" (pred seq))
 
 (defconst org-babel-header-args:R
   '((width		 . :any)
@@ -234,7 +232,7 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
   "Construct R code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-      (let* ((lengths (mapcar 'length (org-remove-if-not 'sequencep value)))
+      (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
 	     (max (if lengths (apply 'max lengths) 0))
 	     (min (if lengths (apply 'min lengths) 0)))
         ;; Ensure VALUE has an orgtbl structure (depth of at least 2).

+ 10 - 13
lisp/ob-core.el

@@ -25,6 +25,7 @@
 ;;; Code:
 (eval-when-compile
   (require 'cl))
+(require 'cl-lib)
 (require 'ob-eval)
 (require 'org-macs)
 (require 'org-compat)
@@ -38,9 +39,7 @@
 (defvar org-src-lang-modes)
 (defvar org-babel-library-of-babel)
 (declare-function outline-show-all "outline" ())
-(declare-function org-every "org" (pred seq))
 (declare-function org-remove-indentation "org" (code &optional n))
-(declare-function org-reduce "org" (CL-FUNC CL-SEQ &rest CL-KEYS))
 (declare-function org-mark-ring-push "org" (&optional pos buffer))
 (declare-function tramp-compat-make-temp-file "tramp-compat"
                   (filename &optional dir-flag))
@@ -90,7 +89,6 @@
 (declare-function org-list-struct "org-list" ())
 (declare-function org-list-prevs-alist "org-list" (struct))
 (declare-function org-list-get-list-end "org-list" (item struct prevs))
-(declare-function org-remove-if "org" (predicate seq))
 (declare-function org-completing-read "org" (&rest args))
 (declare-function org-escape-code-in-region "org-src" (beg end))
 (declare-function org-unescape-code-in-string "org-src" (s))
@@ -100,7 +98,6 @@
 (declare-function org-element-type "org-element" (element))
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-property "org-element" (property element))
-(declare-function org-every "org" (pred seq))
 (declare-function org-macro-escape-arguments "org-macro" (&rest args))
 
 (defgroup org-babel nil
@@ -219,7 +216,7 @@ PARAMS is a quasi-alist of header args, whcih may contain
 multiple entries for the key `:var'.  This function returns a
 list of the cdr of all the `:var' entries."
   (mapcar #'cdr
-	  (org-remove-if (lambda (x) (not (eq (car x) :var))) params)))
+	  (cl-remove-if-not (lambda (x) (eq (car x) :var)) params)))
 
 (defun org-babel-get-inline-src-block-matches ()
   "Set match data if within body of an inline source block.
@@ -526,7 +523,7 @@ their `org-babel-default-header-args:foo' variable.
 For the format of SAFE-LIST, see `org-babel-safe-header-args'."
   `(lambda (value)
      (and (listp value)
-	  (org-every
+	  (cl-every
 	   (lambda (pair)
 	     (and (consp pair)
 		  (org-babel-one-header-arg-safe-p pair ,safe-list)))
@@ -812,7 +809,7 @@ arguments and pop open the results in a preview buffer."
 	(let ((header (car arg-pair))
 	      (args (cdr arg-pair)))
 	  (setq results
-		(cons arg-pair (org-remove-if
+		(cons arg-pair (cl-remove-if
 				(lambda (pair) (equal header (car pair)))
 				results))))))
     results))
@@ -1525,7 +1522,7 @@ instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
   (let ((last= (lambda (str) (= ch (aref str (1- (length str))))))
 	(first= (lambda (str) (= ch (aref str 0)))))
     (reverse
-     (org-reduce (lambda (acc el)
+     (cl-reduce (lambda (acc el)
 		   (let ((head (car acc)))
 		     (if (and head (or (funcall last= head) (funcall first= el)))
 			 (cons (concat head el) (cdr acc))
@@ -1597,7 +1594,7 @@ shown below.
       (cons :result-type  (cond ((member "output" result-params) 'output)
 				((member "value" result-params) 'value)
 				(t 'value))))
-     (org-remove-if
+     (cl-remove-if
       (lambda (x) (memq (car x) '(:colname-names :rowname-names :result-params
 						 :result-type :var)))
       params))))
@@ -2254,7 +2251,7 @@ INFO may provide the values of these header arguments (in the
 		       ;; a table.
 		       (and (listp r)
 			    (null (cdr (last r)))
-			    (org-every
+			    (cl-every
 			     (lambda (e) (or (atom e) (null (cdr (last e)))))
 			     result)))))
 		;; insert results based on type
@@ -2280,7 +2277,7 @@ INFO may provide the values of these header arguments (in the
 		 ((funcall tabulablep result)
 		  (goto-char beg)
 		  (insert (concat (orgtbl-to-orgtbl
-				   (if (org-every
+				   (if (cl-every
 					(lambda (e)
 					  (or (eq e 'hline) (listp e)))
 					result)
@@ -2621,9 +2618,9 @@ parameters when merging lists."
 	(lambda (param)
 	  (when (assoc param params)
 	    (setf (cdr (assoc param params))
-		  (org-remove-if (lambda (pair) (equal (car pair) name))
+		  (cl-remove-if (lambda (pair) (equal (car pair) name))
 				 (cdr (assoc param params))))
-	    (setf params (org-remove-if (lambda (pair) (and (equal (car pair) param)
+	    (setf params (cl-remove-if (lambda (pair) (and (equal (car pair) param)
 						       (null (cdr pair))))
 					params))))
 	(list :colname-names :rowname-names)))

+ 2 - 2
lisp/ob-fortran.el

@@ -29,10 +29,10 @@
 ;;; Code:
 (require 'ob)
 (require 'cc-mode)
+(require 'cl-lib)
 
 (declare-function org-entry-get "org"
 		  (pom property &optional inherit literal-nil))
-(declare-function org-every "org" (pred seq))
 (declare-function org-remove-indentation "org" (code &optional n))
 
 (defvar org-babel-tangle-lang-exts)
@@ -145,7 +145,7 @@ of the same value."
       (format "character(len=%d), parameter ::  %S = '%s'\n"
               (length val) var val))
      ;; val is a matrix
-     ((and (listp val) (org-every #'listp val))
+     ((and (listp val) (cl-every #'listp val))
       (format "real, parameter :: %S(%d,%d) = transpose( reshape( %s , (/ %d, %d /) ) )\n"
 	      var (length val) (length (car val))
 	      (org-babel-fortran-transform-list val)

+ 2 - 5
lisp/ob-ref.el

@@ -50,14 +50,12 @@
 
 ;;; Code:
 (require 'ob-core)
-(eval-when-compile
-  (require 'cl))
+(require 'cl-lib)
 
 (declare-function org-at-item-p "org-list" ())
 (declare-function org-at-table-p "org" (&optional table-type))
 (declare-function org-babel-lob-execute "ob-lob" (info))
 (declare-function org-babel-lob-get-info "ob-lob" nil)
-(declare-function org-count "org" (cl-item cl-seq))
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-type "org-element" (element))
@@ -69,7 +67,6 @@
 (declare-function org-narrow-to-subtree "org" ())
 (declare-function org-pop-to-buffer-same-window "org-compat"
 		  (&optional buffer-or-name norecord label))
-(declare-function org-remove-if-not "org" (predicate seq))
 (declare-function org-show-context "org" (&optional key))
 
 
@@ -139,7 +136,7 @@ the variable."
 	  ;; if ref is indexed grab the indices -- beware nested indices
 	  (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
 		     (let ((str (substring ref 0 (match-beginning 0))))
-		       (= (org-count ?( str) (org-count ?) str))))
+		       (= (cl-count ?( str) (cl-count ?) str))))
 	    (setq index (match-string 1 ref))
 	    (setq ref (substring ref 0 (match-beginning 0))))
 	  ;; assign any arguments to pass to source block

+ 8 - 0
lisp/org-compat.el

@@ -566,6 +566,14 @@ Implements `define-error' for older emacsen."
     (put name 'error-conditions
 	 (copy-sequence (cons name (get 'error 'error-conditions))))))
 
+;;; Functions from cl-lib that Org used to have its own implementation of
+(define-obsolete-function-alias 'org-count 'cl-count "Org 9.0")
+(define-obsolete-function-alias 'org-remove-if 'cl-remove-if "Org 9.0")
+(define-obsolete-function-alias 'org-remove-if-not 'cl-remove-if-not "Org 9.0")
+(define-obsolete-function-alias 'org-reduce 'cl-reduce "Org 9.0")
+(define-obsolete-function-alias 'org-every 'cl-every "Org 9.0")
+(define-obsolete-function-alias 'org-some 'cl-some "Org 9.0")
+
 (provide 'org-compat)
 
 ;;; org-compat.el ends here

+ 2 - 1
lisp/org-element.el

@@ -118,6 +118,7 @@
 
 (require 'org)
 (require 'avl-tree)
+(require 'cl-lib)
 
 
 
@@ -333,7 +334,7 @@ This list is checked after translations have been applied.  See
 	   ;; Regular affiliated keywords.
 	   (format "\\(?1:%s\\)"
 		   (regexp-opt
-		    (org-remove-if
+		    (cl-remove-if
 		     (lambda (k) (member k org-element-dual-keywords))
 		     org-element-affiliated-keywords)))
 	   "\\|"

+ 2 - 1
lisp/org-indent.el

@@ -41,6 +41,7 @@
 
 (eval-when-compile
   (require 'cl))
+(require 'cl-lib)
 
 (declare-function org-inlinetask-get-task-level "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
@@ -209,7 +210,7 @@ When no more buffer is being watched, the agent suppress itself."
   (when org-indent-agent-resume-timer
     (cancel-timer org-indent-agent-resume-timer))
   (setq org-indent-agentized-buffers
-	(org-remove-if-not #'buffer-live-p org-indent-agentized-buffers))
+	(cl-remove-if-not #'buffer-live-p org-indent-agentized-buffers))
   (cond
    ;; Job done:  kill agent.
    ((not org-indent-agentized-buffers) (cancel-timer org-indent-agent-timer))

+ 4 - 4
lisp/org-lint.el

@@ -771,7 +771,7 @@ Use :header-args: instead"
     (lambda (h)
       (and (org-element-property :footnote-section-p h)
 	   (org-element-map (org-element-contents h)
-	       (org-remove-if
+	       (cl-remove-if
 		(lambda (e)
 		  (memq e '(comment comment-block footnote-definition
 				    property-drawer section)))
@@ -1085,7 +1085,7 @@ CHECKERS is the list of checkers used."
   (interactive)
   (let ((c (org-lint--current-checker)))
     (setf tabulated-list-entries
-	  (org-remove-if (lambda (e) (equal c (org-lint--current-checker e)))
+	  (cl-remove-if (lambda (e) (equal c (org-lint--current-checker e)))
 			 tabulated-list-entries))
     (tabulated-list-print)))
 
@@ -1124,7 +1124,7 @@ ARG can also be a list of checker names, as symbols, to run."
 		    "Checker category: "
 		    (mapcar #'org-lint-checker-categories org-lint--checkers)
 		    nil t)))
-	      (org-remove-if-not
+	      (cl-remove-if-not
 	       (lambda (c)
 		 (assoc-string (org-lint-checker-categories c) category))
 	       org-lint--checkers)))
@@ -1139,7 +1139,7 @@ ARG can also be a list of checker names, as symbols, to run."
 		   (when (string= (org-lint-checker-name c) name)
 		     (throw 'exit c)))))))
 	   ((pred consp)
-	    (org-remove-if-not (lambda (c) (memq (org-lint-checker-name c) arg))
+	    (cl-remove-if-not (lambda (c) (memq (org-lint-checker-name c) arg))
 			       org-lint--checkers))
 	   (_ (user-error "Invalid argument `%S' for `org-lint'" arg)))))
     (if (not (org-called-interactively-p))

+ 5 - 6
lisp/org-list.el

@@ -78,6 +78,7 @@
 
 (eval-when-compile
   (require 'cl))
+(require 'cl-lib)
 (require 'org-macs)
 (require 'org-compat)
 
@@ -98,7 +99,6 @@
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-combine-plists "org" (&rest plists))
-(declare-function org-count "org" (cl-item cl-seq))
 (declare-function org-current-level "org" ())
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-context "org-element" (&optional element))
@@ -124,7 +124,6 @@
 (declare-function org-narrow-to-subtree "org" ())
 (declare-function org-previous-line-empty-p "org" ())
 (declare-function org-reduced-level "org" (L))
-(declare-function org-remove-if "org" (predicate seq))
 (declare-function org-show-subtree "org" ())
 (declare-function org-sort-remove-invisible "org" (S))
 (declare-function org-time-string-to-seconds "org" (s))
@@ -1471,7 +1470,7 @@ This function returns, destructively, the new list structure."
 		     (t dest)))
 	 (org-M-RET-may-split-line nil)
 	 ;; Store inner overlays (to preserve visibility).
-	 (overlays (org-remove-if (lambda (o) (or (< (overlay-start o) item)
+	 (overlays (cl-remove-if (lambda (o) (or (< (overlay-start o) item)
 					     (> (overlay-end o) item)))
 				  (overlays-in item item-end))))
     (cond
@@ -2400,7 +2399,7 @@ in subtree, ignoring drawers."
 	       (parents (org-list-parents-alist struct))
 	       (prevs (org-list-prevs-alist struct))
 	       (bottom (copy-marker (org-list-get-bottom-point struct)))
-	       (items-to-toggle (org-remove-if
+	       (items-to-toggle (cl-remove-if
 				 (lambda (e) (or (< e lim-up) (> e lim-down)))
 				 (mapcar #'car struct))))
 	  (mapc (lambda (e) (org-list-set-checkbox
@@ -2497,7 +2496,7 @@ With optional prefix argument ALL, do this for the whole buffer."
 					      (org-list-get-checkbox e s))
 					    items))))
 		   (incf c-all (length cookies))
-		   (incf c-on (org-count "[X]" cookies)))))))
+		   (incf c-on (cl-count "[X]" cookies :test #'equal)))))))
 	  cookies-list cache)
      ;; Move to start.
      (cond (all (goto-char (point-min)))
@@ -2675,7 +2674,7 @@ Return t if successful."
 		   ;; of the subtree mustn't have a child.
 		   (let ((last-item (caar
 				     (reverse
-				      (org-remove-if
+				      (cl-remove-if
 				       (lambda (e) (>= (car e) end))
 				       struct)))))
 		     (org-list-has-child-p last-item struct))))

+ 2 - 2
lisp/org-src.el

@@ -35,6 +35,7 @@
 (require 'ob-keys)
 (require 'ob-comint)
 (eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (declare-function org-base-buffer "org" (buffer))
 (declare-function org-do-remove-indentation "org" (&optional n))
@@ -49,7 +50,6 @@
 (declare-function org-get-indentation "org" (&optional line))
 (declare-function org-pop-to-buffer-same-window "org-compat"
 		  (&optional buffer-or-name norecord label))
-(declare-function org-some "org" (pred seq))
 (declare-function org-switch-to-buffer-other-window "org" (&rest args))
 (declare-function org-trim "org" (s))
 
@@ -963,7 +963,7 @@ Throw an error if there is no such buffer."
       (goto-char beg)
       (cond
        ;; Block is hidden; move at start of block.
-       ((org-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block))
+       ((cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block))
 		  (overlays-at (point)))
 	(beginning-of-line 0))
        (write-back (org-src--goto-coordinates coordinates beg end))))

+ 7 - 5
lisp/org-table.el

@@ -36,6 +36,7 @@
 
 (eval-when-compile
   (require 'cl))
+(require 'cl-lib)
 (require 'org)
 
 (declare-function org-element-at-point "org-element" ())
@@ -2790,11 +2791,12 @@ not overwrite the stored one."
 		(replace-match
 		 (save-match-data
 		   (org-table-make-reference
-		    (org-sublist fields
-				 (+ (if (match-end 2) n0 0)
-				    (string-to-number (match-string 1 form)))
-				 (+ (if (match-end 4) n0 0)
-				    (string-to-number (match-string 3 form))))
+		    (cl-subseq fields
+			       (+ (if (match-end 2) n0 0)
+				  (string-to-number (match-string 1 form))
+				  -1)
+			       (+ (if (match-end 4) n0 0)
+				  (string-to-number (match-string 3 form))))
 		    keep-empty numbers lispp))
 		 t t form)))
 	(setq form0 form)

+ 10 - 64
lisp/org.el

@@ -68,6 +68,8 @@
 
 ;;;; Require other packages
 
+(require 'cl-lib)
+
 (eval-when-compile
   (require 'cl)
   (require 'gnus-sum))
@@ -766,7 +768,7 @@ value of the variable, after updating it:
 
   (progn
     (setq org-export-registered-backends
-          (org-remove-if-not
+          (cl-remove-if-not
            (lambda (backend)
              (let ((name (org-export-backend-name backend)))
                (or (memq name val)
@@ -798,7 +800,7 @@ depends on, if any."
 	   ;; a parent of any back-end in the new value) is removed from the
 	   ;; list of registered back-ends.
 	   (setq org-export-registered-backends
-		 (org-remove-if-not
+		 (cl-remove-if-not
 		  (lambda (backend)
 		    (let ((name (org-export-backend-name backend)))
 		      (or (memq name val)
@@ -11320,9 +11322,9 @@ If the file does not exist, an error is thrown."
 		   buffer-file-name
 		 (substitute-in-file-name (expand-file-name path))))
 	 (file-apps (append org-file-apps (org-default-apps)))
-	 (apps (org-remove-if
+	 (apps (cl-remove-if
 		'org-file-apps-entry-match-against-dlink-p file-apps))
-	 (apps-dlink (org-remove-if-not
+	 (apps-dlink (cl-remove-if-not
 		      'org-file-apps-entry-match-against-dlink-p file-apps))
 	 (remp (and (assq 'remote apps) (org-file-remote-p file)))
 	 (dirp (unless remp (file-directory-p file)))
@@ -18960,7 +18962,7 @@ removed, nil otherwise."
     (setq org-latex-fragment-image-overlays
 	  (let ((beg (or beg (point-min)))
 		(end (or end (point-max))))
-	    (org-remove-if
+	    (cl-remove-if
 	     (lambda (o)
 	       (cond ((not (overlay-buffer o)) (delete-overlay o) t)
 		     ((and (>= (overlay-start o) beg)
@@ -22668,59 +22670,6 @@ The function returns the new ALIST."
     (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)
-    (while seq
-      (setq e (pop seq))
-      (if (not (funcall predicate e)) (push e res)))
-    (nreverse res)))
-
-(defun org-remove-if-not (predicate seq)
-  "Remove everything from SEQ that does not fulfill PREDICATE."
-  (let (res e)
-    (while seq
-      (setq e (pop seq))
-      (if (funcall predicate e) (push e res)))
-    (nreverse res)))
-
-(defun org-reduce (cl-func cl-seq &rest cl-keys)
-  "Reduce two-argument FUNCTION across SEQ.
-Taken from `reduce' in cl-seq.el with all keyword arguments but
-\":initial-value\" removed."
-  (let ((cl-accum (cond ((memq :initial-value cl-keys)
-                         (cadr (memq :initial-value cl-keys)))
-                        (cl-seq (pop cl-seq))
-                        (t (funcall cl-func)))))
-    (while cl-seq
-      (setq cl-accum (funcall cl-func cl-accum (pop cl-seq))))
-    cl-accum))
-
-(defun org-every (pred seq)
-  "Return true if PREDICATE is true of every element of SEQ.
-Adapted from `every' in cl.el."
-  (catch 'org-every
-    (mapc (lambda (e) (unless (funcall pred e) (throw 'org-every nil))) seq)
-    t))
-
-(defun org-some (pred seq)
-  "Return true if PREDICATE is true of any element of SEQ.
-Adapted from `some' in cl.el."
-  (catch 'org-some
-    (mapc (lambda (e) (when (funcall pred e) (throw 'org-some t))) seq)
-    nil))
-
 (defun org-back-over-empty-lines ()
   "Move backwards over whitespace, to the beginning of the first empty line.
 Returns the number of empty lines passed."
@@ -22798,13 +22747,10 @@ so values can contain further %-escapes if they are define later in TABLE."
 
 (defun org-sublist (list start 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))
-      (push (pop list) rtn)
-      (setq c (1+ c)))
-    (nreverse rtn)))
+  (cl-subseq list (1- start) end))
+(make-obsolete 'org-sublist "cl-subseq (note the 0-based counting)." "Org 9.0")
 
 (defun org-find-base-buffer-visiting (file)
   "Like `find-buffer-visiting' but always return the base buffer and

+ 2 - 1
lisp/ox-beamer.el

@@ -30,6 +30,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'ox-latex)
 
 ;; Install a default set-up for Beamer export.
@@ -955,7 +956,7 @@ value."
     (save-excursion
       (org-back-to-heading t)
       ;; Filter out Beamer-related tags and install environment tag.
-      (let ((tags (org-remove-if (lambda (x) (string-match "^B_" x))
+      (let ((tags (cl-remove-if (lambda (x) (string-match "^B_" x))
 				 (org-get-tags)))
 	    (env-tag (and (org-string-nw-p value) (concat "B_" value))))
 	(org-set-tags-to (if env-tag (cons env-tag tags) tags))

+ 2 - 1
lisp/ox-html.el

@@ -34,6 +34,7 @@
 (require 'ox-publish)
 (require 'format-spec)
 (eval-when-compile (require 'cl) (require 'table nil 'noerror))
+(require 'cl-lib)
 
 
 ;;; Function Declarations
@@ -1716,7 +1717,7 @@ INFO is a plist used as a communication channel."
 	 info))
       charset) "\n"
      (let ((viewport-options
-	    (org-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
+	    (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
 			       (plist-get info :html-viewport))))
        (and viewport-options
 	    (concat

+ 3 - 2
lisp/ox-icalendar.el

@@ -32,6 +32,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'ox-ascii)
 (declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
 
@@ -834,7 +835,7 @@ external process."
       ;; Asynchronous export is not interactive, so we will not call
       ;; `org-check-agenda-file'.  Instead we remove any non-existent
       ;; agenda file from the list.
-      (let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
+      (let ((files (cl-remove-if-not #'file-exists-p (org-agenda-files t))))
 	(org-export-async-start
 	    (lambda (results)
 	      (dolist (f results) (org-export-add-to-stack f 'icalendar)))
@@ -865,7 +866,7 @@ The file is stored under the name chosen in
 `org-icalendar-combined-agenda-file'."
   (interactive)
   (if async
-      (let ((files (org-remove-if-not #'file-exists-p (org-agenda-files t))))
+      (let ((files (cl-remove-if-not #'file-exists-p (org-agenda-files t))))
 	(org-export-async-start
 	    (lambda (_)
 	      (org-export-add-to-stack

+ 1 - 1
lisp/ox-publish.el

@@ -445,7 +445,7 @@ matching the regexp SKIP-DIR when recursing through BASE-DIR."
   (let ((all-files (if (not recurse) (directory-files base-dir t match)
 		     ;; If RECURSE is non-nil, we want all files
 		     ;; matching MATCH and sub-directories.
-		     (org-remove-if-not
+		     (cl-remove-if-not
 		      (lambda (file)
 			(or (file-directory-p file)
 			    (and match (string-match match file))))

+ 6 - 6
lisp/ox.el

@@ -2828,7 +2828,7 @@ not, are considered."
 	;; Filter out definitions referenced neither in the original
 	;; tree nor in the external definitions.
 	(let* ((directly-referenced
-		(org-remove-if-not
+		(cl-remove-if-not
 		 (lambda (d)
 		   (member (org-element-property :label d) referenced-labels))
 		 definitions))
@@ -2836,7 +2836,7 @@ not, are considered."
 		(append (funcall collect-labels directly-referenced)
 			referenced-labels)))
 	  (setq definitions
-		(org-remove-if-not
+		(cl-remove-if-not
 		 (lambda (d)
 		   (member (org-element-property :label d) all-labels))
 		 definitions)))
@@ -3865,7 +3865,7 @@ INFO is a plist holding contextual information."
 (defun org-export-numbered-headline-p (headline info)
   "Return a non-nil value if HEADLINE element should be numbered.
 INFO is a plist used as a communication channel."
-  (unless (org-some
+  (unless (cl-some
 	   (lambda (head) (org-not-nil (org-element-property :UNNUMBERED head)))
 	   (org-element-lineage headline nil t))
     (let ((sec-num (plist-get info :section-numbers))
@@ -3902,7 +3902,7 @@ Any tag belonging to this list will also be removed.
 
 When optional argument INHERITED is non-nil, tags can also be
 inherited from parent headlines and FILETAGS keywords."
-  (org-remove-if
+  (cl-remove-if
    (lambda (tag) (or (member tag (plist-get info :select-tags))
 		(member tag (plist-get info :exclude-tags))
 		(member tag tags)))
@@ -6037,7 +6037,7 @@ stack."
 	       ;; Clear stack from exited processes, dead buffers or
 	       ;; non-existent files.
 	       (setq org-export-stack-contents
-		     (org-remove-if-not
+		     (cl-remove-if-not
 		      (lambda (el)
 			(if (processp (nth 2 el))
 			    (buffer-live-p (process-buffer (nth 2 el)))
@@ -6052,7 +6052,7 @@ If optional argument SOURCE is non-nil, remove it instead."
   (interactive)
   (let ((source (or source (org-export--stack-source-at-point))))
     (setq org-export-stack-contents
-	  (org-remove-if (lambda (el) (equal (car el) source))
+	  (cl-remove-if (lambda (el) (equal (car el) source))
 			 org-export-stack-contents))))
 
 (defun org-export-stack-view (&optional in-emacs)

+ 4 - 2
testing/lisp/test-ox.el

@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+
 (unless (featurep 'ox)
   (signal 'missing-test-dependency "org-export"))
 
@@ -1148,7 +1150,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote
       (buffer-string))))
   ;; Adjacent INCLUDE-keywords should have the same :minlevel if unspecified.
   (should
-   (org-every (lambda (level) (zerop (1- level)))
+   (cl-every (lambda (level) (zerop (1- level)))
 	      (org-test-with-temp-text
 		  (concat
 		   (format "#+INCLUDE: \"%s/examples/include.org::#ah\"\n" org-test-dir)
@@ -2066,7 +2068,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote
 :UNNUMBERED: nil
 :END:
 *** H3"
-     (org-every
+     (cl-every
       (lambda (h) (not (org-export-numbered-headline-p h info)))
       (org-element-map tree 'headline #'identity info)))))