emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problems with capture
@ 2015-12-07 13:12 Thomas Holst
  2015-12-07 18:05 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Holst @ 2015-12-07 13:12 UTC (permalink / raw)
  To: org mode mailing list

Hello org-moders,

I have a little trouble with capture. First here is the setup for one of
my capture templates:

#+begin_src emacs-lisp
(setq org-capture-templates
      '(
        ;; ...
        ("hr" "Rechnung erfassen" table-line (file+function "~/git/org-priv/Univ_Beih.org" th:capure-find-open-vers-regn)
         "| # | %^u | %^{Arzt/Apotheke} | %^{für wen|Lida|Oleg|Victor|Simon} | %^{Betrag} | %^u | | | |"
         :table-line-pos "III-1" :immediate-finish t)
        ;; ...
        ))
#+end_src

What this template shall achive:

- look if there is an entry (headline) with todo state OPEN
- if entry exists append a table line
- if entry does not exist, create a new headline, insert table structure
  and append line to newly created table.

The function `th:capture-find-open-vers-regn' does this. Creating works
fine, but a get an error:

  Error running timer `org-element--cache-sync': (error "Invalid search bound (wrong side of point)")

and:

  condition-case: Capture template `hr': Invalid table line specification "III-1

I use something like:

#+begin_src emacs-lisp
(org-element-map (org-element-parse-buffer) 'headline
       (lambda (hl)
         (and
          (string= "Rechnungen" (car (org-element-property :title hl)))
          (= 1 (org-element-property :level hl))
          (org-element-property :begin hl)))
       nil t)
#+end_src

To find the Position in the file and regular

: (insert "a huge string")

To insert new heading and table structure. The new structure is created,
but something breaks caching. How can I insert the new structure without
breaking caching?

Thanks for any pointers.

P.S.
Org-mode version 8.3.2 
(release_8.3.2-359-g6b2c38 @ /home/thommy/git-emacs/org-mode/lisp/)

GNU Emacs 24.5.1 (i686-pc-linux-gnu, GTK+ Version 2.24.23) 
of 2015-07-03 on thommy-desktop

-- 
Bis neulich ...
  Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with capture
  2015-12-07 13:12 Problems with capture Thomas Holst
@ 2015-12-07 18:05 ` Nicolas Goaziou
  2015-12-08  9:16   ` Thomas Holst
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2015-12-07 18:05 UTC (permalink / raw)
  To: Thomas Holst; +Cc: org mode mailing list

Hello,

Thomas Holst <Thomas_Holst@gmx.de> writes:

> I have a little trouble with capture. First here is the setup for one of
> my capture templates:
>
> #+begin_src emacs-lisp
> (setq org-capture-templates
>       '(
>         ;; ...
>         ("hr" "Rechnung erfassen" table-line (file+function "~/git/org-priv/Univ_Beih.org" th:capure-find-open-vers-regn)
>          "| # | %^u | %^{Arzt/Apotheke} | %^{fr wen|Lida|Oleg|Victor|Simon} | %^{Betrag} | %^u | | | |"
>          :table-line-pos "III-1" :immediate-finish t)
>         ;; ...
>         ))
> #+end_src
>
> What this template shall achive:
>
> - look if there is an entry (headline) with todo state OPEN
> - if entry exists append a table line
> - if entry does not exist, create a new headline, insert table structure
>   and append line to newly created table.
>
> The function `th:capture-find-open-vers-regn' does this. Creating works
> fine, but a get an error:
>
>   Error running timer `org-element--cache-sync': (error "Invalid search bound (wrong side of point)")
>
> and:
>
>   condition-case: Capture template `hr': Invalid table line specification "III-1
>
> I use something like:
>
> #+begin_src emacs-lisp
> (org-element-map (org-element-parse-buffer) 'headline
>        (lambda (hl)
>          (and
>           (string= "Rechnungen" (car (org-element-property :title hl)))
>           (= 1 (org-element-property :level hl))
>           (org-element-property :begin hl)))
>        nil t)
> #+end_src
>
> To find the Position in the file and regular
>
> : (insert "a huge string")
>
> To insert new heading and table structure. The new structure is created,
> but something breaks caching. How can I insert the new structure without
> breaking caching?

