diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-28 23:57:18 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-28 23:57:18 +0100 |
commit | b4b2809eb17f301ae59d0865840d45b3f3ff9f3e (patch) | |
tree | 508fc6a10bbff2c931eea12e0db2c4423c043561 | |
parent | ebe9eb242363c0f424373bece2a275dcbf1e8749 (diff) | |
download | org-mode-b4b2809eb17f301ae59d0865840d45b3f3ff9f3e.tar.gz |
ob-core: Fix `org-babel-src-block-names'
* lisp/ob-core.el (org-babel-src-block-names): Do not change
visibility or windows when called.
-rw-r--r-- | lisp/ob-core.el | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 9f367f2..17aae68 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) |