emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Diego Zamboni <diego@zzamboni.org>
To: Org-mode <emacs-orgmode@gnu.org>
Cc: Jarmo Hurri <jarmo.hurri@iki.fi>
Subject: Re: Babel: tangling questions
Date: Tue, 3 Dec 2019 14:28:12 +0100	[thread overview]
Message-ID: <CAGY83EdWU3DOAY+Yvj_Sy9jgs6HegzhHx3oVaz29Nbz2ohW_bQ@mail.gmail.com> (raw)
In-Reply-To: <87immxenvo.fsf@iki.fi>

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

Hi Jarmo,

1. I want to tangle to the default filename (derived from name of org
>    file and programming language). However, the :tangle header argument
>    only takes either "yes" or "filename." If the value is "yes", then
>    the filename is deduced automatically. How can I specify a tangling
>    directory and still have the default filename?
>
>    There was a related question on stack exchange, but it did not use
>    the default filename:
>
> https://emacs.stackexchange.com/questions/41806/org-babel-set-root-dir-for-tangled-files


You can specify a full path as the value of :tangle, but I don't know of a
way to specify only the directory.

As a workaround, you can also use emacs-lisp code as the value for :tangle,
so you could do something like this:

 :tangle (concat "/some/dir/" (file-name-base (file-name-sans-extension
(buffer-file-name))) ".ext")

3. Is it possible to tangle automatically on (every) export? I always
>    export, but I might forget to tangle, in which case export and tangle
>    would be out of sync.
>

I use the following hook to tangle on every save. I find it indispensable :)

  (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook
'org-babel-tangle
                                   'run-at-end 'only-in-org-mode)))

Also, check out my free book "Literate Config", where I discuss some more
tips about Literate Programming: https://leanpub.com/lit-config/read

Hope this helps,
--Diego

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

  reply	other threads:[~2019-12-03 13:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  9:53 Babel: tangling questions Jarmo Hurri
2019-12-03 13:28 ` Diego Zamboni [this message]
2019-12-03 15:22   ` Jarmo Hurri

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=CAGY83EdWU3DOAY+Yvj_Sy9jgs6HegzhHx3oVaz29Nbz2ohW_bQ@mail.gmail.com \
    --to=diego@zzamboni.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=jarmo.hurri@iki.fi \
    /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).