emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Tangling to Multiple Files
@ 2012-10-28 20:12 Alan Lue
  2012-10-28 21:03 ` Thomas S. Dye
  2012-10-28 21:12 ` Eric Schulte
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Lue @ 2012-10-28 20:12 UTC (permalink / raw)
  To: emacs-orgmode


Hi, how does one tangle a single code block to multiple files?

I thought the following might work, but unfortunately it does not.

Set the frame size.
#+HEADERS: :tangle user-host-a.el user-host-b.el
#+BEGIN_SRC emacs-lisp
  (setq initial-frame-alist '((width . 80) (height . 38)))
#+END_SRC

To provide some background, I'm using =org-babel-load-file= in my
init.el file to load up my Emacs configuration from an Org file—call it
"user.org." I'd like to use just one user.org file across multiple
computers, however, meaning I'd like user.org to tangle into
user-host-a.el and user-host-b.el, for instance.

The configurations are only slightly different, so I'd like to be able
to selectively indicate to Org-mode which code blocks to tangle
into.

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

* Re: Tangling to Multiple Files
  2012-10-28 20:12 Tangling to Multiple Files Alan Lue
@ 2012-10-28 21:03 ` Thomas S. Dye
  2012-10-28 21:12 ` Eric Schulte
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas S. Dye @ 2012-10-28 21:03 UTC (permalink / raw)
  To: Alan Lue; +Cc: emacs-orgmode

Aloha Alan,

This can be achieved with noweb references.

Something like this:

#+name: user-host-a
#+HEADERS: :tangle user-host-a.el :noweb tangle
#+BEGIN_SRC emacs-lisp
<<initial-frame>>
#+END_SRC

#+name: user-host-b
#+HEADERS: :tangle user-host-b.el :noweb tangle
#+BEGIN_SRC emacs-lisp
<<initial-frame>>
#+END_SRC

#+name: initial-frame
#+BEGIN_SRC emacs-lisp
  (setq initial-frame-alist '((width . 80) (height . 38)))
#+END_SRC

hth,
Tom

Alan Lue <alan.lue@gmail.com> writes:

> Hi, how does one tangle a single code block to multiple files?
>
> I thought the following might work, but unfortunately it does not.
>
> Set the frame size.
> #+HEADERS: :tangle user-host-a.el user-host-b.el
> #+BEGIN_SRC emacs-lisp
>   (setq initial-frame-alist '((width . 80) (height . 38)))
> #+END_SRC
>
> To provide some background, I'm using =org-babel-load-file= in my
> init.el file to load up my Emacs configuration from an Org file—call it
> "user.org." I'd like to use just one user.org file across multiple
> computers, however, meaning I'd like user.org to tangle into
> user-host-a.el and user-host-b.el, for instance.
>
> The configurations are only slightly different, so I'd like to be able
> to selectively indicate to Org-mode which code blocks to tangle
> into.
>
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: Tangling to Multiple Files
  2012-10-28 20:12 Tangling to Multiple Files Alan Lue
  2012-10-28 21:03 ` Thomas S. Dye
@ 2012-10-28 21:12 ` Eric Schulte
  2012-10-28 21:38   ` Alan Lue
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2012-10-28 21:12 UTC (permalink / raw)
  To: Alan Lue; +Cc: emacs-orgmode

Alan Lue <alan.lue@gmail.com> writes:

> Hi, how does one tangle a single code block to multiple files?
>
> I thought the following might work, but unfortunately it does not.
>
> Set the frame size.
> #+HEADERS: :tangle user-host-a.el user-host-b.el
> #+BEGIN_SRC emacs-lisp
>   (setq initial-frame-alist '((width . 80) (height . 38)))
> #+END_SRC
>
> To provide some background, I'm using =org-babel-load-file= in my
> init.el file to load up my Emacs configuration from an Org file—call it
> "user.org." I'd like to use just one user.org file across multiple
> computers, however, meaning I'd like user.org to tangle into
> user-host-a.el and user-host-b.el, for instance.
>
> The configurations are only slightly different, so I'd like to be able
> to selectively indicate to Org-mode which code blocks to tangle
> into.
>
>

You could try something like the following to tangle out to a different
file on each machine.

  :tangle (format "%s.el" system-name)

or

  :tangle (format "%s.el" user-login-name)

Hope this helps,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

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

* Re: Tangling to Multiple Files
  2012-10-28 21:12 ` Eric Schulte
@ 2012-10-28 21:38   ` Alan Lue
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Lue @ 2012-10-28 21:38 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Thanks Eric, I didn't know that you could pass lisp code as header
arguments. It looks like it'll be best to conditionally tangle.

 :tangle (if (string-match "myhost" system-name) "yes" "no")

Eric Schulte <schulte.eric@gmail.com> writes:

> Alan Lue <alan.lue@gmail.com> writes:
>
>> Hi, how does one tangle a single code block to multiple files?
>>
>> I thought the following might work, but unfortunately it does not.
>>
>> Set the frame size.
>> #+HEADERS: :tangle user-host-a.el user-host-b.el
>> #+BEGIN_SRC emacs-lisp
>>   (setq initial-frame-alist '((width . 80) (height . 38)))
>> #+END_SRC
>>
>> To provide some background, I'm using =org-babel-load-file= in my
>> init.el file to load up my Emacs configuration from an Org file—call it
>> "user.org." I'd like to use just one user.org file across multiple
>> computers, however, meaning I'd like user.org to tangle into
>> user-host-a.el and user-host-b.el, for instance.
>>
>> The configurations are only slightly different, so I'd like to be able
>> to selectively indicate to Org-mode which code blocks to tangle
>> into.
>>
>>
>
> You could try something like the following to tangle out to a different
> file on each machine.
>
>   :tangle (format "%s.el" system-name)
>
> or
>
>   :tangle (format "%s.el" user-login-name)
>
> Hope this helps,

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

end of thread, other threads:[~2012-10-28 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-28 20:12 Tangling to Multiple Files Alan Lue
2012-10-28 21:03 ` Thomas S. Dye
2012-10-28 21:12 ` Eric Schulte
2012-10-28 21:38   ` Alan Lue

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