Browse Source

org.el: fix `org-end-of-meta-data-and-drawers'

Back to the previous version of `org-end-of-meta-data-and-drawers',
with a better fix.

Thanks to Eric Abrahamsen for this.
Bastien Guerry 13 years ago
parent
commit
330ed08feb
1 changed files with 11 additions and 4 deletions
  1. 11 4
      lisp/org.el

+ 11 - 4
lisp/org.el

@@ -20032,11 +20032,18 @@ This will move over empty lines, lines with planning time stamps,
 clocking lines, and drawers."
   (org-back-to-heading t)
   (let ((end (save-excursion (outline-next-heading) (point)))
-	(re (concat "[ \t]*$"
-		    "\\|" org-drawer-regexp 
+	(re (concat "\\(" org-drawer-regexp "\\)"
 		    "\\|" "[ \t]*" org-keyword-time-regexp)))
-    (while (re-search-forward re end 'move) 
-      (forward-line 1))))
+    (forward-line 1)
+    (while (re-search-forward re end t)
+      (if (not (match-end 1))
+	  ;; empty or planning line
+	  (forward-line 1)
+	;; a drawer, find the end
+	(re-search-forward "^[ \t]*:END:" end 'move)
+	(forward-line 1)))
+    (and (re-search-forward "[^\n]" nil t) (backward-char 1))
+    (point)))
 
 (defun org-forward-same-level (arg &optional invisible-ok)
   "Move forward to the arg'th subheading at same level as this one.