Browse Source

Fix `org-up-heading-safe'

* lisp/org.el (org-up-heading-safe): Do not throw any error, as
  advertised in the docstring.
Nicolas Goaziou 10 years ago
parent
commit
9ba9f916e8
1 changed files with 5 additions and 8 deletions
  1. 5 8
      lisp/org.el

+ 5 - 8
lisp/org.el

@@ -23702,14 +23702,11 @@ headline found, or nil if no higher level is found.
 Also, this function will be a lot faster than `outline-up-heading',
 because it relies on stars being the outline starters.  This can really
 make a significant difference in outlines with very many siblings."
-  (let (start-level re)
-    (org-back-to-heading t)
-    (setq start-level (funcall outline-level))
-    (if (equal start-level 1)
-	nil
-      (setq re (concat "^\\*\\{1," (number-to-string (1- start-level)) "\\} "))
-      (if (re-search-backward re nil t)
-	  (funcall outline-level)))))
+  (when (ignore-errors (org-back-to-heading t))
+    (let ((level-up (1- (funcall outline-level))))
+      (and (> level-up 0)
+	   (re-search-backward (format "^\\*\\{1,%d\\} " level-up) nil t)
+	   (funcall outline-level)))))
 
 (defun org-first-sibling-p ()
   "Is this heading the first child of its parents?"