From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ohad Kammar Subject: [PATCH][BUG] org-capture-templates checkitem not working as expected Date: Wed, 17 Sep 2014 10:06:06 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUBCA-0001Ik-4F for emacs-orgmode@gnu.org; Wed, 17 Sep 2014 05:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUBC3-0006bh-MB for emacs-orgmode@gnu.org; Wed, 17 Sep 2014 05:06:38 -0400 Received: from mail-oa0-x232.google.com ([2607:f8b0:4003:c02::232]:60761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUBC3-0006bI-H8 for emacs-orgmode@gnu.org; Wed, 17 Sep 2014 05:06:31 -0400 Received: by mail-oa0-f50.google.com with SMTP id jd19so837577oac.37 for ; Wed, 17 Sep 2014 02:06:27 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Simon Castellan 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 [/] ^C 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. Yours, Ohad. >From 8a09dd1e6aea78551d2958beebf88156ce54e774 Mon Sep 17 00:00:00 2001 From: Ohad Kammar 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. TINYCHANGE --- 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 -- 1.7.9.5