Browse Source

contrib, test suite: use assq instead of assoc for :keywords

Aaron Ecay 3 years ago
parent
commit
407b0d41a2

+ 8 - 8
contrib/lisp/ob-csharp.el

@@ -48,29 +48,29 @@ or an absolute path name, like /usr/local/bin/mcs
 parameters may be used, like mcs -warnaserror+"
   :group 'org-babel
   :version "24.3"
-  :type 'string) 
+  :type 'string)
 
 (defun org-babel-execute:csharp (body params)
   (let* ((full-body (org-babel-expand-body:generic body params))
-	 (cmpflag (or (cdr (assoc :cmpflag params)) ""))
-	 (cmdline (or (cdr (assoc :cmdline params)) ""))
+	 (cmpflag (or (cdr (assq :cmpflag params)) ""))
+	 (cmdline (or (cdr (assq :cmdline params)) ""))
 	 (src-file (org-babel-temp-file "csharp-src-" ".cs"))
 	 (exe-file (concat (file-name-sans-extension src-file)  ".exe"))
-	 (compile 
+	 (compile
 	  (progn (with-temp-file  src-file (insert full-body))
-		 (org-babel-eval 
+		 (org-babel-eval
 		  (concat org-babel-csharp-compiler " " cmpflag " "  src-file) ""))))
     (let ((results (org-babel-eval (concat org-babel-csharp-command " " cmdline " " exe-file) "")))
       (org-babel-reassemble-table
-       (org-babel-result-cond (cdr (assoc :result-params params))
+       (org-babel-result-cond (cdr (assq :result-params params))
 	 (org-babel-read results)
          (let ((tmp-file (org-babel-temp-file "c-")))
            (with-temp-file tmp-file (insert results))
            (org-babel-import-elisp-from-file tmp-file)))
        (org-babel-pick-name
-        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+        (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
        (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (defun org-babel-prep-session:csharp (session params)
   "Return an error because csharp does not support sessions."

+ 4 - 4
contrib/lisp/ob-eukleides.el

@@ -58,12 +58,12 @@
 (defun org-babel-execute:eukleides (body params)
   "Execute a block of eukleides code with org-babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
-	 (out-file (or (cdr (assoc :file params))
+  (let* ((result-params (split-string (or (cdr (assq :results params)) "")))
+	 (out-file (or (cdr (assq :file params))
 		       (error "Eukleides requires a \":file\" header argument")))
-	 (cmdline (cdr (assoc :cmdline params)))
+	 (cmdline (cdr (assq :cmdline params)))
 	 (in-file (org-babel-temp-file "eukleides-"))
-	 (java (or (cdr (assoc :java params)) ""))
+	 (java (or (cdr (assq :java params)) ""))
 	 (cmd (if (not org-eukleides-path)
 		  (error "`org-eukleides-path' is not set")
 		(concat (expand-file-name org-eukleides-path)

+ 4 - 4
contrib/lisp/ob-fomus.el

@@ -64,10 +64,10 @@
 (defun org-babel-execute:fomus (body params)
   "Execute a block of Fomus code with org-babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((result-params (cdr (assoc :result-params params)))
-	 (out-file (cdr (assoc :file params)))
-	 (cmdline (cdr (assoc :cmdline params)))
-	 (cmd (or (cdr (assoc :cmd params)) "fomus"))
+  (let* ((result-params (cdr (assq :result-params params)))
+	 (out-file (cdr (assq :file params)))
+	 (cmdline (cdr (assq :cmdline params)))
+	 (cmd (or (cdr (assq :cmd params)) "fomus"))
 	 (in-file (org-babel-temp-file "fomus-" ".fms")))
     (with-temp-file in-file
       (insert (org-babel-expand-body:fomus body params)))

+ 13 - 13
contrib/lisp/ob-julia.el

@@ -61,7 +61,7 @@
 
 (defvar ess-local-process-name) ; dynamically scoped
 (defun org-babel-edit-prep:julia (info)
-  (let ((session (cdr (assoc :session (nth 2 info)))))
+  (let ((session (cdr (assq :session (nth 2 info)))))
     (when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
       (save-match-data (org-babel-julia-initiate-session session nil)))))
 
@@ -82,12 +82,12 @@
   "Execute a block of julia code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-params (cdr (assoc :result-params params)))
-	   (result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assq :result-params params)))
+	   (result-type (cdr (assq :result-type params)))
            (session (org-babel-julia-initiate-session
-		     (cdr (assoc :session params)) params))
-	   (colnames-p (cdr (assoc :colnames params)))
-	   (rownames-p (cdr (assoc :rownames params)))
+		     (cdr (assq :session params)) params))
+	   (colnames-p (cdr (assq :colnames params)))
+	   (rownames-p (cdr (assq :rownames params)))
 	   (graphics-file (org-babel-julia-graphical-output-file params))
 	   (full-body (org-babel-expand-body:julia body params graphics-file))
 	   (result
@@ -95,10 +95,10 @@ This function is called by `org-babel-execute-src-block'."
 	     session full-body result-type result-params
 	     (or (equal "yes" colnames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :colname-names params)) colnames-p))
+		  (cdr (assq :colname-names params)) colnames-p))
 	     (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :rowname-names params)) rownames-p)))))
+		  (cdr (assq :rowname-names params)) rownames-p)))))
       (if graphics-file nil result))))
 
 (defun org-babel-prep-session:julia (session params)
@@ -129,15 +129,15 @@ This function is called by `org-babel-execute-src-block'."
      (lambda (pair)
        (org-babel-julia-assign-elisp
 	(car pair) (cdr pair)
-	(equal "yes" (cdr (assoc :colnames params)))
-	(equal "yes" (cdr (assoc :rownames params)))))
+	(equal "yes" (cdr (assq :colnames params)))
+	(equal "yes" (cdr (assq :rownames params)))))
      (mapcar
       (lambda (i)
 	(cons (car (nth i vars))
 	      (org-babel-reassemble-table
 	       (cdr (nth i vars))
-	       (cdr (nth i (cdr (assoc :colname-names params))))
-	       (cdr (nth i (cdr (assoc :rowname-names params)))))))
+	       (cdr (nth i (cdr (assq :colname-names params))))
+	       (cdr (nth i (cdr (assq :rowname-names params)))))))
       (org-number-sequence 0 (1- (length vars)))))))
 
 (defun org-babel-julia-quote-csv-field (s)
@@ -178,7 +178,7 @@ This function is called by `org-babel-execute-src-block'."
     (let ((session (or session "*julia*"))
 	  (ess-ask-for-ess-directory
 	   (and (and (boundp 'ess-ask-for-ess-directory) ess-ask-for-ess-directory)
-		(not (cdr (assoc :dir params))))))
+		(not (cdr (assq :dir params))))))
       (if (org-babel-comint-buffer-livep session)
 	  session
 	(save-window-excursion

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

@@ -46,11 +46,11 @@
 (defun org-babel-execute:mathematica (body params)
   "Execute a block of Mathematica code with org-babel.  This function is
 called by `org-babel-execute-src-block'"
-  (let* ((result-params (cdr (assoc :result-params params)))
+  (let* ((result-params (cdr (assq :result-params params)))
 	 (full-body (org-babel-expand-body:mathematica body params))
 	 (tmp-script-file (org-babel-temp-file "mathematica-"))
 	 (cmd org-babel-mathematica-command))
-    ;; actually execute the source-code block 
+    ;; actually execute the source-code block
     (with-temp-file tmp-script-file (insert full-body))
     ;; (with-temp-file "/tmp/dbg" (insert full-body))
     ((lambda (raw)
@@ -79,4 +79,3 @@ specifying a variable of the same value."
     (format "%S" var)))
 
 (provide 'ob-mathematica)
-

+ 2 - 2
contrib/lisp/ob-mathomatic.el

@@ -85,9 +85,9 @@
   "Execute a block of Mathomatic entries with org-babel.  This function is
 called by `org-babel-execute-src-block'."
   (message "executing Mathomatic source code block")
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
+  (let ((result-params (split-string (or (cdr (assq :results params)) "")))
 	(result
-	 (let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
+	 (let* ((cmdline (or (cdr (assq :cmdline params)) ""))
 		(in-file (org-babel-temp-file "mathomatic-" ".math"))
 		(cmd (format "%s -t -c -q  %s %s"
 			     org-babel-mathomatic-command in-file cmdline)))

+ 5 - 5
contrib/lisp/ob-oz.el

@@ -214,7 +214,7 @@ StartOzServer.oz is located.")
 (defun org-babel-execute:oz (body params)
   "Execute a block of Oz code with org-babel.  This function is
 called by `org-babel-execute-src-block' via multiple-value-bind."
-  (let* ((result-params (cdr (assoc :result-params params)))
+  (let* ((result-params (cdr (assq :result-params params)))
 	 (full-body (org-babel-expand-body:oz body params))
 	 (wait-time (plist-get params :wait-time)))
     ;; actually execute the source-code block
@@ -227,10 +227,10 @@ called by `org-babel-execute-src-block' via multiple-value-bind."
        (message "Org-babel: executing Oz expression")
        (oz-send-string-expression full-body (or wait-time 1)))
       (t (error "either 'output' or 'results' must be members of :results")))
-     (org-babel-pick-name (cdr (assoc :colname-names params))
-			  (cdr (assoc :colnames params)))
-     (org-babel-pick-name (cdr (assoc :roname-names params))
-			  (cdr (assoc :rownames params))))))
+     (org-babel-pick-name (cdr (assq :colname-names params))
+			  (cdr (assq :colnames params)))
+     (org-babel-pick-name (cdr (assq :roname-names params))
+			  (cdr (assq :rownames params))))))
 
 ;; This function should be used to assign any variables in params in
 ;; the context of the session environment.

+ 13 - 13
contrib/lisp/ob-stata.el

@@ -76,7 +76,7 @@
 
 (defvar ess-local-process-name) ; dynamically scoped
 (defun org-babel-edit-prep:stata (info)
-  (let ((session (cdr (assoc :session (nth 2 info)))))
+  (let ((session (cdr (assq :session (nth 2 info)))))
     (when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
       (save-match-data (org-babel-stata-initiate-session session nil)))))
 
@@ -97,12 +97,12 @@
   "Execute a block of stata code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-params (cdr (assoc :result-params params)))
-	   (result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assq :result-params params)))
+	   (result-type (cdr (assq :result-type params)))
            (session (org-babel-stata-initiate-session
-		     (cdr (assoc :session params)) params))
-	   (colnames-p (cdr (assoc :colnames params)))
-	   (rownames-p (cdr (assoc :rownames params)))
+		     (cdr (assq :session params)) params))
+	   (colnames-p (cdr (assq :colnames params)))
+	   (rownames-p (cdr (assq :rownames params)))
 	   (graphics-file (org-babel-stata-graphical-output-file params))
 	   (full-body (org-babel-expand-body:stata body params graphics-file))
 	   (result
@@ -110,10 +110,10 @@ This function is called by `org-babel-execute-src-block'."
 	     session full-body result-type result-params
 	     (or (equal "yes" colnames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :colname-names params)) colnames-p))
+		  (cdr (assq :colname-names params)) colnames-p))
 	     (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assoc :rowname-names params)) rownames-p)))))
+		  (cdr (assq :rowname-names params)) rownames-p)))))
       (if graphics-file nil result))))
 
 (defun org-babel-prep-session:stata (session params)
@@ -144,15 +144,15 @@ This function is called by `org-babel-execute-src-block'."
      (lambda (pair)
        (org-babel-stata-assign-elisp
 	(car pair) (cdr pair)
-	(equal "yes" (cdr (assoc :colnames params)))
-	(equal "yes" (cdr (assoc :rownames params)))))
+	(equal "yes" (cdr (assq :colnames params)))
+	(equal "yes" (cdr (assq :rownames params)))))
      (mapcar
       (lambda (i)
 	(cons (car (nth i vars))
 	      (org-babel-reassemble-table
 	       (cdr (nth i vars))
-	       (cdr (nth i (cdr (assoc :colname-names params))))
-	       (cdr (nth i (cdr (assoc :rowname-names params)))))))
+	       (cdr (nth i (cdr (assq :colname-names params))))
+	       (cdr (nth i (cdr (assq :rowname-names params)))))))
       (org-number-sequence 0 (1- (length vars)))))))
 
 (defun org-babel-stata-quote-csv-field (s)
@@ -193,7 +193,7 @@ This function is called by `org-babel-execute-src-block'."
     (let ((session (or session "*stata*"))
 	  (ess-ask-for-ess-directory
 	   (and (and (boundp 'ess-ask-for-ess-directory) ess-ask-for-ess-directory)
-		(not (cdr (assoc :dir params))))))
+		(not (cdr (assq :dir params))))))
       (if (org-babel-comint-buffer-livep session)
 	  session
 	(save-window-excursion

+ 5 - 5
contrib/lisp/ob-tcl.el

@@ -47,18 +47,18 @@
 (defun org-babel-execute:tcl (body params)
   "Execute a block of Tcl code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((session (cdr (assoc :session params)))
-         (result-params (cdr (assoc :result-params params)))
-         (result-type (cdr (assoc :result-type params)))
+  (let* ((session (cdr (assq :session params)))
+         (result-params (cdr (assq :result-params params)))
+         (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:tcl params)))
 	(session (org-babel-tcl-initiate-session session)))
     (org-babel-reassemble-table
      (org-babel-tcl-evaluate session full-body result-type)
      (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+      (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
      (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+      (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
 
 (defun org-babel-prep-session:tcl (session params)
   "Prepare SESSION according to the header arguments in PARAMS."

+ 8 - 8
contrib/lisp/ob-vbnet.el

@@ -48,30 +48,30 @@ or an absolute path name, like /usr/local/bin/vbnc
 parameters may be used, like vbnc /warnaserror+"
   :group 'org-babel
   :version "24.3"
-  :type 'string) 
+  :type 'string)
 
 (defun org-babel-execute:vbnet (body params)
   (let* ((full-body (org-babel-expand-body:generic body params))
-	 (cmpflag (or (cdr (assoc :cmpflag params)) ""))
-	 (cmdline (or (cdr (assoc :cmdline params)) ""))
+	 (cmpflag (or (cdr (assq :cmpflag params)) ""))
+	 (cmdline (or (cdr (assq :cmdline params)) ""))
 	 (src-file (org-babel-temp-file "vbnet-src-" ".vb"))
 	 (exe-file (concat (file-name-sans-extension src-file)  ".exe"))
-	 (compile 
+	 (compile
 	  (progn (with-temp-file  src-file (insert full-body))
-		 (org-babel-eval 
+		 (org-babel-eval
 		  (concat org-babel-vbnet-compiler " " cmpflag " " src-file)
 		  ""))))
     (let ((results (org-babel-eval (concat org-babel-vbnet-command " " cmdline " " exe-file) "")))
       (org-babel-reassemble-table
-       (org-babel-result-cond (cdr (assoc :result-params params))
+       (org-babel-result-cond (cdr (assq :result-params params))
 	 (org-babel-read results)
          (let ((tmp-file (org-babel-temp-file "c-")))
            (with-temp-file tmp-file (insert results))
            (org-babel-import-elisp-from-file tmp-file)))
        (org-babel-pick-name
-        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+        (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
        (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
+        (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
 
 (defun org-babel-prep-session:vbnet (session params)
   "Return an error because vbnet does not support sessions."

+ 4 - 4
contrib/lisp/org-bibtex-extras.el

@@ -113,12 +113,12 @@ For example, to point to your `obe-bibtex-file' use the following.
 	(add (remove-duplicates (col field) :test #'string=)))
       ;; build the links in the graph
       (dolist (citation meta)
-        (let ((dest (id (cdr (assoc :title citation)))))
-          (dolist (author (mapcar #'id (cdr (assoc :authors citation))))
+        (let ((dest (id (cdr (assq :title citation)))))
+          (dolist (author (mapcar #'id (cdr (assq :authors citation))))
             (when author (push (cons author dest) links)))
-          (let ((jid (id (cdr (assoc :journal citation)))))
+          (let ((jid (id (cdr (assq :journal citation)))))
             (when jid (push (cons jid dest) links)))
-          (let ((cid (id (cdr (assoc :category citation)))))
+          (let ((cid (id (cdr (assq :category citation)))))
             (when cid (push (cons cid dest) links)))))
       ;; build the json string
       (format "{\"nodes\":[%s],\"links\":[%s]}"

File diff suppressed because it is too large
+ 100 - 100
contrib/lisp/org-index.el


+ 4 - 4
testing/lisp/test-ob.el

@@ -128,7 +128,7 @@ should still return the link."
 (ert-deftest test-ob/get-src-block-info-tangle ()
   (org-test-at-marker nil org-test-file-ob-anchor
     (let ((info (org-babel-get-src-block-info)))
-      (should (string= "no" (cdr (assoc :tangle (nth 2 info))))))))
+      (should (string= "no" (cdr (assq :tangle (nth 2 info))))))))
 
 (ert-deftest test-ob/elisp-in-header-arguments ()
   "Test execution of elisp forms in header arguments."
@@ -204,9 +204,9 @@ should still return the link."
       (should (equal "example-lang" (nth 0 info)))
       (should (string= "the body" (org-trim (nth 1 info))))
       (should-not (member '(:session\ \ \ \ ) params))
-      (should (equal '(:session) (assoc :session params)))
-      (should (equal '(:result-type . output) (assoc :result-type params)))
-      (should (equal '(num . 9) (cdr (assoc :var params)))))))
+      (should (equal '(:session) (assq :session params)))
+      (should (equal '(:result-type . output) (assq :result-type params)))
+      (should (equal '(num . 9) (cdr (assq :var params)))))))
 
 (ert-deftest test-ob/parse-header-args2 ()
   (org-test-with-temp-text-in-file "