Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2017-08-13 19:02:27 +02:00
commit 548b07741b
1 changed files with 8 additions and 4 deletions

View File

@ -1759,16 +1759,20 @@ NAME, or nil if no such block exists. Set match data according
to `org-babel-named-src-block-regexp'."
(save-excursion
(goto-char (point-min))
(ignore-errors
(org-next-block 1 nil (org-babel-named-src-block-regexp-for-name name)))))
(let ((regexp (org-babel-named-src-block-regexp-for-name name)))
(or (and (looking-at regexp)
(progn (goto-char (match-beginning 1))
(line-beginning-position)))
(ignore-errors (org-next-block 1 nil))))))
(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
(goto-char (point-min))
(let ((re (org-babel-named-src-block-regexp-for-name))
names)
(let* ((re (org-babel-named-src-block-regexp-for-name))
(names (and (looking-at re)
(list (match-string-no-properties 9)))))
(while (ignore-errors (org-next-block 1 nil re))
(push (match-string-no-properties 9) names))
names)))