Browse Source

babel: eliminated compiler warning about `org-babel-get-src-block-info'

Eric Schulte 15 years ago
parent
commit
a86734f526
7 changed files with 65 additions and 58 deletions
  1. 4 4
      Makefile
  2. 2 1
      lisp/babel/ob-exp.el
  3. 7 2
      lisp/babel/ob-init.el
  4. 2 0
      lisp/babel/ob-keys.el
  5. 2 0
      lisp/babel/ob-ref.el
  6. 2 0
      lisp/babel/ob-table.el
  7. 46 51
      lisp/babel/ob.el

+ 4 - 4
Makefile

@@ -116,14 +116,14 @@ LISPF      = 	org.el				\
 		org-w3m.el              	\
 		org-wl.el			\
 		org-xoxo.el			\
-		babel/ob-comint.el		\
 		babel/ob.el			\
-		babel/ob-exp.el			\
-		babel/ob-keys.el		\
+		babel/ob-table.el		\
 		babel/ob-lob.el			\
 		babel/ob-ref.el			\
-		babel/ob-table.el		\
+		babel/ob-exp.el			\
 		babel/ob-tangle.el		\
+		babel/ob-comint.el		\
+		babel/ob-keys.el		\
 		babel/langs/ob-emacs-lisp.el	\
 		babel/langs/ob-sh.el
 

+ 2 - 1
lisp/babel/ob-exp.el

@@ -34,11 +34,12 @@
 (eval-when-compile
   (require 'cl))
 
+(declare-function org-babel-get-src-block-info "ob" (&optional hvo))
+
 (defvar obe-marker nil)
 (defvar org-current-export-file)
 (defvar org-babel-lob-one-liner-regexp)
 (defvar org-babel-ref-split-regexp)
-(declare-function org-babel-get-src-block-info "ob" (&optional hvo))
 (declare-function org-babel-lob-get-info "ob-lob" ())
 (declare-function org-babel-ref-literal "ob-ref" (ref))
 

+ 7 - 2
lisp/babel/ob-init.el

@@ -1,11 +1,16 @@
 ;;; ob-init.el --- working with code blocks in org-mode
+;; add the langs/ directory to the load path
+(add-to-list 'load-path (expand-file-name
+			 "langs"
+			 (file-name-directory (or (buffer-file-name)
+						  load-file-name))))
 (require 'ob)
+(require 'ob-table)
+(require 'ob-lob)
 (require 'ob-ref)
 (require 'ob-exp)
 (require 'ob-tangle)
-(require 'ob-lob)
 (require 'ob-comint)
-(require 'ob-table)
 (require 'ob-keys)
 (require 'ob-sh)
 (require 'ob-emacs-lisp)

+ 2 - 0
lisp/babel/ob-keys.el

@@ -34,6 +34,8 @@
 ;;; Code:
 (require 'ob)
 
+(declare-function org-babel-get-src-block-info "ob" (&optional hvo))
+
 (defvar org-babel-key-prefix "\C-c\C-v"
   "The `org-babel-key-prefix' variable holds the key prefix
 behind which all org-babel interactive key-binding are placed.

+ 2 - 0
lisp/babel/ob-ref.el

