aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorRasmus2017-08-29 10:07:08 +0200
committerRasmus2017-08-29 10:13:31 +0200
commit3ad8ca429bac5e1354881cf4411d6f41dab36b44 (patch)
tree41d8dc789a212dc3b1e09f402714b09dc1462fc5 /doc
parentc1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 (diff)
downloademacs-3ad8ca429bac5e1354881cf4411d6f41dab36b44.tar.gz
emacs-3ad8ca429bac5e1354881cf4411d6f41dab36b44.zip
Update Org to v9.0.10
Please see etc/ORG-NEWS for major changes. Note, this is a bugfix release.
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/org.texi427
1 files changed, 360 insertions, 67 deletions
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 2d537946be0..067ae7bbc52 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -4,7 +4,8 @@
4@settitle The Org Manual 4@settitle The Org Manual
5@include docstyle.texi 5@include docstyle.texi
6 6
7@set VERSION 9.0.9 7@set VERSION 9.0.10
8@set DATE 2017-08-27
8 9
9@c Version and Contact Info 10@c Version and Contact Info
10@set MAINTAINERSITE @uref{http://orgmode.org,maintainers web page} 11@set MAINTAINERSITE @uref{http://orgmode.org,maintainers web page}
@@ -499,6 +500,12 @@ Capture templates
499* Template expansion:: Filling in information about time and context 500* Template expansion:: Filling in information about time and context
500* Templates in contexts:: Only show a template in a specific context 501* Templates in contexts:: Only show a template in a specific context
501 502
503Protocols for external access
504
505* @code{store-link} protocol:: Store a link, push URL to kill-ring.
506* @code{capture} protocol:: Fill a buffer with external information.
507* @code{open-source} protocol:: Edit published contents.
508
502Archiving 509Archiving
503 510
504* Moving subtrees:: Moving a tree to an archive file 511* Moving subtrees:: Moving a tree to an archive file
@@ -830,7 +837,7 @@ different formats such as HTML, @LaTeX{}, Open Document, and Markdown. New
830export backends can be derived from existing ones, or defined from scratch. 837export backends can be derived from existing ones, or defined from scratch.
831 838
832Org files can include source code blocks, which makes Org uniquely suited for 839Org files can include source code blocks, which makes Org uniquely suited for
833authoring technical documents with code examples. Org source code blocks are 840authoring technical documents with code examples. Org source code blocks are
834fully functional; they can be evaluated in place and their results can be 841fully functional; they can be evaluated in place and their results can be
835captured in the file. This makes it possible to create a single file 842captured in the file. This makes it possible to create a single file
836reproducible research compendium. 843reproducible research compendium.
@@ -7310,7 +7317,11 @@ dynamic insertion of content. The templates are expanded in the order given her
7310 @r{%^@{prompt|default|completion2|completion3...@}.} 7317 @r{%^@{prompt|default|completion2|completion3...@}.}
7311 @r{The arrow keys access a prompt-specific history.} 7318 @r{The arrow keys access a prompt-specific history.}
7312%\1 @dots{} %\N @r{Insert the text entered at the Nth %^@{@var{prompt}@}, where @code{N} is} 7319%\1 @dots{} %\N @r{Insert the text entered at the Nth %^@{@var{prompt}@}, where @code{N} is}
7313 @r{a number, starting from 1.} 7320 @r{a number, starting from 1.@footnote{As required in Emacs
7321 Lisp, it is necessary to escape any backslash character in
7322 a string with another backslash. So, in order to use
7323 @samp{%\1} placeholder, you need to write @samp{%\\1} in
7324 the template.}}
7314%? @r{After completing the template, position cursor here.} 7325%? @r{After completing the template, position cursor here.}
7315@end smallexample 7326@end smallexample
7316 7327
@@ -7505,16 +7516,202 @@ For more information, including how to read atom feeds, see
7505@node Protocols 7516@node Protocols
7506@section Protocols for external access 7517@section Protocols for external access
7507@cindex protocols, for external access 7518@cindex protocols, for external access
7508@cindex emacsserver
7509 7519
7510You can set up Org for handling protocol calls from outside applications that 7520Org protocol is a mean to trigger custom actions in Emacs from external
7511are passed to Emacs through the @file{emacsserver}. For example, you can 7521applications. Any application that supports calling external programs with
7522an URL as argument may be used with this functionality. For example, you can
7512configure bookmarks in your web browser to send a link to the current page to 7523configure bookmarks in your web browser to send a link to the current page to
7513Org and create a note from it using capture (@pxref{Capture}). Or you 7524Org and create a note from it using capture (@pxref{Capture}). You can also
7514could create a bookmark that will tell Emacs to open the local source file of 7525create a bookmark that tells Emacs to open the local source file of a remote
7515a remote website you are looking at with the browser. See 7526website you are browsing.
7516@uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed 7527
7517documentation and setup instructions. 7528@cindex Org protocol, set-up
7529@cindex Installing Org protocol
7530In order to use Org protocol from an application, you need to register
7531@samp{org-protocol://} as a valid scheme-handler. External calls are passed
7532to Emacs through the @code{emacsclient} command, so you also need to ensure
7533an Emacs server is running. More precisely, when the application calls
7534
7535@example
7536emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7537@end example
7538
7539@noindent
7540Emacs calls the handler associated to @samp{PROTOCOL} with argument
7541@samp{(:key1 val1 :key2 val2)}.
7542
7543@cindex protocol, new protocol
7544@cindex defining new protocols
7545Org protocol comes with three predefined protocols, detailed in the following
7546sections. Configure @code{org-protocol-protocol-alist} to define your own.
7547
7548@menu
7549* @code{store-link} protocol:: Store a link, push URL to kill-ring.
7550* @code{capture} protocol:: Fill a buffer with external information.
7551* @code{open-source} protocol:: Edit published contents.
7552@end menu
7553
7554@node @code{store-link} protocol
7555@subsection @code{store-link} protocol
7556@cindex store-link protocol
7557@cindex protocol, store-link
7558
7559Using @code{store-link} handler, you can copy links, insertable through
7560@kbd{M-x org-insert-link} or yanking thereafter. More precisely, the command
7561
7562@example
7563emacsclient org-protocol://store-link?url=URL&title=TITLE
7564@end example
7565
7566@noindent
7567stores the following link:
7568
7569@example
7570[[URL][TITLE]]
7571@end example
7572
7573In addition, @samp{URL} is pushed on the kill-ring for yanking. You need to
7574encode @samp{URL} and @samp{TITLE} if they contain slashes, and probably
7575quote those for the shell.
7576
7577To use this feature from a browser, add a bookmark with an arbitrary name,
7578e.g., @samp{Org: store-link} and enter this as @emph{Location}:
7579
7580@example
7581javascript:location.href='org-protocol://store-link?url='+
7582 encodeURIComponent(location.href);
7583@end example
7584
7585@node @code{capture} protocol
7586@subsection @code{capture} protocol
7587@cindex capture protocol
7588@cindex protocol, capture
7589
7590@cindex capture, %:url placeholder
7591@cindex %:url template expansion in capture
7592@cindex capture, %:title placeholder
7593@cindex %:title template expansion in capture
7594Activating @code{capture} handler pops up a @samp{Capture} buffer and fills
7595the capture template associated to the @samp{X} key with them. The template
7596refers to the data through @code{%:url} and @code{%:title} placeholders.
7597Moreover, any selected text in the browser is appended to the body of the
7598entry.
7599
7600@example
7601emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7602@end example
7603
7604To use this feature, add a bookmark with an arbitrary name, e.g.
7605@samp{Org: capture} and enter this as @samp{Location}:
7606
7607@example
7608javascript:location.href='org-protocol://template=x'+
7609 '&url='+encodeURIComponent(window.location.href)+
7610 '&title='+encodeURIComponent(document.title)+
7611 '&body='+encodeURIComponent(window.getSelection());
7612@end example
7613
7614@vindex org-protocol-default-template-key
7615The result depends on the capture template used, which is set in the bookmark
7616itself, as in the example above, or in
7617@code{org-protocol-default-template-key}.
7618
7619@node @code{open-source} protocol
7620@subsection @code{open-source} protocol
7621@cindex open-source protocol
7622@cindex protocol, open-source
7623
7624The @code{open-source} handler is designed to help with editing local sources
7625when reading a document. To that effect, you can use a bookmark with the
7626following location:
7627
7628@example
7629javascript:location.href='org-protocol://open-source?&url='+
7630 encodeURIComponent(location.href)
7631@end example
7632
7633@cindex protocol, open-source, :base-url property
7634@cindex :base-url property in open-source protocol
7635@cindex protocol, open-source, :working-directory property
7636@cindex :working-directory property in open-source protocol
7637@cindex protocol, open-source, :online-suffix property
7638@cindex :online-suffix property in open-source protocol
7639@cindex protocol, open-source, :working-suffix property
7640@cindex :working-suffix property in open-source protocol
7641@vindex org-protocol-project-alist
7642The variable @code{org-protocol-project-alist} maps URLs to local file names,
7643by stripping URL parameters from the end and replacing the @code{:base-url}
7644with @code{:working-diretory} and @code{:online-suffix} with
7645@code{:working-suffix}. For example, assuming you own a local copy of
7646@url{http://orgmode.org/worg/} contents at @file{/home/user/worg}, you can
7647set @code{org-protocol-project-alist} to the following
7648
7649@lisp
7650(setq org-protocol-project-alist
7651 '(("Worg"
7652 :base-url "http://orgmode.org/worg/"
7653 :working-directory "/home/user/worg/"
7654 :online-suffix ".html"
7655 :working-suffix ".org")))
7656@end lisp
7657
7658@noindent
7659If you are now browsing
7660@url{http://orgmode.org/worg/org-contrib/org-protocol.html} and find a typo
7661or have an idea about how to enhance the documentation, simply click the
7662bookmark and start editing.
7663
7664@cindex handle rewritten URL in open-source protocol
7665@cindex protocol, open-source rewritten URL
7666However, such mapping may not yield the desired results. Suppose you
7667maintain an online store located at @url{http://example.com/}. The local
7668sources reside in @file{/home/user/example/}. It is common practice to serve
7669all products in such a store through one file and rewrite URLs that do not
7670match an existing file on the server. That way, a request to
7671@url{http://example.com/print/posters.html} might be rewritten on the server
7672to something like
7673@url{http://example.com/shop/products.php/posters.html.php}. The
7674@code{open-source} handler probably cannot find a file named
7675@file{/home/user/example/print/posters.html.php} and fails.
7676
7677@cindex protocol, open-source, :rewrites property
7678@cindex :rewrites property in open-source protocol
7679Such an entry in @code{org-protocol-project-alist} may hold an additional
7680property @code{:rewrites}. This property is a list of cons cells, each of
7681which maps a regular expression to a path relative to the
7682@code{:working-directory}.
7683
7684Now map the URL to the path @file{/home/user/example/products.php} by adding
7685@code{:rewrites} rules like this:
7686
7687@lisp
7688(setq org-protocol-project-alist
7689 '(("example.com"
7690 :base-url "http://example.com/"
7691 :working-directory "/home/user/example/"
7692 :online-suffix ".php"
7693 :working-suffix ".php"
7694 :rewrites (("example.com/print/" . "products.php")
7695 ("example.com/$" . "index.php")))))
7696@end lisp
7697
7698@noindent
7699Since @samp{example.com/$} is used as a regular expression, it maps
7700@url{http://example.com/}, @url{https://example.com},
7701@url{http://www.example.com/} and similar to
7702@file{/home/user/example/index.php}.
7703
7704The @code{:rewrites} rules are searched as a last resort if and only if no
7705existing file name is matched.
7706
7707@cindex protocol, open-source, set-up mapping
7708@cindex set-up mappings in open-source protocol
7709@findex org-protocol-create
7710@findex org-protocol-create-for-org
7711Two functions can help you filling @code{org-protocol-project-alist} with
7712valid contents: @code{org-protocol-create} and
7713@code{org-protocol-create-for-org}. The latter is of use if you're editing
7714an Org file that is part of a publishing project.
7518 7715
7519@node Refile and copy 7716@node Refile and copy
7520@section Refile and copy 7717@section Refile and copy
@@ -8081,7 +8278,7 @@ you can use the following instead:
8081@end example 8278@end example
8082 8279
8083That will give you three days' warning: on the anniversary date itself and the 8280That will give you three days' warning: on the anniversary date itself and the
8084two days prior. The argument is optional: if omitted, it defaults to 7. 8281two days prior. The argument is optional: if omitted, it defaults to 7.
8085 8282
8086@subsubheading Appointment reminders 8283@subsubheading Appointment reminders
8087@cindex @file{appt.el} 8284@cindex @file{appt.el}
@@ -11443,8 +11640,8 @@ The default is ``xhtml-strict''.
11443Org's HTML exporter does not by default enable new block elements introduced 11640Org's HTML exporter does not by default enable new block elements introduced
11444with the HTML5 standard. To enable them, set @code{org-html-html5-fancy} to 11641with the HTML5 standard. To enable them, set @code{org-html-html5-fancy} to
11445non-@code{nil}. Or use an @code{OPTIONS} line in the file to set 11642non-@code{nil}. Or use an @code{OPTIONS} line in the file to set
11446@code{html5-fancy}. HTML5 documents can now have arbitrary #+BEGIN and #+END 11643@code{html5-fancy}. HTML5 documents can now have arbitrary @code{#+BEGIN}
11447blocks. For example: 11644and @code{#+END} blocks. For example:
11448 11645
11449@example 11646@example
11450#+BEGIN_aside 11647#+BEGIN_aside
@@ -13590,7 +13787,7 @@ itself does not appear in the structure of the document.
13590Copyright information is printed on the back of the title page. 13787Copyright information is printed on the back of the title page.
13591 13788
13592@example 13789@example
13593* Copying 13790* Legalese
13594 :PROPERTIES: 13791 :PROPERTIES:
13595 :COPYING: t 13792 :COPYING: t
13596 :END: 13793 :END:
@@ -15142,8 +15339,8 @@ customization options for extracting source code.
15142When Org tangles @samp{src} code blocks, it expands, merges, and transforms 15339When Org tangles @samp{src} code blocks, it expands, merges, and transforms
15143them. Then Org recomposes them into one or more separate files, as 15340them. Then Org recomposes them into one or more separate files, as
15144configured through the options. During this @emph{tangling} process, Org 15341configured through the options. During this @emph{tangling} process, Org
15145expands variables in the source code, and resolves any ``noweb'' style 15342expands variables in the source code, and resolves any Noweb style references
15146references (@pxref{Noweb reference syntax}). 15343(@pxref{Noweb reference syntax}).
15147 15344
15148@subsubheading Header arguments 15345@subsubheading Header arguments
15149 15346
@@ -15319,6 +15516,7 @@ Org supports the following languages for the @samp{src} code blocks:
15319Additional documentation for some languages are at 15516Additional documentation for some languages are at
15320@uref{http://orgmode.org/worg/org-contrib/babel/languages.html}. 15517@uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
15321 15518
15519@vindex org-babel-load-languages
15322By default, only @code{emacs-lisp} is enabled for evaluation. To enable or 15520By default, only @code{emacs-lisp} is enabled for evaluation. To enable or
15323disable other languages, customize the @code{org-babel-load-languages} 15521disable other languages, customize the @code{org-babel-load-languages}
15324variable either through the Emacs customization interface, or by adding code 15522variable either through the Emacs customization interface, or by adding code
@@ -16148,12 +16346,11 @@ Do not insert newlines to pad the tangled @samp{src} code blocks.
16148By default Org expands @samp{src} code blocks during tangling. The 16346By default Org expands @samp{src} code blocks during tangling. The
16149@code{:no-expand} header argument turns off such expansions. Note that one 16347@code{:no-expand} header argument turns off such expansions. Note that one
16150side-effect of expansion by @code{org-babel-expand-src-block} also assigns 16348side-effect of expansion by @code{org-babel-expand-src-block} also assigns
16151values to @code{:var} (@pxref{var}) variables. Expansions also replace 16349values to @code{:var} (@pxref{var}) variables. Expansions also replace Noweb
16152``noweb'' references with their targets (@pxref{Noweb reference syntax}). 16350references with their targets (@pxref{Noweb reference syntax}). Some of
16153Some of these expansions may cause premature assignment, hence this option. 16351these expansions may cause premature assignment, hence this option. This
16154This option makes a difference only for tangling. It has no effect when 16352option makes a difference only for tangling. It has no effect when exporting
16155exporting since @samp{src} code blocks for execution have to be expanded 16353since @samp{src} code blocks for execution have to be expanded anyway.
16156anyway.
16157 16354
16158@node session 16355@node session
16159@subsubsection @code{:session} 16356@subsubsection @code{:session}
@@ -16182,42 +16379,56 @@ subsequent source code language blocks change session names.
16182@subsubsection @code{:noweb} 16379@subsubsection @code{:noweb}
16183@cindex @code{:noweb}, src header argument 16380@cindex @code{:noweb}, src header argument
16184 16381
16185The @code{:noweb} header argument controls expansion of ``noweb'' syntax 16382The @code{:noweb} header argument controls expansion of Noweb syntax
16186references (@pxref{Noweb reference syntax}). Expansions occur when source 16383references (@pxref{Noweb reference syntax}). Expansions occur when source
16187code blocks are evaluated, tangled, or exported. 16384code blocks are evaluated, tangled, or exported.
16188 16385
16189@itemize @bullet 16386@itemize @bullet
16190@item @code{no} 16387@item @code{no}
16191Default. No expansion of ``Noweb'' syntax references in the body of the code 16388Default. No expansion of Noweb syntax references in the body of the code
16192when evaluating, tangling, or exporting. 16389when evaluating, tangling, or exporting.
16193@item @code{yes} 16390@item @code{yes}
16194Expansion of ``Noweb'' syntax references in the body of the @samp{src} code 16391Expansion of Noweb syntax references in the body of the @samp{src} code block
16195block when evaluating, tangling, or exporting. 16392when evaluating, tangling, or exporting.
16196@item @code{tangle} 16393@item @code{tangle}
16197Expansion of ``Noweb'' syntax references in the body of the @samp{src} code 16394Expansion of Noweb syntax references in the body of the @samp{src} code block
16198block when tangling. No expansion when evaluating or exporting. 16395when tangling. No expansion when evaluating or exporting.
16199@item @code{no-export} 16396@item @code{no-export}
16200Expansion of ``Noweb'' syntax references in the body of the @samp{src} code 16397Expansion of Noweb syntax references in the body of the @samp{src} code block
16201block when evaluating or tangling. No expansion when exporting. 16398when evaluating or tangling. No expansion when exporting.
16202@item @code{strip-export} 16399@item @code{strip-export}
16203Expansion of ``Noweb'' syntax references in the body of the @samp{src} code 16400Expansion of Noweb syntax references in the body of the @samp{src} code block
16204block when expanding prior to evaluating or tangling. Removes ``noweb'' 16401when expanding prior to evaluating or tangling. Removes Noweb syntax
16205syntax references when exporting. 16402references when exporting.
16206@item @code{eval} 16403@item @code{eval}
16207Expansion of ``Noweb'' syntax references in the body of the @samp{src} code 16404Expansion of Noweb syntax references in the body of the @samp{src} code block
16208block only before evaluating. 16405only before evaluating.
16209@end itemize 16406@end itemize
16210 16407
16211@subsubheading Noweb prefix lines 16408@subsubheading Noweb prefix lines
16212Noweb insertions now honor prefix characters that appear before 16409Noweb insertions now honor prefix characters that appear before the Noweb
16213@code{<<reference>>}. This behavior is illustrated in the following example. 16410syntax reference.
16214Because the @code{<<example>>} noweb reference appears behind the SQL comment 16411
16215syntax, each line of the expanded noweb reference will be commented. 16412This behavior is illustrated in the following example. Because the
16413@code{<<example>>} noweb reference appears behind the SQL comment syntax,
16414each line of the expanded noweb reference will be commented.
16415
16416With:
16216 16417
16217This @samp{src} code block: 16418@example
16419#+NAME: example
16420#+BEGIN_SRC text
16421this is the
16422multi-line body of example
16423#+END_SRC
16424@end example
16425
16426this @samp{src} code block:
16218 16427
16219@example 16428@example
16429#+BEGIN_SRC sql :noweb yes
16220-- <<example>> 16430-- <<example>>
16431#+END_SRC
16221@end example 16432@end example
16222 16433
16223expands to: 16434expands to:
@@ -16230,17 +16441,60 @@ expands to:
16230Since this change will not affect noweb replacement text without newlines in 16441Since this change will not affect noweb replacement text without newlines in
16231them, inline noweb references are acceptable. 16442them, inline noweb references are acceptable.
16232 16443
16444This feature can also be used for management of indentation in exported code snippets.
16445
16446With:
16447
16448@example
16449#+NAME: if-true
16450#+BEGIN_SRC python :exports none
16451print('Do things when True')
16452#+END_SRC
16453
16454#+NAME: if-false
16455#+BEGIN_SRC python :exports none
16456print('Do things when False')
16457#+END_SRC
16458@end example
16459
16460this @samp{src} code block:
16461
16462@example
16463#+BEGIN_SRC python :noweb yes :results output
16464if True:
16465 <<if-true>>
16466else:
16467 <<if-false>>
16468#+END_SRC
16469@end example
16470
16471expands to:
16472
16473@example
16474if True:
16475 print('Do things when True')
16476else:
16477 print('Do things when False')
16478@end example
16479
16480and evaluates to:
16481
16482@example
16483Do things when True
16484@end example
16485
16233@node noweb-ref 16486@node noweb-ref
16234@subsubsection @code{:noweb-ref} 16487@subsubsection @code{:noweb-ref}
16235@cindex @code{:noweb-ref}, src header argument 16488@cindex @code{:noweb-ref}, src header argument
16236 16489
16237When expanding ``noweb'' style references, Org concatenates @samp{src} code 16490When expanding Noweb style references, Org concatenates @samp{src} code
16238blocks by matching the reference name to either the block name or the 16491blocks by matching the reference name to either the code block name or the
16239@code{:noweb-ref} header argument. 16492@code{:noweb-ref} header argument.
16240 16493
16241For simple concatenation, set this @code{:noweb-ref} header argument at the 16494For simple concatenation, set this @code{:noweb-ref} header argument at the
16242sub-tree or file level. In the example Org file shown next, the body of the 16495sub-tree or file level. In the example Org file shown next, the body of the
16243source code in each block is extracted for concatenation to a pure code file. 16496source code in each block is extracted for concatenation to a pure code file
16497when tangled.
16244 16498
16245@example 16499@example
16246 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh 16500 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
@@ -16300,8 +16554,8 @@ A note of warning: when @code{:cache} is used for a @code{:session}, caching
16300may cause unexpected results. 16554may cause unexpected results.
16301 16555
16302When the caching mechanism tests for any source code changes, it will not 16556When the caching mechanism tests for any source code changes, it will not
16303expand ``noweb'' style references (@pxref{Noweb reference syntax}). For 16557expand Noweb style references (@pxref{Noweb reference syntax}). For reasons
16304reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}. 16558why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}.
16305 16559
16306The @code{:cache} header argument can have one of two values: @code{yes} or 16560The @code{:cache} header argument can have one of two values: @code{yes} or
16307@code{no}. 16561@code{no}.
@@ -16743,38 +16997,80 @@ prints ``2''. Results show that.
16743@cindex syntax, noweb 16997@cindex syntax, noweb
16744@cindex source code, noweb reference 16998@cindex source code, noweb reference
16745 16999
16746Org supports named blocks in ``noweb'' style syntax. For ``noweb'' literate 17000Org supports named blocks in Noweb style syntax. For Noweb literate
16747programming details, see @uref{http://www.cs.tufts.edu/~nr/noweb/}). 17001programming details, see @uref{http://www.cs.tufts.edu/~nr/noweb/}).
16748 17002
16749@example 17003@example
16750<<code-block-name>> 17004<<code-block-name>>
16751@end example 17005@end example
16752 17006
16753For the header argument @code{:noweb yes}, Org expands ``noweb'' style 17007For the header argument @code{:noweb yes}, Org expands Noweb style references
16754references in the @samp{src} code block before evaluation. 17008in the @samp{src} code block before evaluation.
16755 17009
16756For the header argument @code{:noweb no}, Org does not expand ``noweb'' style 17010For the header argument @code{:noweb no}, Org does not expand Noweb style
16757references in the @samp{src} code block before evaluation. 17011references in the @samp{src} code block before evaluation.
16758 17012
16759The default is @code{:noweb no}. 17013The default is @code{:noweb no}. Org defaults to @code{:noweb no} so as not
17014to cause errors in languages where Noweb syntax is ambiguous. Change Org's
17015default to @code{:noweb yes} for languages where there is no risk of
17016confusion.
16760 17017
16761Org offers a more flexible way to resolve ``noweb'' style references 17018Org offers a more flexible way to resolve Noweb style references
16762(@pxref{noweb-ref}). 17019(@pxref{noweb-ref}).
16763 17020
16764Org can handle naming of @emph{results} block, rather than the body of the 17021Org can include the @emph{results} of a code block rather than its body. To
16765@samp{src} code block, using ``noweb'' style references. 17022that effect, append parentheses, possibly including arguments, to the code
16766 17023block name, as show below.
16767For ``noweb'' style reference, append parenthesis to the code block name for
16768arguments, as shown in this example:
16769 17024
16770@example 17025@example
16771<<code-block-name(optional arguments)>> 17026<<code-block-name(optional arguments)>>
16772@end example 17027@end example
16773 17028
16774Note: Org defaults to @code{:noweb no} so as not to cause errors in languages 17029Note that when using the above approach to a code block's results, the code
16775such as @samp{Ruby} where ``noweb'' syntax is equally valid characters. For 17030block name set by @code{#+NAME} keyword is required; the reference set by
16776example, @code{<<arg>>}. Change Org's default to @code{:noweb yes} for 17031@code{:noweb-ref} will not work.
16777languages where there is no risk of confusion. 17032
17033Here is an example that demonstrates how the exported content changes when
17034Noweb style references are used with parentheses versus without.
17035
17036With:
17037
17038@example
17039#+NAME: some-code
17040#+BEGIN_SRC python :var num=0 :results output :exports none
17041print(num*10)
17042#+END_SRC
17043@end example
17044
17045this code block:
17046
17047@example
17048#+BEGIN_SRC text :noweb yes
17049<<some-code>>
17050#+END_SRC
17051@end example
17052
17053expands to:
17054
17055@example
17056print(num*10)
17057@end example
17058
17059Below, a similar Noweb style reference is used, but with parentheses, while
17060setting a variable @code{num} to 10:
17061
17062@example
17063#+BEGIN_SRC text :noweb yes
17064<<some-code(num=10)>>
17065#+END_SRC
17066@end example
17067
17068Note that now the expansion contains the @emph{results} of the code block
17069@code{some-code}, not the code block itself:
17070
17071@example
17072100
17073@end example
16778 17074
16779For faster tangling of large Org mode files, set 17075For faster tangling of large Org mode files, set
16780@code{org-babel-use-quick-and-dirty-noweb-expansion} variable to @code{t}. 17076@code{org-babel-use-quick-and-dirty-noweb-expansion} variable to @code{t}.
@@ -17004,12 +17300,9 @@ structural elements, such as @code{#+BEGIN_SRC} and @code{#+END_SRC}. Easy
17004templates use an expansion mechanism, which is native to Org, in a process 17300templates use an expansion mechanism, which is native to Org, in a process
17005similar to @file{yasnippet} and other Emacs template expansion packages. 17301similar to @file{yasnippet} and other Emacs template expansion packages.
17006 17302
17007@kbd{@key{<}} @kbd{@key{s}} @kbd{@key{TAB}} completes the @samp{src} code 17303@kbd{<} @kbd{s} @kbd{@key{TAB}} expands to a @samp{src} code block.
17008block.
17009
17010@kbd{<} @kbd{l} @kbd{@key{TAB}}
17011 17304
17012expands to: 17305@kbd{<} @kbd{l} @kbd{@key{TAB}} expands to:
17013 17306
17014#+BEGIN_EXPORT latex 17307#+BEGIN_EXPORT latex
17015 17308
@@ -17082,7 +17375,7 @@ Org evaluates code in the following circumstances:
17082Org evaluates @samp{src} code blocks in an Org file during export. Org also 17375Org evaluates @samp{src} code blocks in an Org file during export. Org also
17083evaluates a @samp{src} code block with the @kbd{C-c C-c} key chord. Users 17376evaluates a @samp{src} code block with the @kbd{C-c C-c} key chord. Users
17084exporting or running code blocks must load files only from trusted sources. 17377exporting or running code blocks must load files only from trusted sources.
17085Be weary of customizing variables that remove or alter default security 17378Be wary of customizing variables that remove or alter default security
17086measures. 17379measures.
17087 17380
17088@defopt org-confirm-babel-evaluate 17381@defopt org-confirm-babel-evaluate