emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* "Bad template" when creating org-capture for table-line without '|'
@ 2024-03-27 10:47 Rens Oliemans
  2024-03-27 12:37 ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Rens Oliemans @ 2024-03-27 10:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I was trying to create an org-capture for a table-line type, and I noticed that
org-capture inserts the string "| Bad template |" when the template does not start with
'|'. This could make sense, since a line is (only) considered part of a table when it
starts with '|'.

However, I did not know that the _template_ also has to start with '|', and org-capture
still inserts the string "| Bad template |", which does not suggest in any way that the
lacking '|' would be the problem (after all, it is smart enough to prepend a '|').

Use this template to reproduce the behaviour, present on 9.7-pre
(release_9.6.23-1318-g990b89):

(setq org-capture-templates '(("t" "Test" table-line (file "test.org")
			       "%^t")))

I did not see this documented anywhere: this was quite confusing, and the only way I got a
hint at what I did wrong was to see the default template for table-line: "| %? |". It
seems that this behaviour is intended, looking at org-capture.el:1358 @ 990b89d3:

...
	 (pcase (org-trim (org-capture-get :template))
	   ((pred (string-match-p org-table-border-regexp))
	    "| %?Bad template |")
	   (text (concat text "\n"))))
...

however, is this also what's ideal? I would suggest one of the following alternatives:

- An error is signalled to the user with the root cause of the error: no '|' at start of
  template. In addition, the org-capture-templates variable documentation string and the
  manual would be updated. I am happy to create a patch for this.

- org-capture could pre- and suffix a '|' if the user did not supply it in their template.
  I am also happy to create a patch for this, however that would be my first so such a
  patch would perhaps have a few iterations ;)

What are your thoughts on this?

Best


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

end of thread, other threads:[~2024-06-05 10:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-27 10:47 "Bad template" when creating org-capture for table-line without '|' Rens Oliemans
2024-03-27 12:37 ` Ihor Radchenko
2024-04-14 11:24   ` [PATCH 1/2] org-capture: Allow entry template to start without heading Rens Oliemans
2024-04-14 13:41     ` Ihor Radchenko
2024-04-14 18:39       ` Rens Oliemans
2024-05-14  8:48         ` Ihor Radchenko
2024-05-14  9:49           ` Rens Oliemans
2024-05-27  7:54           ` Rens Oliemans
2024-05-27  8:29             ` Ihor Radchenko
2024-05-27  8:50               ` Bastien Guerry
2024-06-04 13:21       ` Ihor Radchenko
2024-06-05 10:25         ` Rens Oliemans
2024-04-14 11:24   ` [PATCH 2/2] org-capture: Allow table-line entry to start without | Rens Oliemans

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