@@ -56,6 +56,8 @@
 (eval-when-compile
   (require 'cl))
 
+(declare-function org-babel-get-src-block-info "ob" (&optional hvo))
+
 (defun org-babel-ref-variables (params)
   "Takes a parameter alist, and return an alist of variable
 names, and the emacs-lisp representation of the related value."

+ 2 - 0
lisp/babel/ob-table.el

@@ -55,6 +55,8 @@
 ;;; Code:
 (require 'ob)
 
+(declare-function org-babel-get-src-block-info "ob" (&optional hvo))
+
 (defun org-babel-table-truncate-at-newline (string)
   "If STRING ends in a newline character, then remove the newline
 character and replace it with ellipses."

+ 46 - 51
lisp/babel/ob.el

@@ -49,11 +49,52 @@
 (declare-function tramp-file-name-user "tramp" (vec))
 (declare-function tramp-file-name-host "tramp" (vec))
 
-;; add the langs/ directory to the load path
-(add-to-list 'load-path (expand-file-name
-			 "langs"
-			 (file-name-directory (or (buffer-file-name)
-						  load-file-name))))
+(defun org-babel-get-src-block-info (&optional header-vars-only)
+  "Get information of the current source block.
+
+Returns a list
+ (language body header-arguments-alist switches name function-args indent).
+Unless HEADER-VARS-ONLY is non-nil, any variable
+references provided in 'function call style' (i.e. in a
+parenthesised argument list following the src block name) are
+added to the header-arguments-alist."
+  (let ((case-fold-search t) head info args indent)
+    (if (setq head (org-babel-where-is-src-block-head))
+        (save-excursion
+	  (goto-char head)
+	  (setq info (org-babel-parse-src-block-match))
+	  (setq indent (car (last info)))
+	  (setq info (butlast info))
+	  (forward-line -1)
+	  (if (looking-at
+	       (concat org-babel-source-name-regexp
+		       "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)"))
+	      (progn
+		(setq info (append info (list (org-babel-clean-text-properties
+					       (match-string 2)))))
+		;; Note that e.g. "name()" and "name( )" result in
+		;; ((:var . "")).  We maintain that behaviour, and the
+		;; resulting non-nil sixth element is relied upon in
+		;; org-babel-exp-code to detect a functional-style
+		;; block in those cases. However, "name" without any
+		;; parentheses would result in the same thing, so we
+		;; explicitly avoid that.
+		(if (setq args (match-string 4))
+		    (setq info
+			  (append info (list
+					(mapcar
+					 (lambda (ref) (cons :var ref))
+					 (org-babel-ref-split-args args))))))
+		(unless header-vars-only
+		  (setf (nth 2 info)
+			(org-babel-merge-params (nth 5 info) (nth 2 info)))))
+	    (setq info (append info (list nil nil))))
+	  (append info (list indent)))
+      (if (save-excursion ;; inline source block
+            (re-search-backward "[ \f\t\n\r\v]" nil t)
+            (looking-at org-babel-inline-src-block-regexp))
+          (org-babel-parse-inline-src-block-match)
+        nil))))
 
 (defun org-babel-execute-src-block-maybe ()
   "Detect if this is context for a org-babel src-block and if so
@@ -427,52 +468,6 @@ the current subtree."
       (org-babel-execute-buffer)
       (widen))))
 
-(defun org-babel-get-src-block-info (&optional header-vars-only)
-  "Get information of the current source block.
-Returns a list
- (language body header-arguments-alist switches name function-args indent).
-Unless HEADER-VARS-ONLY is non-nil, any variable
-references provided in 'function call style' (i.e. in a
-parenthesised argument list following the src block name) are
-added to the header-arguments-alist."
-  (let ((case-fold-search t) head info args indent)
-    (if (setq head (org-babel-where-is-src-block-head))
-        (save-excursion
-	  (goto-char head)
-	  (setq info (org-babel-parse-src-block-match))
-	  (setq indent (car (last info)))
-	  (setq info (butlast info))
-	  (forward-line -1)
-	  (if (looking-at
-	       (concat org-babel-source-name-regexp
-		       "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)"))
-	      (progn
-		(setq info (append info (list (org-babel-clean-text-properties
-					       (match-string 2)))))
-		;; Note that e.g. "name()" and "name( )" result in
-		;; ((:var . "")).  We maintain that behaviour, and the
-		;; resulting non-nil sixth element is relied upon in
-		;; org-babel-exp-code to detect a functional-style
-		;; block in those cases. However, "name" without any
-		;; parentheses would result in the same thing, so we
-		;; explicitly avoid that.
-		(if (setq args (match-string 4))
-		    (setq info
-			  (append info (list
-					(mapcar
-					 (lambda (ref) (cons :var ref))
-					 (org-babel-ref-split-args args))))))
-		(unless header-vars-only
-		  (setf (nth 2 info)
-			(org-babel-merge-params (nth 5 info) (nth 2 info)))))
-	    (setq info (append info (list nil nil))))
-	  (append info (list indent)))
-      (if (save-excursion ;; inline source block
-            (re-search-backward "[ \f\t\n\r\v]" nil t)
-            (looking-at org-babel-inline-src-block-regexp))
-          (org-babel-parse-inline-src-block-match)
-        nil)))) ;; indicate that no source block was found
-
 (defun org-babel-sha1-hash (&optional info)
   "Generate an sha1 hash based on the value of info."
   (interactive)