I think I fixed something related recently. Could you update Org and try
again?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with capture
  2015-12-07 18:05 ` Nicolas Goaziou
@ 2015-12-08  9:16   ` Thomas Holst
  2015-12-08 12:29     ` Thomas Holst
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Holst @ 2015-12-08  9:16 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org mode mailing list

Hi Nicolas,
· Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Thomas Holst <Thomas_Holst@gmx.de> writes:

> [...snip...]

after a git-pull the first error (about cache) is gone. The second error
still is there:


>>   condition-case: Capture template `hr': Invalid table line specification "III-1"

The table which was inserted looks like this:

#+begin_src org
  ** OPEN [2015-12-08 Di] Rechnungen
  #+NAME: akt-vers-rechnungen
  |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
  | ! | Datum | Arzt | für wen | Betrag | wann bez. | wann bearb. | wann erh. Vers | wann erh. Beih. |
  |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
  |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
  | # |       |      |         |   0.00 |           |             |           0.00 |            0.00 |
  |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
  #+TBLFM: $8=$5*0.2;%.2f::$9=$5*0.8;%.2f::@2$5=vsum(@-II..@-I);%.2f
#+end_src

After creation point is at beginning of headline (left of the two *).
From my point of view table line specification "III-1" is ok.

Thanks for looking into this.

-- 
Mit freundlichen Grüßen / Best regards 

Thomas Holst 
DGS-EC/ESE4

Tel.   +49 (711) 811-40681
PC-Fax +49 (711) 811-5182208

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with capture
  2015-12-08  9:16   ` Thomas Holst
@ 2015-12-08 12:29     ` Thomas Holst
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Holst @ 2015-12-08 12:29 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org mode mailing list

Hi Nicolas,

replying to myself :-),

I dug a little deeper into this.

· Thomas Holst <thomas.holst@de.bosch.com> wrote:
> Hi Nicolas,
> · Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>> Thomas Holst <Thomas_Holst@gmx.de> writes:
>
>> [...snip...]
>
> after a git-pull the first error (about cache) is gone. The second error
> still is there:
>
>>>   condition-case: Capture template `hr': Invalid table line specification "III-1"
>
> The table which was inserted looks like this:
> #+begin_src org
>   ** OPEN [2015-12-08 Di] Rechnungen
>   #+NAME: akt-vers-rechnungen
>   |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
>   | ! | Datum | Arzt | f+r wen | Betrag | wann bez. | wann bearb. | wann erh. Vers | wann erh. Beih. |
>   |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
>   |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
>   | # |       |      |         |   0.00 |           |             |           0.00 |            0.00 |
>   |---+-------+------+---------+--------+-----------+-------------+----------------+-----------------|
>   #+TBLFM: $8=$5*0.2;%.2f::$9=$5*0.8;%.2f::@2$5=vsum(@-II..@-I);%.2f
> #+end_src
> After creation point is at beginning of headline (left of the two *).
> From my point of view table line specification "III-1" is ok.
>
> Thanks for looking into this.

The culprit is `org-capture-place-table-line'. It narrows the buffer to
relevant table but leaves point at the beginning of an empty line.
`org-table-analyze' does not any table and exits with nil.

For me the following patch fixes the problem:

#+begin_src diff
1 file changed, 1 insertion(+)
lisp/org-capture.el | 1 +

modified   lisp/org-capture.el
@@ -1156,6 +1156,7 @@ may have been stored before."
       (goto-char end)
       (insert "\n|   |\n|----|\n|    |\n")
       (narrow-to-region (1+ end) (point)))
+    (goto-char (point-min))
     ;; We are narrowed to the table, or to an empty line if there was no table
 
     ;; Check if the template is good
#+end_src

Maybe there is a better way to fix this.

Thanks again for lookint into this.

-- 
Mit freundlichen Grüßen / Best regards 

Thomas Holst 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-08 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 13:12 Problems with capture Thomas Holst
2015-12-07 18:05 ` Nicolas Goaziou
2015-12-08  9:16   ` Thomas Holst
2015-12-08 12:29     ` Thomas Holst

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).