1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

ob-core: Use `org-next-block'

* lisp/ob-core.el (org-babel-find-named-block):
(org-babel-src-block-names): Use `org-next-block'.
This commit is contained in:
Nicolas Goaziou 2015-05-01 13:55:04 +02:00
parent a4f4343110
commit 4aeb622336

View File

@ -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