diff --git a/lisp/ob.el b/lisp/ob.el index 9c0338302..f7d705041 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1097,7 +1097,9 @@ buffer or nil if no such result exists." With optional prefix argument ARG, jump forward ARG many source blocks." (interactive "P") (when (looking-at org-babel-src-block-regexp) (forward-char 1)) - (re-search-forward org-babel-src-block-regexp nil nil (or arg 1)) + (condition-case nil + (re-search-forward org-babel-src-block-regexp nil nil (or arg 1)) + (error (error "No further code blocks"))) (goto-char (match-beginning 0)) (org-show-context)) ;;;###autoload @@ -1105,7 +1107,9 @@ With optional prefix argument ARG, jump forward ARG many source blocks." "Jump to the previous source block. With optional prefix argument ARG, jump backward ARG many source blocks." (interactive "P") - (re-search-backward org-babel-src-block-regexp nil nil (or arg 1)) + (condition-case nil + (re-search-backward org-babel-src-block-regexp nil nil (or arg 1)) + (error (error "No previous code blocks"))) (goto-char (match-beginning 0)) (org-show-context)) (defvar org-babel-lob-one-liner-regexp)