From 4aeb62233682bcd4c9aa4f941e39124e0fd71ebc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 1 May 2015 13:55:04 +0200 Subject: [PATCH] ob-core: Use `org-next-block' * lisp/ob-core.el (org-babel-find-named-block): (org-babel-src-block-names): Use `org-next-block'. --- lisp/ob-core.el | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index c9fa5d797..c3963b42c 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1759,23 +1759,22 @@ If the point is not on a source block then return nil." (defun org-babel-find-named-block (name) "Find a named source-code block. Return the location of the source block identified by source -NAME, or nil if no such block exists. Set match data according to -org-babel-named-src-block-regexp." +NAME, or nil if no such block exists. Set match data according +to `org-babel-named-src-block-regexp'." (save-excursion - (let ((case-fold-search t) - (regexp (org-babel-named-src-block-regexp-for-name name)) msg) - (goto-char (point-min)) - (when (or (re-search-forward regexp nil t) - (re-search-backward regexp nil t)) - (match-beginning 0))))) + (goto-char (point-min)) + (ignore-errors + (org-next-block 1 nil (org-babel-named-src-block-regexp-for-name name))))) (defun org-babel-src-block-names (&optional file) "Returns the names of source blocks in FILE or the current buffer." + (when file (find-file file)) (save-excursion - (when file (find-file file)) (goto-char (point-min)) - (let ((case-fold-search t) names) - (while (re-search-forward org-babel-src-name-w-name-regexp nil t) - (setq names (cons (match-string 3) names))) + (goto-char (point-min)) + (let (names) + (while (ignore-errors + (org-next-block 1 nil org-babel-src-name-w-name-regexp)) + (push (match-string 3) names)) names))) ;;;###autoload