From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Holst Subject: [patch] capture property table-line-pos can be a function Date: Sat, 15 Mar 2014 21:07:04 +0100 Message-ID: <87eh23i5uf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=Multipart0o0o0o0o0o0o0o" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOurR-0005Z9-95 for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 16:07:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOurL-0008WS-Eu for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 16:07:13 -0400 Received: from mout.gmx.net ([212.227.15.18]:63710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOurL-0008WE-4U for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 16:07:07 -0400 Received: from thommy-desktop ([84.57.175.23]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0M04uG-1XGkvl3aou-00uLhb for ; Sat, 15 Mar 2014 21:07:06 +0100 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 --=Multipart0o0o0o0o0o0o0o Content-Type: text/plain Hi, for quite a while I have this patch in my local org-mode branch. Now I find the time to share it. Given a table with several sections and a capture template for entries in this table. The sections are dynamic, so a static value for table-line-pos does not help. With this patch table-line-pos can be: - a string like "II-2" - a varialbe containing a string - or a function The function has to return a string which qualifies for table-line-pos This serves me well and I am using it for more than one year now. If you find it usefull then feel free to use it. I marked it as TINYCHANGE, but I have signed FSF papers. -- Bis neulich ... Thomas --=Multipart0o0o0o0o0o0o0o Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-capture-property-table-line-pos.patch Content-Description: patch for table-line-pos >From e5f906f20b796326e50057fa4fc21599368bd347 Mon Sep 17 00:00:00 2001 From: Thomas Holst Date: Sat, 15 Mar 2014 16:22:44 +0100 Subject: [PATCH 1/2] capture: property `:table-line-pos' can be a function name, a string or a variable * org-capture.el: If the value of `:table-line-pos' is a function name, its return valeue is used to determine the position inside the table. Return value must be a string like "II-3". Else `:table-line-pos' is 'eval'ed. TINYCHANGE --- lisp/org-capture.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index e7f5e20..cf6c9e2 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1149,6 +1149,9 @@ may have been stored before." ;; Check if the template is good (if (not (string-match org-table-dataline-regexp txt)) (setq txt "| %?Bad template |\n")) + (if (functionp table-line-pos) + (setq table-line-pos (funcall table-line-pos)) + (setq table-line-pos (eval table-line-pos))) (cond ((and table-line-pos (string-match "\\(I+\\)\\([-+][0-9]\\)" table-line-pos)) -- 1.7.9.5 --=Multipart0o0o0o0o0o0o0o--