Jelajahi Sumber

fixed two issues with noweb reference expansion

* lisp/ob.el (org-babel-expand-noweb-references): Only allow
  reference names which start and end with non-whitespace characters.
  Also, raise errors as appropriate given org-babel-noweb-error-langs.
Eric Schulte 13 tahun lalu
induk
melakukan
1bb2a3c23a
1 mengubah file dengan 4 tambahan dan 2 penghapusan
  1. 4 2
      lisp/ob.el

+ 4 - 2
lisp/ob.el

@@ -2150,7 +2150,8 @@ block but are passed literally to the \"example-block\"."
       (with-temp-buffer
       (with-temp-buffer
         (insert body) (goto-char (point-min))
         (insert body) (goto-char (point-min))
         (setq index (point))
         (setq index (point))
-        (while (and (re-search-forward "<<\\(.+?\\)>>" nil t))
+        (while (and (re-search-forward "<<\\([^ \t].+?[^ \t]\\|[^ \t]\\)>>"
+				       nil t))
           (save-match-data (setf source-name (match-string 1)))
           (save-match-data (setf source-name (match-string 1)))
           (save-match-data (setq evaluate (string-match "\(.*\)" source-name)))
           (save-match-data (setq evaluate (string-match "\(.*\)" source-name)))
           (save-match-data
           (save-match-data
@@ -2215,7 +2216,8 @@ block but are passed literally to the \"example-block\"."
 					     body)))
 					     body)))
 				(setq expansion
 				(setq expansion
 				      (cons sep (cons full expansion)))))))))
 				      (cons sep (cons full expansion)))))))))
-		    (mapconcat #'identity (nreverse (cdr expansion)) ""))
+		    (and expansion
+			 (mapconcat #'identity (nreverse (cdr expansion)) "")))
 		  ;; possibly raise an error if named block doesn't exist
 		  ;; possibly raise an error if named block doesn't exist
 		  (if (member lang org-babel-noweb-error-langs)
 		  (if (member lang org-babel-noweb-error-langs)
 		      (error "%s" (concat
 		      (error "%s" (concat