all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* managing repetitive code in export & tangling
@ 2019-10-08 15:26 Matt Price
  2019-10-08 20:53 ` Sebastian Miele
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Price @ 2019-10-08 15:26 UTC (permalink / raw)
  To: Org Mode

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

In my lectures i often have simple examples that build progressively over
several slides. In order to use klipse properly, but also for clarity, I
gneerally repeat variable declarations from slide to slide, so for
instance:

** Making Lists (Arrays)

+#NAME: js-array-historians
#+BEGIN_SRC js
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan
Scott"];
#+END_SRC

** Repetition: While Loops
#+NAME: js-while-hist
#+begin_src js
<<js-array-historians>>
let i = 0;

while (i < historians.length) {
    console.log(historians[i] + " was a historian.");
    i+=1;
  }
#+end_src

There might then be a sequence of another 5 or 6 slides in which the same
"historians" array is bound to the same value and used as an example.

This works fine on its own. However, I would also like to tangle all this
code to a single file per lecture so students can download a git repo and
play with it directly in a real text editor. Unfortunately, javascript will
error out if a ~let~ bound variable is  redeclared in the same scope.  I'm
wondering if there's any way to specify that a noweb reference only be
included one time in a tangled file. Or if there are cleverer workarounds
that folks can suggest!

Thanks much,

Matt

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

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

end of thread, other threads:[~2019-10-08 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-08 15:26 managing repetitive code in export & tangling Matt Price
2019-10-08 20:53 ` Sebastian Miele

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.