* [patch] capture property table-line-pos can be a function
@ 2014-03-15 20:07 Thomas Holst
2014-03-17 0:51 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Holst @ 2014-03-15 20:07 UTC (permalink / raw)
To: emacs-orgmode
[-- 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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch] capture property table-line-pos can be a function
2014-03-15 20:07 [patch] capture property table-line-pos can be a function Thomas Holst
@ 2014-03-17 0:51 ` Bastien
2014-03-17 7:43 ` Thomas Holst
0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2014-03-17 0:51 UTC (permalink / raw)
To: Thomas Holst; +Cc: emacs-orgmode
Hi Thomas,
Thomas Holst <Thomas_Holst@gmx.de> writes:
> 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.
This sounds useful. Could you also provide a patch for the
documentation?
Thanks in advance!
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] capture property table-line-pos can be a function
2014-03-17 0:51 ` Bastien
@ 2014-03-17 7:43 ` Thomas Holst
2014-03-17 16:58 ` Thomas Holst
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Holst @ 2014-03-17 7:43 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode@gnu.org, Thomas Holst
Hi Bastien,
· Bastien <bzg@gnu.org> wrote:
> Thomas Holst <Thomas_Holst@gmx.de> writes:
>
>> 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.
>
> This sounds useful. Could you also provide a patch for the
> documentation?
>
> Thanks in advance!
thanks for looking into this. I will try to provide a patch for the
documentation in the next days.
--
Bis neulich ...
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] capture property table-line-pos can be a function
2014-03-17 7:43 ` Thomas Holst
@ 2014-03-17 16:58 ` Thomas Holst
2014-03-18 16:12 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Holst @ 2014-03-17 16:58 UTC (permalink / raw)
To: Thomas Holst; +Cc: Bastien, emacs-orgmode@gnu.org, Thomas Holst
[-- Attachment #1: Type: text/plain, Size: 736 bytes --]
Hi,
> Hi Bastien,
>
> · Bastien <bzg@gnu.org> wrote:
>> Thomas Holst <Thomas_Holst@gmx.de> writes:
>>
>>> 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.
>>
>> This sounds useful. Could you also provide a patch for the
>> documentation?
>>
>> Thanks in advance!
ok here is the patch for documentation.
--
Bis neulich ...
Thomas
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for new fatures for table-line-pos --]
[-- Type: text/x-diff, Size: 1150 bytes --]
From 436e5adb0a9d0bc9ac37352bd90018c973dfdabf Mon Sep 17 00:00:00 2001
From: Thomas Holst <Thomas_Holst@gmx.de>
Date: Mon, 17 Mar 2014 09:01:40 +0100
Subject: [PATCH] docu change for table-line-pos new feature
* org.texi: document new features of `table-line-pos' in capture
templates
---
doc/org.texi | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/doc/org.texi b/doc/org.texi
index b53b668..2bebae4 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7095,9 +7095,10 @@ narrow it so that you only see the new material.
@item :table-line-pos
Specification of the location in the table where the new line should be
-inserted. It should be a string like @code{"II-3"} meaning that the new
-line should become the third line before the second horizontal separator
-line.
+inserted. It can be a string, a variable holding a string or a function
+returning a string. The string should look like @code{"II-3"} meaning that
+the new line should become the third line before the second horizontal
+separator line.
@item :kill-buffer
If the target file was not yet visited when capture was invoked, kill the
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch] capture property table-line-pos can be a function
2014-03-17 16:58 ` Thomas Holst
@ 2014-03-18 16:12 ` Bastien
2014-03-18 18:27 ` Thomas Holst
0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2014-03-18 16:12 UTC (permalink / raw)
To: Thomas Holst; +Cc: emacs-orgmode@gnu.org
Hi Thomas,
Thomas Holst <Thomas_Holst@gmx.de> writes:
> ok here is the patch for documentation.
Thanks -- can you read this page?
http://orgmode.org/worg/org-contribute.html#sec-5
There are advice on how to format the Changelog entry.
See in particular this list:
- Variables and functions names are quoted like `this' (backquote and
single quote).
- Sentences should be separated by two spaces.
- Sentences should start with an uppercase letter.
- Avoid the passive form: i.e., use "change" instead of "changed".
I know it's boring, but even more boring to fix this when we merge
Org with Emacs :)
Thanks in advance,
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] capture property table-line-pos can be a function
2014-03-18 16:12 ` Bastien
@ 2014-03-18 18:27 ` Thomas Holst
2014-03-19 8:36 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Holst @ 2014-03-18 18:27 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 890 bytes --]
Hi Bastien,
· Bastien <bzg@gnu.org> wrote:
> Thomas Holst <Thomas_Holst@gmx.de> writes:
>
>> ok here is the patch for documentation.
>
> Thanks -- can you read this page?
> http://orgmode.org/worg/org-contribute.html#sec-5
>
> There are advice on how to format the Changelog entry.
>
> See in particular this list:
>
> - Variables and functions names are quoted like `this' (backquote and
> single quote).
> - Sentences should be separated by two spaces.
> - Sentences should start with an uppercase letter.
> - Avoid the passive form: i.e., use "change" instead of "changed".
>
> I know it's boring, but even more boring to fix this when we merge
> Org with Emacs :)
>
> Thanks in advance,
I am sorry, I used =git format-patch= for the patches assuming all will
go well. Here are both patches with rewritten commit messages. Hopefully
I made them well.
--
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: 1229 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: Implement new features for capture templates
* lisp/org-capture.el (org-capture-place-table-line): If the value of
`:table-line-pos' is a function name, its return value 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: docu patch for :table-line-pos --]
[-- Type: text/x-diff, Size: 1212 bytes --]
From 436e5adb0a9d0bc9ac37352bd90018c973dfdabf Mon Sep 17 00:00:00 2001
From: Thomas Holst <Thomas_Holst@gmx.de>
Date: Mon, 17 Mar 2014 09:01:40 +0100
Subject: [PATCH] docu change for table-line-pos new feature
org.texi: Document new features for capture templates
* doc/org.texi: Document new features of `:table-line-pos' in capture
templates.
---
doc/org.texi | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/doc/org.texi b/doc/org.texi
index b53b668..2bebae4 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7095,9 +7095,10 @@ narrow it so that you only see the new material.
@item :table-line-pos
Specification of the location in the table where the new line should be
-inserted. It should be a string like @code{"II-3"} meaning that the new
-line should become the third line before the second horizontal separator
-line.
+inserted. It can be a string, a variable holding a string or a function
+returning a string. The string should look like @code{"II-3"} meaning that
+the new line should become the third line before the second horizontal
+separator line.
@item :kill-buffer
If the target file was not yet visited when capture was invoked, kill the
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-03-19 9:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 20:07 [patch] capture property table-line-pos can be a function Thomas Holst
2014-03-17 0:51 ` 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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.