emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Running in-line babel code at auto-insert template file open
@ 2020-02-25  3:51 Lawrence Bottorff
  2020-02-27  3:21 ` Lawrence Bottorff
  0 siblings, 1 reply; 2+ messages in thread
From: Lawrence Bottorff @ 2020-02-25  3:51 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

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

Let's say I have a standard org file I want to have created multiple times.
I've created a template file and told Emacs autoinsert where it is. Here's
the relevant in my init

(use-package autoinsert
  :ensure t
  ...
  :config
  (define-auto-insert "poolchem.org?$" "poolchem.org"))

So in this template file poolchem.org I have six table skeletons, but I
also want various customized additions. For example, I would like the table
names to reflect the current week starting with the coming Sunday's date

#+tblname: pc1-*src_emacs-lisp[:results raw]{(org-read-date nil nil "++sun"
nil (org-time-string-to-time "2020-02-24"))}*

which would hopefully show up in the newly created buffer as

#+tblname: pc1-2020-03-01

But then nothing of the sort happens, i.e., the in-line code just comes
back verbatim when I create a new file, unevaluated. I guess I'm totally
missing what is going on with in-line code. It seems other methods of
template creation allow code to be embedded, then to be evaluated. (The
variable auto-insert-alist has entire templates.) I've experimented with
eval of org-sbe in # local variables: ... but that was for running code
blocks upon file open, not individual embedded functions that would
customize my newly created org file. Any ideas?

LB

[-- Attachment #2: Type: text/html, Size: 1677 bytes --]

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

* Re: Running in-line babel code at auto-insert template file open
  2020-02-25  3:51 Running in-line babel code at auto-insert template file open Lawrence Bottorff
@ 2020-02-27  3:21 ` Lawrence Bottorff
  0 siblings, 0 replies; 2+ messages in thread
From: Lawrence Bottorff @ 2020-02-27  3:21 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

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

Got a good answer over at emacs.stackexchange
<https://emacs.stackexchange.com/questions/55754/how-to-run-functions-inside-auto-insert-template>
that
uses Emacs text-buffer lore. Still, it seems like org-mode should be able
to auto-run in-line code just like the solution does. Alas, someday I hope
to be able to just tackle a problem like this and submit the solution. Hope
springs eternal (which Google-Gmail just auto-completed!)...

On Mon, Feb 24, 2020 at 9:51 PM Lawrence Bottorff <borgauf@gmail.com> wrote:

> Let's say I have a standard org file I want to have created multiple
> times. I've created a template file and told Emacs autoinsert where it is.
> Here's the relevant in my init
>
> (use-package autoinsert
>   :ensure t
>   ...
>   :config
>   (define-auto-insert "poolchem.org?$" "poolchem.org"))
>
> So in this template file poolchem.org I have six table skeletons, but I
> also want various customized additions. For example, I would like the table
> names to reflect the current week starting with the coming Sunday's date
>
> #+tblname: pc1-*src_emacs-lisp[:results raw]{(org-read-date nil nil
> "++sun" nil (org-time-string-to-time "2020-02-24"))}*
>
> which would hopefully show up in the newly created buffer as
>
> #+tblname: pc1-2020-03-01
>
> But then nothing of the sort happens, i.e., the in-line code just comes
> back verbatim when I create a new file, unevaluated. I guess I'm totally
> missing what is going on with in-line code. It seems other methods of
> template creation allow code to be embedded, then to be evaluated. (The
> variable auto-insert-alist has entire templates.) I've experimented with
> eval of org-sbe in # local variables: ... but that was for running code
> blocks upon file open, not individual embedded functions that would
> customize my newly created org file. Any ideas?
>
> LB
>
>

[-- Attachment #2: Type: text/html, Size: 2531 bytes --]

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

end of thread, other threads:[~2020-02-27  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-25  3:51 Running in-line babel code at auto-insert template file open Lawrence Bottorff
2020-02-27  3:21 ` Lawrence Bottorff

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