From 0ffeb8709e2d128e0f18d1c5fafcf970dd453c01 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 14 Apr 2013 11:21:23 +0200 Subject: [PATCH] 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. --- lisp/org.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index de8bd0706..9b4f444af 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) -- 2.11.4.GIT