Browse Source

ob: better error messages when searches for code blocks fail

* lisp/ob.el (org-babel-next-src-block): now raising more informative
  error when no further code blocks can be found
  (org-babel-previous-src-block): now raising more informative error
  when no previous code blocks can be found
Eric Schulte 10 years ago
parent
commit
e92a4b0813
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lisp/ob.el

+ 6 - 2
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)