Browse Source

org.el: Fix org-todo argument handling when looping over region

* lisp/org.el (org-todo): Replace backquote construct, which did not
properly quote argument, with closure.

Using "',arg" instead of ",arg" would also work.

Reported-by: Mario Frasca <mario@anche.no>
https://orgmode.org/list/ea64d98c-d7bf-eea0-40d4-00a1515bdb98@anche.no
Kyle Meyer 4 years ago
parent
commit
8a2eb7d1bc
2 changed files with 28 additions and 1 deletions
  1. 1 1
      lisp/org.el
  2. 27 0
      testing/lisp/test-org.el

+ 1 - 1
lisp/org.el

@@ -10065,7 +10065,7 @@ When called through ELisp, arg is also interpreted in the following way:
 		    'region-start-level 'region))
 	    org-loop-over-headlines-in-active-region)
 	(org-map-entries
-	 `(org-todo ,arg)
+	 (lambda () (org-todo arg))
 	 org-loop-over-headlines-in-active-region
 	 cl (when (org-invisible-p) (org-end-of-subtree nil t))))
     (when (equal arg '(16)) (setq arg 'nextset))

+ 27 - 0
testing/lisp/test-org.el

@@ -3035,6 +3035,33 @@ SCHEDULED: <2017-05-06 Sat>
      (org-end-of-meta-data t)
      (looking-at "Contents"))))
 
+(ert-deftest test-org/shiftright-heading ()
+  "Test `org-shiftright' on headings."
+  (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+    (should
+     (equal "* TODO a1\n** a2\n* DONE b1\n"
+	    (org-test-with-temp-text "* a1\n** a2\n* DONE b1\n"
+	      (org-shiftright)
+	      (buffer-string))))
+    (should
+     (equal "* TODO a1\n** TODO a2\n* b1\n"
+    	    (org-test-with-temp-text "* a1\n** a2\n* DONE b1\n"
+    	      (let ((org-loop-over-headlines-in-active-region t))
+    		(transient-mark-mode 1)
+    		(push-mark (point) t t)
+    		(search-forward "* DONE b1")
+    		(org-shiftright))
+    	      (buffer-string))))
+    (should
+     (equal "* TODO a1\n** a2\n* b1\n"
+    	    (org-test-with-temp-text "* a1\n** a2\n* DONE b1\n"
+    	      (let ((org-loop-over-headlines-in-active-region 'start-level))
+    		(transient-mark-mode 1)
+    		(push-mark (point) t t)
+    		(search-forward "* DONE b1")
+    		(org-shiftright))
+    	      (buffer-string))))))
+
 (ert-deftest test-org/beginning-of-line ()
   "Test `org-beginning-of-line' specifications."
   ;; Move to beginning of line.  If current line in invisible, move to