summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-11-28 23:59:21 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-11-28 23:59:21 +0100
commit819b2a1a3d7d74787b45007929c2cd0e80be481e (patch)
tree99d47c807965fa4d58b5a5ddc9a7de4b6d6cdec6
parente92732efd0734e5e46ffb72107282751d779fbbf (diff)
parentb4b2809eb17f301ae59d0865840d45b3f3ff9f3e (diff)
downloadorg-mode-819b2a1a3d7d74787b45007929c2cd0e80be481e.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/ob-core.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 1af695e..d76f664 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1765,15 +1765,17 @@ to `org-babel-named-src-block-regexp'."
(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 (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)))
+ (with-current-buffer (if file (find-file-noselect file) (current-buffer))
+ (org-with-point-at 1
+ (let ((regexp "^[ \t]*#\\+begin_src ")
+ (case-fold-search t)
+ (names nil))
+ (while (re-search-forward regexp nil t)
+ (let ((element (org-element-at-point)))
+ (when (eq 'src-block (org-element-type element))
+ (let ((name (org-element-property :name element)))
+ (when name (push name names))))))
+ names))))
;;;###autoload
(defun org-babel-goto-named-result (name)