summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-04-14 11:21:23 +0200
committerBastien Guerry <bzg@altern.org>2013-04-14 11:46:45 +0200
commit0ffeb8709e2d128e0f18d1c5fafcf970dd453c01 (patch)
treee9c8c39e61369cf859c7bfffe1971d8b3a0f98ef
parent7c048fd8861483b4d1c35344e619339f3d04701e (diff)
downloadorg-mode-0ffeb8709e2d128e0f18d1c5fafcf970dd453c01.tar.gz
org.el (org-adaptive-fill-function, org-fill-paragraph): Throw a useful error message
* org.el (org-adaptive-fill-function, org-fill-paragraph): Throw a useful error message when parse an element fails in the current buffer. This can happen for example in a `message-mode' buffer when using orgstruct-mode. If you insert a line like: SCHEDULED: <2013-04-13 Sat> is blablabla then org-element-at-point will fail and the user will get an error he cannot understand.
-rw-r--r--lisp/org.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index de8bd07..9b4f444 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -22063,8 +22063,11 @@ meant to be filled."
(throw 'exit (make-string (length (match-string 0)) ? ))))))
(org-with-wide-buffer
(let* ((p (line-beginning-position))
- (element (save-excursion (beginning-of-line)
- (org-element-at-point)))
+ (element (save-excursion
+ (beginning-of-line)
+ (or (ignore-errors (org-element-at-point))
+ (user-error "An element cannot be parsed line %d"
+ (line-number-at-pos (point))))))
(type (org-element-type element))
(post-affiliated (org-element-property :post-affiliated element)))
(unless (and post-affiliated (< p post-affiliated))
@@ -22134,7 +22137,11 @@ a footnote definition, try to fill the first paragraph within."
(with-syntax-table org-mode-transpose-word-syntax-table
;; Move to end of line in order to get the first paragraph
;; within a plain list or a footnote definition.
- (let ((element (save-excursion (end-of-line) (org-element-at-point))))
+ (let ((element (save-excursion
+ (end-of-line)
+ (or (ignore-errors (org-element-at-point))
+ (user-error "An element cannot be parsed line %d"
+ (line-number-at-pos (point)))))))
;; First check if point is in a blank line at the beginning of
;; the buffer. In that case, ignore filling.
(case (org-element-type element)