emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thomas Holst <Thomas_Holst@gmx.de>
To: emacs-orgmode@gnu.org
Subject: [patch] capture property table-line-pos can be a function
Date: Sat, 15 Mar 2014 21:07:04 +0100	[thread overview]
Message-ID: <87eh23i5uf@gmx.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for table-line-pos --]
[-- Type: text/x-diff, Size: 1138 bytes --]

From e5f906f20b796326e50057fa4fc21599368bd347 Mon Sep 17 00:00:00 2001
From: Thomas Holst <Thomas_Holst@gmx.de>
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


             reply	other threads:[~2014-03-15 20:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-15 20:07 Thomas Holst [this message]
2014-03-17  0:51 ` [patch] capture property table-line-pos can be a function Bastien
2014-03-17  7:43   ` Thomas Holst
2014-03-17 16:58     ` Thomas Holst
2014-03-18 16:12       ` Bastien
2014-03-18 18:27         ` Thomas Holst
2014-03-19  8:36           ` Bastien
2014-03-19  9:53             ` Thomas Holst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh23i5uf@gmx.de \
    --to=thomas_holst@gmx.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).