소스 검색

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.
Bastien Guerry 12 년 전
부모
커밋
0ffeb8709e
1개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 3
      lisp/org.el

+ 10 - 3
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)