diff options
| author | Rasmus | 2017-08-29 10:07:08 +0200 |
|---|---|---|
| committer | Rasmus | 2017-08-29 10:13:31 +0200 |
| commit | 3ad8ca429bac5e1354881cf4411d6f41dab36b44 (patch) | |
| tree | 41d8dc789a212dc3b1e09f402714b09dc1462fc5 /doc | |
| parent | c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 (diff) | |
| download | emacs-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.texi | 427 |
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 | ||
| 503 | Protocols 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 | |||
| 502 | Archiving | 509 | Archiving |
| 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 | |||
| 830 | export backends can be derived from existing ones, or defined from scratch. | 837 | export backends can be derived from existing ones, or defined from scratch. |
| 831 | 838 | ||
| 832 | Org files can include source code blocks, which makes Org uniquely suited for | 839 | Org files can include source code blocks, which makes Org uniquely suited for |
| 833 | authoring technical documents with code examples. Org source code blocks are | 840 | authoring technical documents with code examples. Org source code blocks are |
| 834 | fully functional; they can be evaluated in place and their results can be | 841 | fully functional; they can be evaluated in place and their results can be |
| 835 | captured in the file. This makes it possible to create a single file | 842 | captured in the file. This makes it possible to create a single file |
| 836 | reproducible research compendium. | 843 | reproducible 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 | ||
| 7510 | You can set up Org for handling protocol calls from outside applications that | 7520 | Org protocol is a mean to trigger custom actions in Emacs from external |
| 7511 | are passed to Emacs through the @file{emacsserver}. For example, you can | 7521 | applications. Any application that supports calling external programs with |
| 7522 | an URL as argument may be used with this functionality. For example, you can | ||
| 7512 | configure bookmarks in your web browser to send a link to the current page to | 7523 | configure bookmarks in your web browser to send a link to the current page to |
| 7513 | Org and create a note from it using capture (@pxref{Capture}). Or you | 7524 | Org and create a note from it using capture (@pxref{Capture}). You can also |
| 7514 | could create a bookmark that will tell Emacs to open the local source file of | 7525 | create a bookmark that tells Emacs to open the local source file of a remote |
| 7515 | a remote website you are looking at with the browser. See | 7526 | website you are browsing. |
| 7516 | @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed | 7527 | |
| 7517 | documentation and setup instructions. | 7528 | @cindex Org protocol, set-up |
| 7529 | @cindex Installing Org protocol | ||
| 7530 | In 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 | ||
| 7532 | to Emacs through the @code{emacsclient} command, so you also need to ensure | ||
| 7533 | an Emacs server is running. More precisely, when the application calls | ||
| 7534 | |||
| 7535 | @example | ||
| 7536 | emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2 | ||
| 7537 | @end example | ||
| 7538 | |||
| 7539 | @noindent | ||
| 7540 | Emacs 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 | ||
| 7545 | Org protocol comes with three predefined protocols, detailed in the following | ||
| 7546 | sections. 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 | |||
| 7559 | Using @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 | ||
| 7563 | emacsclient org-protocol://store-link?url=URL&title=TITLE | ||
| 7564 | @end example | ||
| 7565 | |||
| 7566 | @noindent | ||
| 7567 | stores the following link: | ||
| 7568 | |||
| 7569 | @example | ||
| 7570 | [[URL][TITLE]] | ||
| 7571 | @end example | ||
| 7572 | |||
| 7573 | In addition, @samp{URL} is pushed on the kill-ring for yanking. You need to | ||
| 7574 | encode @samp{URL} and @samp{TITLE} if they contain slashes, and probably | ||
| 7575 | quote those for the shell. | ||
| 7576 | |||
| 7577 | To use this feature from a browser, add a bookmark with an arbitrary name, | ||
| 7578 | e.g., @samp{Org: store-link} and enter this as @emph{Location}: | ||
| 7579 | |||
| 7580 | @example | ||
| 7581 | javascript: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 | ||
| 7594 | Activating @code{capture} handler pops up a @samp{Capture} buffer and fills | ||
| 7595 | the capture template associated to the @samp{X} key with them. The template | ||
| 7596 | refers to the data through @code{%:url} and @code{%:title} placeholders. | ||
| 7597 | Moreover, any selected text in the browser is appended to the body of the | ||
| 7598 | entry. | ||
| 7599 | |||
| 7600 | @example | ||
| 7601 | emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY | ||
| 7602 | @end example | ||
| 7603 | |||
| 7604 | To 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 | ||
| 7608 | javascript: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 | ||
| 7615 | The result depends on the capture template used, which is set in the bookmark | ||
| 7616 | itself, 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 | |||
| 7624 | The @code{open-source} handler is designed to help with editing local sources | ||
| 7625 | when reading a document. To that effect, you can use a bookmark with the | ||
| 7626 | following location: | ||
| 7627 | |||
| 7628 | @example | ||
| 7629 | javascript: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 | ||
| 7642 | The variable @code{org-protocol-project-alist} maps URLs to local file names, | ||
| 7643 | by stripping URL parameters from the end and replacing the @code{:base-url} | ||
| 7644 | with @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 | ||
| 7647 | set @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 | ||
| 7659 | If you are now browsing | ||
| 7660 | @url{http://orgmode.org/worg/org-contrib/org-protocol.html} and find a typo | ||
| 7661 | or have an idea about how to enhance the documentation, simply click the | ||
| 7662 | bookmark and start editing. | ||
| 7663 | |||
| 7664 | @cindex handle rewritten URL in open-source protocol | ||
| 7665 | @cindex protocol, open-source rewritten URL | ||
| 7666 | However, such mapping may not yield the desired results. Suppose you | ||
| 7667 | maintain an online store located at @url{http://example.com/}. The local | ||
| 7668 | sources reside in @file{/home/user/example/}. It is common practice to serve | ||
| 7669 | all products in such a store through one file and rewrite URLs that do not | ||
| 7670 | match 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 | ||
| 7672 | to 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 | ||
| 7679 | Such an entry in @code{org-protocol-project-alist} may hold an additional | ||
| 7680 | property @code{:rewrites}. This property is a list of cons cells, each of | ||
| 7681 | which maps a regular expression to a path relative to the | ||
| 7682 | @code{:working-directory}. | ||
| 7683 | |||
| 7684 | Now 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 | ||
| 7699 | Since @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 | |||
| 7704 | The @code{:rewrites} rules are searched as a last resort if and only if no | ||
| 7705 | existing 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 | ||
| 7711 | Two functions can help you filling @code{org-protocol-project-alist} with | ||
| 7712 | valid contents: @code{org-protocol-create} and | ||
| 7713 | @code{org-protocol-create-for-org}. The latter is of use if you're editing | ||
| 7714 | an 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 | ||
| 8083 | That will give you three days' warning: on the anniversary date itself and the | 8280 | That will give you three days' warning: on the anniversary date itself and the |
| 8084 | two days prior. The argument is optional: if omitted, it defaults to 7. | 8281 | two 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''. | |||
| 11443 | Org's HTML exporter does not by default enable new block elements introduced | 11640 | Org's HTML exporter does not by default enable new block elements introduced |
| 11444 | with the HTML5 standard. To enable them, set @code{org-html-html5-fancy} to | 11641 | with the HTML5 standard. To enable them, set @code{org-html-html5-fancy} to |
| 11445 | non-@code{nil}. Or use an @code{OPTIONS} line in the file to set | 11642 | non-@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} |
| 11447 | blocks. For example: | 11644 | and @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. | |||
| 13590 | Copyright information is printed on the back of the title page. | 13787 | Copyright 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. | |||
| 15142 | When Org tangles @samp{src} code blocks, it expands, merges, and transforms | 15339 | When Org tangles @samp{src} code blocks, it expands, merges, and transforms |
| 15143 | them. Then Org recomposes them into one or more separate files, as | 15340 | them. Then Org recomposes them into one or more separate files, as |
| 15144 | configured through the options. During this @emph{tangling} process, Org | 15341 | configured through the options. During this @emph{tangling} process, Org |
| 15145 | expands variables in the source code, and resolves any ``noweb'' style | 15342 | expands variables in the source code, and resolves any Noweb style references |
| 15146 | references (@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: | |||
| 15319 | Additional documentation for some languages are at | 15516 | Additional 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 | ||
| 15322 | By default, only @code{emacs-lisp} is enabled for evaluation. To enable or | 15520 | By default, only @code{emacs-lisp} is enabled for evaluation. To enable or |
| 15323 | disable other languages, customize the @code{org-babel-load-languages} | 15521 | disable other languages, customize the @code{org-babel-load-languages} |
| 15324 | variable either through the Emacs customization interface, or by adding code | 15522 | variable 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. | |||
| 16148 | By default Org expands @samp{src} code blocks during tangling. The | 16346 | By 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 |
| 16150 | side-effect of expansion by @code{org-babel-expand-src-block} also assigns | 16348 | side-effect of expansion by @code{org-babel-expand-src-block} also assigns |
| 16151 | values to @code{:var} (@pxref{var}) variables. Expansions also replace | 16349 | values to @code{:var} (@pxref{var}) variables. Expansions also replace Noweb |
| 16152 | ``noweb'' references with their targets (@pxref{Noweb reference syntax}). | 16350 | references with their targets (@pxref{Noweb reference syntax}). Some of |
| 16153 | Some of these expansions may cause premature assignment, hence this option. | 16351 | these expansions may cause premature assignment, hence this option. This |
| 16154 | This option makes a difference only for tangling. It has no effect when | 16352 | option makes a difference only for tangling. It has no effect when exporting |
| 16155 | exporting since @samp{src} code blocks for execution have to be expanded | 16353 | since @samp{src} code blocks for execution have to be expanded anyway. |
| 16156 | anyway. | ||
| 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 | ||
| 16185 | The @code{:noweb} header argument controls expansion of ``noweb'' syntax | 16382 | The @code{:noweb} header argument controls expansion of Noweb syntax |
| 16186 | references (@pxref{Noweb reference syntax}). Expansions occur when source | 16383 | references (@pxref{Noweb reference syntax}). Expansions occur when source |
| 16187 | code blocks are evaluated, tangled, or exported. | 16384 | code blocks are evaluated, tangled, or exported. |
| 16188 | 16385 | ||
| 16189 | @itemize @bullet | 16386 | @itemize @bullet |
| 16190 | @item @code{no} | 16387 | @item @code{no} |
| 16191 | Default. No expansion of ``Noweb'' syntax references in the body of the code | 16388 | Default. No expansion of Noweb syntax references in the body of the code |
| 16192 | when evaluating, tangling, or exporting. | 16389 | when evaluating, tangling, or exporting. |
| 16193 | @item @code{yes} | 16390 | @item @code{yes} |
| 16194 | Expansion of ``Noweb'' syntax references in the body of the @samp{src} code | 16391 | Expansion of Noweb syntax references in the body of the @samp{src} code block |
| 16195 | block when evaluating, tangling, or exporting. | 16392 | when evaluating, tangling, or exporting. |
| 16196 | @item @code{tangle} | 16393 | @item @code{tangle} |
| 16197 | Expansion of ``Noweb'' syntax references in the body of the @samp{src} code | 16394 | Expansion of Noweb syntax references in the body of the @samp{src} code block |
| 16198 | block when tangling. No expansion when evaluating or exporting. | 16395 | when tangling. No expansion when evaluating or exporting. |
| 16199 | @item @code{no-export} | 16396 | @item @code{no-export} |
| 16200 | Expansion of ``Noweb'' syntax references in the body of the @samp{src} code | 16397 | Expansion of Noweb syntax references in the body of the @samp{src} code block |
| 16201 | block when evaluating or tangling. No expansion when exporting. | 16398 | when evaluating or tangling. No expansion when exporting. |
| 16202 | @item @code{strip-export} | 16399 | @item @code{strip-export} |
| 16203 | Expansion of ``Noweb'' syntax references in the body of the @samp{src} code | 16400 | Expansion of Noweb syntax references in the body of the @samp{src} code block |
| 16204 | block when expanding prior to evaluating or tangling. Removes ``noweb'' | 16401 | when expanding prior to evaluating or tangling. Removes Noweb syntax |
| 16205 | syntax references when exporting. | 16402 | references when exporting. |
| 16206 | @item @code{eval} | 16403 | @item @code{eval} |
| 16207 | Expansion of ``Noweb'' syntax references in the body of the @samp{src} code | 16404 | Expansion of Noweb syntax references in the body of the @samp{src} code block |
| 16208 | block only before evaluating. | 16405 | only before evaluating. |
| 16209 | @end itemize | 16406 | @end itemize |
| 16210 | 16407 | ||
| 16211 | @subsubheading Noweb prefix lines | 16408 | @subsubheading Noweb prefix lines |
| 16212 | Noweb insertions now honor prefix characters that appear before | 16409 | Noweb insertions now honor prefix characters that appear before the Noweb |
| 16213 | @code{<<reference>>}. This behavior is illustrated in the following example. | 16410 | syntax reference. |
| 16214 | Because the @code{<<example>>} noweb reference appears behind the SQL comment | 16411 | |
| 16215 | syntax, each line of the expanded noweb reference will be commented. | 16412 | This behavior is illustrated in the following example. Because the |
| 16413 | @code{<<example>>} noweb reference appears behind the SQL comment syntax, | ||
| 16414 | each line of the expanded noweb reference will be commented. | ||
| 16415 | |||
| 16416 | With: | ||
| 16216 | 16417 | ||
| 16217 | This @samp{src} code block: | 16418 | @example |
| 16419 | #+NAME: example | ||
| 16420 | #+BEGIN_SRC text | ||
| 16421 | this is the | ||
| 16422 | multi-line body of example | ||
| 16423 | #+END_SRC | ||
| 16424 | @end example | ||
| 16425 | |||
| 16426 | this @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 | ||
| 16223 | expands to: | 16434 | expands to: |
| @@ -16230,17 +16441,60 @@ expands to: | |||
| 16230 | Since this change will not affect noweb replacement text without newlines in | 16441 | Since this change will not affect noweb replacement text without newlines in |
| 16231 | them, inline noweb references are acceptable. | 16442 | them, inline noweb references are acceptable. |
| 16232 | 16443 | ||
| 16444 | This feature can also be used for management of indentation in exported code snippets. | ||
| 16445 | |||
| 16446 | With: | ||
| 16447 | |||
| 16448 | @example | ||
| 16449 | #+NAME: if-true | ||
| 16450 | #+BEGIN_SRC python :exports none | ||
| 16451 | print('Do things when True') | ||
| 16452 | #+END_SRC | ||
| 16453 | |||
| 16454 | #+NAME: if-false | ||
| 16455 | #+BEGIN_SRC python :exports none | ||
| 16456 | print('Do things when False') | ||
| 16457 | #+END_SRC | ||
| 16458 | @end example | ||
| 16459 | |||
| 16460 | this @samp{src} code block: | ||
| 16461 | |||
| 16462 | @example | ||
| 16463 | #+BEGIN_SRC python :noweb yes :results output | ||
| 16464 | if True: | ||
| 16465 | <<if-true>> | ||
| 16466 | else: | ||
| 16467 | <<if-false>> | ||
| 16468 | #+END_SRC | ||
| 16469 | @end example | ||
| 16470 | |||
| 16471 | expands to: | ||
| 16472 | |||
| 16473 | @example | ||
| 16474 | if True: | ||
| 16475 | print('Do things when True') | ||
| 16476 | else: | ||
| 16477 | print('Do things when False') | ||
| 16478 | @end example | ||
| 16479 | |||
| 16480 | and evaluates to: | ||
| 16481 | |||
| 16482 | @example | ||
| 16483 | Do 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 | ||
| 16237 | When expanding ``noweb'' style references, Org concatenates @samp{src} code | 16490 | When expanding Noweb style references, Org concatenates @samp{src} code |
| 16238 | blocks by matching the reference name to either the block name or the | 16491 | blocks 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 | ||
| 16241 | For simple concatenation, set this @code{:noweb-ref} header argument at the | 16494 | For simple concatenation, set this @code{:noweb-ref} header argument at the |
| 16242 | sub-tree or file level. In the example Org file shown next, the body of the | 16495 | sub-tree or file level. In the example Org file shown next, the body of the |
| 16243 | source code in each block is extracted for concatenation to a pure code file. | 16496 | source code in each block is extracted for concatenation to a pure code file |
| 16497 | when 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 | |||
| 16300 | may cause unexpected results. | 16554 | may cause unexpected results. |
| 16301 | 16555 | ||
| 16302 | When the caching mechanism tests for any source code changes, it will not | 16556 | When the caching mechanism tests for any source code changes, it will not |
| 16303 | expand ``noweb'' style references (@pxref{Noweb reference syntax}). For | 16557 | expand Noweb style references (@pxref{Noweb reference syntax}). For reasons |
| 16304 | reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}. | 16558 | why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}. |
| 16305 | 16559 | ||
| 16306 | The @code{:cache} header argument can have one of two values: @code{yes} or | 16560 | The @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 | ||
| 16746 | Org supports named blocks in ``noweb'' style syntax. For ``noweb'' literate | 17000 | Org supports named blocks in Noweb style syntax. For Noweb literate |
| 16747 | programming details, see @uref{http://www.cs.tufts.edu/~nr/noweb/}). | 17001 | programming 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 | ||
| 16753 | For the header argument @code{:noweb yes}, Org expands ``noweb'' style | 17007 | For the header argument @code{:noweb yes}, Org expands Noweb style references |
| 16754 | references in the @samp{src} code block before evaluation. | 17008 | in the @samp{src} code block before evaluation. |
| 16755 | 17009 | ||
| 16756 | For the header argument @code{:noweb no}, Org does not expand ``noweb'' style | 17010 | For the header argument @code{:noweb no}, Org does not expand Noweb style |
| 16757 | references in the @samp{src} code block before evaluation. | 17011 | references in the @samp{src} code block before evaluation. |
| 16758 | 17012 | ||
| 16759 | The default is @code{:noweb no}. | 17013 | The default is @code{:noweb no}. Org defaults to @code{:noweb no} so as not |
| 17014 | to cause errors in languages where Noweb syntax is ambiguous. Change Org's | ||
| 17015 | default to @code{:noweb yes} for languages where there is no risk of | ||
| 17016 | confusion. | ||
| 16760 | 17017 | ||
| 16761 | Org offers a more flexible way to resolve ``noweb'' style references | 17018 | Org offers a more flexible way to resolve Noweb style references |
| 16762 | (@pxref{noweb-ref}). | 17019 | (@pxref{noweb-ref}). |
| 16763 | 17020 | ||
| 16764 | Org can handle naming of @emph{results} block, rather than the body of the | 17021 | Org can include the @emph{results} of a code block rather than its body. To |
| 16765 | @samp{src} code block, using ``noweb'' style references. | 17022 | that effect, append parentheses, possibly including arguments, to the code |
| 16766 | 17023 | block name, as show below. | |
| 16767 | For ``noweb'' style reference, append parenthesis to the code block name for | ||
| 16768 | arguments, 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 | ||
| 16774 | Note: Org defaults to @code{:noweb no} so as not to cause errors in languages | 17029 | Note that when using the above approach to a code block's results, the code |
| 16775 | such as @samp{Ruby} where ``noweb'' syntax is equally valid characters. For | 17030 | block name set by @code{#+NAME} keyword is required; the reference set by |
| 16776 | example, @code{<<arg>>}. Change Org's default to @code{:noweb yes} for | 17031 | @code{:noweb-ref} will not work. |
| 16777 | languages where there is no risk of confusion. | 17032 | |
| 17033 | Here is an example that demonstrates how the exported content changes when | ||
| 17034 | Noweb style references are used with parentheses versus without. | ||
| 17035 | |||
| 17036 | With: | ||
| 17037 | |||
| 17038 | @example | ||
| 17039 | #+NAME: some-code | ||
| 17040 | #+BEGIN_SRC python :var num=0 :results output :exports none | ||
| 17041 | print(num*10) | ||
| 17042 | #+END_SRC | ||
| 17043 | @end example | ||
| 17044 | |||
| 17045 | this code block: | ||
| 17046 | |||
| 17047 | @example | ||
| 17048 | #+BEGIN_SRC text :noweb yes | ||
| 17049 | <<some-code>> | ||
| 17050 | #+END_SRC | ||
| 17051 | @end example | ||
| 17052 | |||
| 17053 | expands to: | ||
| 17054 | |||
| 17055 | @example | ||
| 17056 | print(num*10) | ||
| 17057 | @end example | ||
| 17058 | |||
| 17059 | Below, a similar Noweb style reference is used, but with parentheses, while | ||
| 17060 | setting 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 | |||
| 17068 | Note that now the expansion contains the @emph{results} of the code block | ||
| 17069 | @code{some-code}, not the code block itself: | ||
| 17070 | |||
| 17071 | @example | ||
| 17072 | 100 | ||
| 17073 | @end example | ||
| 16778 | 17074 | ||
| 16779 | For faster tangling of large Org mode files, set | 17075 | For 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 | |||
| 17004 | templates use an expansion mechanism, which is native to Org, in a process | 17300 | templates use an expansion mechanism, which is native to Org, in a process |
| 17005 | similar to @file{yasnippet} and other Emacs template expansion packages. | 17301 | similar 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. |
| 17008 | block. | ||
| 17009 | |||
| 17010 | @kbd{<} @kbd{l} @kbd{@key{TAB}} | ||
| 17011 | 17304 | ||
| 17012 | expands 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: | |||
| 17082 | Org evaluates @samp{src} code blocks in an Org file during export. Org also | 17375 | Org evaluates @samp{src} code blocks in an Org file during export. Org also |
| 17083 | evaluates a @samp{src} code block with the @kbd{C-c C-c} key chord. Users | 17376 | evaluates a @samp{src} code block with the @kbd{C-c C-c} key chord. Users |
| 17084 | exporting or running code blocks must load files only from trusted sources. | 17377 | exporting or running code blocks must load files only from trusted sources. |
| 17085 | Be weary of customizing variables that remove or alter default security | 17378 | Be wary of customizing variables that remove or alter default security |
| 17086 | measures. | 17379 | measures. |
| 17087 | 17380 | ||
| 17088 | @defopt org-confirm-babel-evaluate | 17381 | @defopt org-confirm-babel-evaluate |