From b5072890c38b386f3374800f58cc47ae7605db8e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 13 Jan 2015 17:18:12 +0100 Subject: [PATCH] Fix "Args out of range" when demarcating blocks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/ob-core.el (org-babel-demarcate-block): Return value from `org-babel-where-is-src-block-head' may be nil. Reported-by: Sébastien Vauban --- lisp/ob-core.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 061c7d7d5..892c3e3ba 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1860,12 +1860,13 @@ is created. In both cases if the region is demarcated and if the region is not active then the point is demarcated." (interactive "P") (let* ((info (org-babel-get-src-block-info 'light)) - (block (progn (org-babel-where-is-src-block-head) (match-string 0))) - (headers (progn (org-babel-where-is-src-block-head) (match-string 4))) + (start (org-babel-where-is-src-block-head)) + (block (and start (match-string 0))) + (headers (and start (match-string 4))) (stars (concat (make-string (or (org-current-level) 1) ?*) " ")) - lower-case-p) - (if (let (case-fold-search) (string-match "#\\+begin_src" block)) - (setq lower-case-p t)) + (lower-case-p (and block + (let (case-fold-search) + (org-string-match-p "#\\+begin_src" block))))) (if info (mapc (lambda (place) -- 2.11.4.GIT