浏览代码

org-element: Fix error when parsing a line-break

* contrib/lisp/org-element.el (org-element-line-break-parser)
(org-element-line-break-interpreter): Line-break object ends where the
line ends.  It doesn't contain the next newline character.
(org-element-parse-objects): Refactoring.
Nicolas Goaziou 12 年之前
父节点
当前提交
e4a300d90d
共有 1 个文件被更改,包括 7 次插入8 次删除
  1. 7 8
      contrib/lisp/org-element.el

+ 7 - 8
contrib/lisp/org-element.el

@@ -2600,14 +2600,12 @@ Return a list whose CAR is `line-break', and CDR a plist with
 `:begin', `:end' and `:post-blank' keywords.
 
 Assume point is at the beginning of the line break."
-  (let ((begin (point))
-	(end (save-excursion (forward-line) (point))))
-    (list 'line-break (list :begin begin :end end :post-blank 0))))
+  (list 'line-break (list :begin (point) :end (point-at-eol) :post-blank 0)))
 
 (defun org-element-line-break-interpreter (line-break contents)
   "Interpret LINE-BREAK object as Org syntax.
 CONTENTS is nil."
-  "\\\\\n")
+  "\\\\")
 
 (defun org-element-line-break-successor (limit)
   "Search for the next line-break object.
@@ -3670,8 +3668,9 @@ current object."
   (let (candidates)
     (save-excursion
       (goto-char beg)
-      (while (setq candidates (org-element-get-next-object-candidates
-			       end restriction candidates))
+      (while (and (< (point) end)
+		  (setq candidates (org-element-get-next-object-candidates
+				    end restriction candidates)))
 	(let ((next-object
 	       (let ((pos (apply 'min (mapcar 'cdr candidates))))
 		 (save-excursion
@@ -3692,8 +3691,8 @@ current object."
 		(cont-beg (org-element-property :contents-begin next-object)))
 	    ;; Fill contents of NEXT-OBJECT by side-effect, if it has
 	    ;; a recursive type.
-	    (when (and (memq (car next-object) org-element-recursive-objects)
-		       cont-beg)
+	    (when (and cont-beg
+		       (memq (car next-object) org-element-recursive-objects))
 	      (save-restriction
 		(narrow-to-region
 		 cont-beg