[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH][BUG] org-capture-templates checkitem not working as expected

From: Ohad Kammar
Subject: [O] [PATCH][BUG] org-capture-templates checkitem not working as expected
Date: Wed, 17 Sep 2014 10:06:06 +0100

Dear Org users,

There's a bug with the checkitem type org-capture-templates.

To reproduce:

1) Choose an org file with the headline "Test list", e.g., execute:
   $ cat > ~/org-capture-bugreport.org
   * Test list [/]
2) Add the following two templates to your org-capture-templates:
         ("b" "Demonstrate a bug in capture templates" checkitem (file
"~/org-capture-bugreport.org" "Test list")
              "there should be '[ ]' at the beginning of this item,
but there isn't." :immediate-finish t)
         ("v" "Demonstrate a bug in capture templates" checkitem (file
"~/org-capture-bugreport.org" "Test list")
              "[ ] This is how it should behave" :immediate-finish t)
3) org-capture b and org-capture v

I expected the 'b' option to add a checkbox item under "Test list",
but instead it only adds an item. The 'v' option behaves as I expect
from 'b', but I had to add the checkbox manually.

Below is a patch fixing this issue. (This is my first patch to Org, I'm
happy to fix any mistakes.


>From 8a09dd1e6aea78551d2958beebf88156ce54e774 Mon Sep 17 00:00:00 2001
From: Ohad Kammar <address@hidden>
Date: Wed, 17 Sep 2014 09:43:45 +0100
Subject: [PATCH] org-capture.el: Implemented checkitem capture type

org-capture.el (org-capture-place-item): Add check-box if appropriate.

Pre-patch, the checkitem and item types behave exactly the same,
rather than inserting a checkbox.

Fix by Simon Castellan and Ohad Kammar.

 lisp/org-capture.el |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9e33d25..365d7c5 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1094,7 +1094,7 @@ may have been stored before."
     (setq txt (org-remove-indentation txt))
     ;; Make sure this is indeed an item
     (unless (string-match (concat "\\`" (org-item-re)) txt)
-      (setq txt (concat "- "
+      (setq txt (concat "- " (if (eq (org-capture-get :type)
'checkitem) "[ ] " "")
             (mapconcat 'identity (split-string txt "\n")
                    "\n  "))))
     ;; Set the correct indentation, depending on context

reply via email to

[Prev in Thread] Current Thread [Next in Thread]