Bläddra i källkod

Bugfix: allow org-blocker-hook to check against headings outside of a narrowed buffer.

* org.el (org-todo): Bugfix: use `org-with-wide-buffer' to
check against headings outside of a narrowed buffer.

* org-macs.el (org-with-wide-buffer): New macro.
Bastien Guerry 14 år sedan
förälder
incheckning
4369d4f9a3
2 ändrade filer med 12 tillägg och 3 borttagningar
  1. 9 1
      lisp/org-macs.el
  2. 3 2
      lisp/org.el

+ 9 - 1
lisp/org-macs.el

@@ -333,6 +333,15 @@ point nowhere."
 		 (and (markerp (cdr c)) (move-marker (cdr c) nil)))
 	       data)))))
 
+(defmacro org-with-wide-buffer (&rest body)
+  "Execute body while temporarily widening the buffer."
+  `(let ((beg (point-min)) (end (point-max)) (pos (point)))
+     (prog2
+	 (widen)
+	 ,@body
+       (narrow-to-region beg end)
+       (goto-char pos))))
+
 (defmacro org-with-limited-levels (&rest body)
   "Execute BODY with limited number of outline levels."
   `(let* ((outline-regexp (org-get-limited-outline-regexp)))
@@ -344,7 +353,6 @@ point nowhere."
   "Return outline-regexp with limited number of levels.
 The number of levels is controlled by `org-inlinetask-min-level'"
   (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask)))
-
       outline-regexp
     (let* ((limit-level (1- org-inlinetask-min-level))
 	   (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))

+ 3 - 2
lisp/org.el

@@ -10936,8 +10936,9 @@ For calling through lisp, arg is also interpreted in the following way:
 		  (not (member this org-done-keywords)))
 	    (unless (save-excursion
 		      (save-match-data
-			(run-hook-with-args-until-failure
-			 'org-blocker-hook change-plist)))
+			(org-with-wide-buffer
+			 (run-hook-with-args-until-failure
+			  'org-blocker-hook change-plist))))
 	      (if (interactive-p)
 		  (error "TODO state change from %s to %s blocked" this state)
 		;; fail silently