summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-02-15 16:48:40 +0100
committerBastien Guerry <bzg@altern.org>2013-02-15 16:48:40 +0100
commit1298b6468a7172923132e665b9870ec2a5699697 (patch)
tree418eab4578bf7011e84fca1954c53604a425a5d5
parent7306e04193a3e3921b1e5ca40517f4eddd9ee45f (diff)
parent0b6a2e2416b0acc28469661d7013f92f82a34267 (diff)
downloadorg-mode-1298b6468a7172923132e665b9870ec2a5699697.tar.gz
Merge branch 'master' of orgmode.org:org-mode
-rw-r--r--lisp/org-element.el48
-rw-r--r--lisp/org.el15
2 files changed, 35 insertions, 28 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f4eb35d..f17273c 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4622,26 +4622,40 @@ first element of current section."
(list (org-element-headline-parser (point-max) t))))
;; Otherwise move at the beginning of the section containing
;; point.
- (let ((origin (point))
- (end (save-excursion
- (org-with-limited-levels (outline-next-heading)) (point)))
- element type special-flag trail struct prevs parent)
- (org-with-limited-levels
- (if (org-before-first-heading-p) (goto-char (point-min))
- (org-back-to-heading)
- (forward-line)))
- (org-skip-whitespace)
- (beginning-of-line)
- ;; Parse successively each element, skipping those ending
- ;; before original position.
- (catch 'exit
- (while t
- (setq element
+ (catch 'exit
+ (let ((origin (point))
+ (end (save-excursion
+ (org-with-limited-levels (outline-next-heading)) (point)))
+ element type special-flag trail struct prevs parent)
+ (org-with-limited-levels
+ (if (org-before-first-heading-p)
+ ;; In empty lines at buffer's beginning, return nil.
+ (progn (goto-char (point-min))
+ (org-skip-whitespace)
+ (when (or (eobp) (> (line-beginning-position) origin))
+ (throw 'exit nil)))
+ (org-back-to-heading)
+ (forward-line)
+ (org-skip-whitespace)
+ (when (> (line-beginning-position) origin)
+ ;; In blank lines just after the headline, point still
+ ;; belongs to the headline.
+ (throw 'exit
+ (progn (org-back-to-heading)
+ (if (not keep-trail)
+ (org-element-headline-parser (point-max) t)
+ (list (org-element-headline-parser
+ (point-max) t))))))))
+ (beginning-of-line)
+ ;; Parse successively each element, skipping those ending
+ ;; before original position.
+ (while t
+ (setq element
(org-element--current-element end 'element special-flag struct)
- type (car element))
+ type (car element))
(org-element-put-property element :parent parent)
(when keep-trail (push element trail))
- (cond
+ (cond
;; 1. Skip any element ending before point. Also skip
;; element ending at point when we're sure that another
;; element has started.
diff --git a/lisp/org.el b/lisp/org.el
index 7eb92ec..c531d3c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19652,13 +19652,8 @@ This command does many different things, depending on context:
((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
(t
(let* ((context (org-element-context)) (type (org-element-type context)))
- ;; Test if point is within blanks at the end of an element.
- (if (save-excursion
- (or (not context)
- (beginning-of-line)
- (and (looking-at "[ \t]*$")
- (skip-chars-forward " \r\t\n")
- (>= (point) (org-element-property :end context)))))
+ ;; Test if point is within a blank line.
+ (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
(user-error "C-c C-c can do nothing useful at this location"))
;; For convenience: at the first line of a paragraph on the
@@ -22241,10 +22236,8 @@ the cursor is already beyond the end of the headline."
((fboundp 'move-end-of-line) 'move-end-of-line)
(t 'end-of-line))))
(if (or (not special) arg) (call-interactively move-fun)
- (let* ((element (ignore-errors
- ;; Don't throw an error outside elements
- (save-excursion (beginning-of-line)
- (org-element-at-point))))
+ (let* ((element (save-excursion (beginning-of-line)
+ (org-element-at-point)))
(type (org-element-type element)))
(cond
((memq type '(headline inlinetask))