From 398dbd91ed8082291e21bc15457be48a9010638f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 27 Dec 2013 15:41:41 +0100 Subject: [PATCH] org-element: Fix `org-element-at-point' shortcut * lisp/org-element.el (org-element-at-point): Correctly move from blank line to blank line in order to find a known element above. --- lisp/org-element.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index fb2eecd0d..8c368ae56 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5219,16 +5219,15 @@ first row." ;; position. Give up after 10 tries or when we hit ;; a headline (or beginning of buffer). (beginning-of-line) - (skip-chars-backward " \r\t\n") (dotimes (i 10) + (skip-chars-backward " \r\t\n") (cond ((not (re-search-backward "^\\(?:\\*+ \\|[ \t]*$\\)" nil t)) (throw 'loop (goto-char (point-min)))) ((/= (char-after) ?*) (when (bobp) (throw 'loop nil)) - ;; An element cannot start at a headline, so check - ;; first non-blank line below. - (skip-chars-forward " \r\t\n" origin) - (beginning-of-line)) + ;; An element cannot start at a blank line, so + ;; check line below. + (forward-line)) ((org-with-limited-levels (org-at-heading-p)) ;; Tough luck: we're back at a headline above. ;; Move to beginning of section.