From 4a214a0647ee8ceb0ee413a7d57d27b303056ab5 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Date: Sun, 21 Dec 2014 22:14:26 +0100
Subject: [PATCH] `org-outline-level' ignores narrowing

* lisp/org.el (org-outline-level): Ignore narrowing.  Refactor to be
  slightly faster.
---
 lisp/org.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 92ee18b34..088f8260b 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6238,11 +6238,11 @@ done, nil otherwise."
   "Compute the outline level of the heading at point.
 If this is called at a normal headline, the level is the number of stars.
 Use `org-reduced-level' to remove the effect of `org-odd-levels'."
-  (save-excursion
-    (if (not (ignore-errors (org-back-to-heading t)))
-	0
-      (looking-at org-outline-regexp)
-      (1- (- (match-end 0) (match-beginning 0))))))
+  (org-with-wide-buffer
+   (end-of-line)
+   (if (re-search-backward org-outline-regexp-bol nil t)
+       (1- (- (match-end 0) (match-beginning 0)))
+     0)))
 
 (defvar org-font-lock-keywords nil)