Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2017-11-28 23:59:21 +01:00
commit 819b2a1a3d
1 changed files with 11 additions and 9 deletions

View File

@ -1765,15 +1765,17 @@ to `org-babel-named-src-block-regexp'."
(defun org-babel-src-block-names (&optional file) (defun org-babel-src-block-names (&optional file)
"Returns the names of source blocks in FILE or the current buffer." "Returns the names of source blocks in FILE or the current buffer."
(when file (find-file file)) (with-current-buffer (if file (find-file-noselect file) (current-buffer))
(save-excursion (org-with-point-at 1
(goto-char (point-min)) (let ((regexp "^[ \t]*#\\+begin_src ")
(let* ((re (org-babel-named-src-block-regexp-for-name)) (case-fold-search t)
(names (and (looking-at re) (names nil))
(list (match-string-no-properties 9))))) (while (re-search-forward regexp nil t)
(while (ignore-errors (org-next-block 1 nil re)) (let ((element (org-element-at-point)))
(push (match-string-no-properties 9) names)) (when (eq 'src-block (org-element-type element))
names))) (let ((name (org-element-property :name element)))
(when name (push name names))))))
names))))
;;;###autoload ;;;###autoload
(defun org-babel-goto-named-result (name) (defun org-babel-goto-named-result (name)