aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus2017-08-29 10:07:08 +0200
committerRasmus2017-08-29 10:13:31 +0200
commit3ad8ca429bac5e1354881cf4411d6f41dab36b44 (patch)
tree41d8dc789a212dc3b1e09f402714b09dc1462fc5
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.
-rw-r--r--doc/misc/org.texi427
-rw-r--r--etc/ORG-NEWS2
-rw-r--r--etc/refcards/orgcard.tex4
-rw-r--r--lisp/org/ob-comint.el5
-rw-r--r--lisp/org/ob-core.el53
-rw-r--r--lisp/org/ob-emacs-lisp.el53
-rw-r--r--lisp/org/org-agenda.el17
-rw-r--r--lisp/org/org-capture.el52
-rw-r--r--lisp/org/org-clock.el74
-rw-r--r--lisp/org/org-compat.el12
-rw-r--r--lisp/org/org-element.el33
-rw-r--r--lisp/org/org-indent.el10
-rw-r--r--lisp/org/org-irc.el3
-rw-r--r--lisp/org/org-lint.el2
-rw-r--r--lisp/org/org-macro.el98
-rw-r--r--lisp/org/org-macs.el37
-rw-r--r--lisp/org/org-mobile.el4
-rw-r--r--lisp/org/org-protocol.el6
-rw-r--r--lisp/org/org-src.el21
-rw-r--r--lisp/org/org-table.el39
-rw-r--r--lisp/org/org-version.el4
-rw-r--r--lisp/org/org.el524
-rw-r--r--lisp/org/ox-html.el3
-rw-r--r--lisp/org/ox-icalendar.el12
-rw-r--r--lisp/org/ox-latex.el18
-rw-r--r--lisp/org/ox-md.el7
-rw-r--r--lisp/org/ox-odt.el75
-rw-r--r--lisp/org/ox.el13
28 files changed, 982 insertions, 626 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
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index f8399dbf1e8..ff1000e78ef 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -157,7 +157,7 @@ should be written instead
157,* Headline 157,* Headline
158:PROPERTIES: 158:PROPERTIES:
159:header-args: :exports code 159:header-args: :exports code
160:header-args: :var a=1 b=2 160:header-args+: :var a=1 b=2
161:header-args+: :var c=3 161:header-args+: :var c=3
162:END: 162:END:
163#+END_EXAMPLE 163#+END_EXAMPLE
diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex
index 0170a18abce..1c4f4501c15 100644
--- a/etc/refcards/orgcard.tex
+++ b/etc/refcards/orgcard.tex
@@ -1,7 +1,7 @@
1% Reference Card for Org Mode 1% Reference Card for Org Mode
2\def\orgversionnumber{9.0.9} 2\def\orgversionnumber{9.0.10}
3\def\versionyear{2017} % latest update 3\def\versionyear{2017} % latest update
4\input emacsver.tex 4\def\year{2017} % latest copyright year
5 5
6%**start of header 6%**start of header
7\newcount\columnsperpage 7\newcount\columnsperpage
diff --git a/lisp/org/ob-comint.el b/lisp/org/ob-comint.el
index cc60f4e4a73..7b218081fad 100644
--- a/lisp/org/ob-comint.el
+++ b/lisp/org/ob-comint.el
@@ -33,7 +33,6 @@
33(require 'ob-core) 33(require 'ob-core)
34(require 'org-compat) 34(require 'org-compat)
35(require 'comint) 35(require 'comint)
36(require 'tramp)
37 36
38(defun org-babel-comint-buffer-livep (buffer) 37(defun org-babel-comint-buffer-livep (buffer)
39 "Check if BUFFER is a comint buffer with a live process." 38 "Check if BUFFER is a comint buffer with a live process."
@@ -148,10 +147,6 @@ FILE exists at end of evaluation."
148 (process-send-string 147 (process-send-string
149 (get-buffer-process buffer) 148 (get-buffer-process buffer)
150 (if (= (aref string (1- (length string))) ?\n) string (concat string "\n"))) 149 (if (= (aref string (1- (length string))) ?\n) string (concat string "\n")))
151 ;; From Tramp 2.1.19 the following cache flush is not necessary
152 (when (file-remote-p default-directory)
153 (with-parsed-tramp-file-name default-directory nil
154 (tramp-flush-directory-property v "")))
155 (while (not (file-exists-p file)) (sit-for (or period 0.25)))) 150 (while (not (file-exists-p file)) (sit-for (or period 0.25))))
156 151
157(provide 'ob-comint) 152(provide 'ob-comint)
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index c630b70f91f..527fb2204ad 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -1752,16 +1752,20 @@ NAME, or nil if no such block exists. Set match data according
1752to `org-babel-named-src-block-regexp'." 1752to `org-babel-named-src-block-regexp'."
1753 (save-excursion 1753 (save-excursion
1754 (goto-char (point-min)) 1754 (goto-char (point-min))
1755 (ignore-errors 1755 (let ((regexp (org-babel-named-src-block-regexp-for-name name)))
1756 (org-next-block 1 nil (org-babel-named-src-block-regexp-for-name name))))) 1756 (or (and (looking-at regexp)
1757 (progn (goto-char (match-beginning 1))
1758 (line-beginning-position)))
1759 (ignore-errors (org-next-block 1 nil regexp))))))
1757 1760
1758(defun org-babel-src-block-names (&optional file) 1761(defun org-babel-src-block-names (&optional file)
1759 "Returns the names of source blocks in FILE or the current buffer." 1762 "Returns the names of source blocks in FILE or the current buffer."
1760 (when file (find-file file)) 1763 (when file (find-file file))
1761 (save-excursion 1764 (save-excursion
1762 (goto-char (point-min)) 1765 (goto-char (point-min))
1763 (let ((re (org-babel-named-src-block-regexp-for-name)) 1766 (let* ((re (org-babel-named-src-block-regexp-for-name))
1764 names) 1767 (names (and (looking-at re)
1768 (list (match-string-no-properties 9)))))
1765 (while (ignore-errors (org-next-block 1 nil re)) 1769 (while (ignore-errors (org-next-block 1 nil re))
1766 (push (match-string-no-properties 9) names)) 1770 (push (match-string-no-properties 9) names))
1767 names))) 1771 names)))
@@ -2269,21 +2273,22 @@ INFO may provide the values of these header arguments (in the
2269 ((member "prepend" result-params))) ; already there 2273 ((member "prepend" result-params))) ; already there
2270 (setq results-switches 2274 (setq results-switches
2271 (if results-switches (concat " " results-switches) "")) 2275 (if results-switches (concat " " results-switches) ""))
2272 (let ((wrap (lambda (start finish &optional no-escape no-newlines 2276 (let ((wrap
2273 inline-start inline-finish) 2277 (lambda (start finish &optional no-escape no-newlines
2274 (when inline 2278 inline-start inline-finish)
2275 (setq start inline-start) 2279 (when inline
2276 (setq finish inline-finish) 2280 (setq start inline-start)
2277 (setq no-newlines t)) 2281 (setq finish inline-finish)
2278 (goto-char end) 2282 (setq no-newlines t))
2279 (insert (concat finish (unless no-newlines "\n"))) 2283 (let ((before-finish (marker-position end)))
2280 (goto-char beg) 2284 (goto-char end)
2281 (insert (concat start (unless no-newlines "\n"))) 2285 (insert (concat finish (unless no-newlines "\n")))
2282 (unless no-escape 2286 (goto-char beg)
2283 (org-escape-code-in-region (min (point) end) end)) 2287 (insert (concat start (unless no-newlines "\n")))
2284 (goto-char end) 2288 (unless no-escape
2285 (unless no-newlines (goto-char (point-at-eol))) 2289 (org-escape-code-in-region
2286 (setq end (point-marker)))) 2290 (min (point) before-finish) before-finish))
2291 (goto-char end))))
2287 (tabulablep 2292 (tabulablep
2288 (lambda (r) 2293 (lambda (r)
2289 ;; Non-nil when result R can be turned into 2294 ;; Non-nil when result R can be turned into
@@ -2337,7 +2342,7 @@ INFO may provide the values of these header arguments (in the
2337 (insert (org-macro-escape-arguments 2342 (insert (org-macro-escape-arguments
2338 (org-babel-chomp result "\n")))) 2343 (org-babel-chomp result "\n"))))
2339 (t (goto-char beg) (insert result))) 2344 (t (goto-char beg) (insert result)))
2340 (setq end (point-marker)) 2345 (setq end (copy-marker (point) t))
2341 ;; possibly wrap result 2346 ;; possibly wrap result
2342 (cond 2347 (cond
2343 ((assq :wrap (nth 2 info)) 2348 ((assq :wrap (nth 2 info))
@@ -2374,11 +2379,12 @@ INFO may provide the values of these header arguments (in the
2374 ((and (not (funcall tabulablep result)) 2379 ((and (not (funcall tabulablep result))
2375 (not (member "file" result-params))) 2380 (not (member "file" result-params)))
2376 (let ((org-babel-inline-result-wrap 2381 (let ((org-babel-inline-result-wrap
2377 ;; Hard code {{{results(...)}}} on top of customization. 2382 ;; Hard code {{{results(...)}}} on top of
2383 ;; customization.
2378 (format "{{{results(%s)}}}" 2384 (format "{{{results(%s)}}}"
2379 org-babel-inline-result-wrap))) 2385 org-babel-inline-result-wrap)))
2380 (org-babel-examplify-region beg end results-switches inline) 2386 (org-babel-examplify-region
2381 (setq end (point)))))) 2387 beg end results-switches inline)))))
2382 ;; Possibly indent results in par with #+results line. 2388 ;; Possibly indent results in par with #+results line.
2383 (when (and (not inline) (numberp indent) (> indent 0) 2389 (when (and (not inline) (numberp indent) (> indent 0)
2384 ;; In this case `table-align' does the work 2390 ;; In this case `table-align' does the work
@@ -2391,6 +2397,7 @@ INFO may provide the values of these header arguments (in the
2391 (message "Code block returned no value.") 2397 (message "Code block returned no value.")
2392 (message "Code block produced no output.")) 2398 (message "Code block produced no output."))
2393 (message "Code block evaluation complete."))) 2399 (message "Code block evaluation complete.")))
2400 (set-marker end nil)
2394 (when outside-scope (narrow-to-region visible-beg visible-end)) 2401 (when outside-scope (narrow-to-region visible-beg visible-end))
2395 (set-marker visible-beg nil) 2402 (set-marker visible-beg nil)
2396 (set-marker visible-end nil))))))) 2403 (set-marker visible-end nil)))))))
diff --git a/lisp/org/ob-emacs-lisp.el b/lisp/org/ob-emacs-lisp.el
index c0bd12a8793..989561db7be 100644
--- a/lisp/org/ob-emacs-lisp.el
+++ b/lisp/org/ob-emacs-lisp.el
@@ -41,41 +41,38 @@ their value. It is used as the optional LEXICAL argument to
41 41
42(defun org-babel-expand-body:emacs-lisp (body params) 42(defun org-babel-expand-body:emacs-lisp (body params)
43 "Expand BODY according to PARAMS, return the expanded body." 43 "Expand BODY according to PARAMS, return the expanded body."
44 (let* ((vars (org-babel--get-vars params)) 44 (let ((vars (org-babel--get-vars params))
45 (result-params (cdr (assq :result-params params))) 45 (print-level nil)
46 (print-level nil) (print-length nil) 46 (print-length nil))
47 (body (if (> (length vars) 0) 47 (if (null vars) (concat body "\n")
48 (concat "(let (" 48 (format "(let (%s)\n%s\n)"
49 (mapconcat 49 (mapconcat
50 (lambda (var) 50 (lambda (var)
51 (format "%S" (print `(,(car var) ',(cdr var))))) 51 (format "%S" (print `(,(car var) ',(cdr var)))))
52 vars "\n ") 52 vars "\n ")
53 ")\n" body "\n)") 53 body))))
54 (concat body "\n"))))
55 (if (or (member "code" result-params)
56 (member "pp" result-params))
57 (concat "(pp " body ")") body)))
58 54
59(defun org-babel-execute:emacs-lisp (body params) 55(defun org-babel-execute:emacs-lisp (body params)
60 "Execute a block of emacs-lisp code with Babel." 56 "Execute a block of emacs-lisp code with Babel."
61 (save-window-excursion 57 (save-window-excursion
62 (let* ((lexical (cdr (assq :lexical params))) 58 (let* ((lexical (cdr (assq :lexical params)))
63 (result 59 (result-params (cdr (assq :result-params params)))
64 (eval (read (format (if (member "output" 60 (body (format (if (member "output" result-params)
65 (cdr (assq :result-params params))) 61 "(with-output-to-string %s\n)"
66 "(with-output-to-string %s)" 62 "(progn %s\n)")
67 "(progn %s)") 63 (org-babel-expand-body:emacs-lisp body params)))
68 (org-babel-expand-body:emacs-lisp 64 (result (eval (read (if (or (member "code" result-params)
69 body params))) 65 (member "pp" result-params))
70 66 (concat "(pp " body ")")
71 (if (listp lexical) 67 body))
72 lexical 68 (if (listp lexical)
73 (member lexical '("yes" "t")))))) 69 lexical
74 (org-babel-result-cond (cdr (assq :result-params params)) 70 (member lexical '("yes" "t"))))))
71 (org-babel-result-cond result-params
75 (let ((print-level nil) 72 (let ((print-level nil)
76 (print-length nil)) 73 (print-length nil))
77 (if (or (member "scalar" (cdr (assq :result-params params))) 74 (if (or (member "scalar" result-params)
78 (member "verbatim" (cdr (assq :result-params params)))) 75 (member "verbatim" result-params))
79 (format "%S" result) 76 (format "%S" result)
80 (format "%s" result))) 77 (format "%s" result)))
81 (org-babel-reassemble-table 78 (org-babel-reassemble-table
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index f90dd53bb05..598461874f6 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -6992,11 +6992,16 @@ The optional argument TYPE tells the agenda type."
6992 (list 'face (org-get-todo-face (match-string 2 x))) 6992 (list 'face (org-get-todo-face (match-string 2 x)))
6993 x) 6993 x)
6994 (when (match-end 1) 6994 (when (match-end 1)
6995 (setq x (concat (substring x 0 (match-end 1)) 6995 (setq x
6996 (format org-agenda-todo-keyword-format 6996 (concat
6997 (match-string 2 x)) 6997 (substring x 0 (match-end 1))
6998 (org-add-props " " (text-properties-at 0 x)) 6998 (format org-agenda-todo-keyword-format
6999 (substring x (match-end 3))))))) 6999 (match-string 2 x))
7000 ;; Remove `display' property as the icon could leak
7001 ;; on the white space.
7002 (org-add-props " " (org-plist-delete (text-properties-at 0 x)
7003 'display))
7004 (substring x (match-end 3)))))))
7000 x))) 7005 x)))
7001 7006
7002(defsubst org-cmp-values (a b property) 7007(defsubst org-cmp-values (a b property)
@@ -7592,7 +7597,7 @@ also press `-' or `+' to switch between filtering and excluding."
7592 (org-global-tags-completion-table))) 7597 (org-global-tags-completion-table)))
7593 (let ((completion-ignore-case t)) 7598 (let ((completion-ignore-case t))
7594 (setq tag (completing-read 7599 (setq tag (completing-read
7595 "Tag: " org-global-tags-completion-table)))) 7600 "Tag: " org-global-tags-completion-table nil t))))
7596 (cond 7601 (cond
7597 ((eq char ?\r) 7602 ((eq char ?\r)
7598 (org-agenda-filter-show-all-tag) 7603 (org-agenda-filter-show-all-tag)
diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el
index 63e23cc118b..43207308baf 100644
--- a/lisp/org/org-capture.el
+++ b/lisp/org/org-capture.el
@@ -242,8 +242,10 @@ be replaced with content and expanded:
242 happens after expanding non-interactive %-escapes, those can 242 happens after expanding non-interactive %-escapes, those can
243 be used to fill the expression. 243 be used to fill the expression.
244 %<...> The result of format-time-string on the ... format specification. 244 %<...> The result of format-time-string on the ... format specification.
245 %t Time stamp, date only. 245 %t Time stamp, date only. The time stamp is the current time,
246 %T Time stamp with date and time. 246 except when called from agendas with `\\[org-agenda-capture]' or
247 with `org-capture-use-agenda-date' set.
248 %T Time stamp as above, with date and time.
247 %u, %U Like the above, but inactive time stamps. 249 %u, %U Like the above, but inactive time stamps.
248 %i Initial content, copied from the active region. If %i is 250 %i Initial content, copied from the active region. If %i is
249 indented, the entire inserted text will be indented as well. 251 indented, the entire inserted text will be indented as well.
@@ -261,7 +263,8 @@ be replaced with content and expanded:
261 %^g Prompt for tags, with completion on tags in target file. 263 %^g Prompt for tags, with completion on tags in target file.
262 %^G Prompt for tags, with completion on all tags in all agenda files. 264 %^G Prompt for tags, with completion on all tags in all agenda files.
263 %^t Like %t, but prompt for date. Similarly %^T, %^u, %^U. 265 %^t Like %t, but prompt for date. Similarly %^T, %^u, %^U.
264 You may define a prompt like: %^{Please specify birthday}t 266 You may define a prompt like: %^{Please specify birthday}t.
267 The default date is that of %t, see above.
265 %^C Interactive selection of which kill or clip to use. 268 %^C Interactive selection of which kill or clip to use.
266 %^L Like %^C, but insert as link. 269 %^L Like %^C, but insert as link.
267 %^{prop}p Prompt the user for a value for property `prop'. 270 %^{prop}p Prompt the user for a value for property `prop'.
@@ -1126,6 +1129,7 @@ may have been stored before."
1126 (mapconcat 'identity (split-string txt "\n") 1129 (mapconcat 'identity (split-string txt "\n")
1127 "\n ")))) 1130 "\n "))))
1128 ;; Prepare surrounding empty lines. 1131 ;; Prepare surrounding empty lines.
1132 (unless (bolp) (insert "\n"))
1129 (org-capture-empty-lines-before) 1133 (org-capture-empty-lines-before)
1130 (setq beg (point)) 1134 (setq beg (point))
1131 (unless (eolp) (save-excursion (insert "\n"))) 1135 (unless (eolp) (save-excursion (insert "\n")))
@@ -1143,10 +1147,9 @@ may have been stored before."
1143 (insert txt) 1147 (insert txt)
1144 (org-capture-empty-lines-after) 1148 (org-capture-empty-lines-after)
1145 (org-capture-position-for-last-stored beg) 1149 (org-capture-position-for-last-stored beg)
1146 (forward-char 1)
1147 (setq end (point)) 1150 (setq end (point))
1148 (org-capture-mark-kill-region beg (1- end)) 1151 (org-capture-mark-kill-region beg end)
1149 (org-capture-narrow beg (1- end)) 1152 (org-capture-narrow beg end)
1150 (if (or (re-search-backward "%\\?" beg t) 1153 (if (or (re-search-backward "%\\?" beg t)
1151 (re-search-forward "%\\?" end t)) 1154 (re-search-forward "%\\?" end t))
1152 (replace-match "")))) 1155 (replace-match ""))))
@@ -1575,12 +1578,16 @@ The template may still contain \"%?\" for cursor positioning."
1575 (replace-match "\\1" nil nil v-a) 1578 (replace-match "\\1" nil nil v-a)
1576 v-a)) 1579 v-a))
1577 (v-n user-full-name) 1580 (v-n user-full-name)
1578 (v-k (and (marker-buffer org-clock-marker) 1581 (v-k (if (marker-buffer org-clock-marker)
1579 (org-no-properties org-clock-heading))) 1582 (org-no-properties org-clock-heading)
1583 ""))
1580 (v-K (if (marker-buffer org-clock-marker) 1584 (v-K (if (marker-buffer org-clock-marker)
1581 (org-make-link-string 1585 (org-make-link-string
1582 (buffer-file-name (marker-buffer org-clock-marker)) 1586 (format "%s::*%s"
1583 org-clock-heading))) 1587 (buffer-file-name (marker-buffer org-clock-marker))
1588 v-k)
1589 v-k)
1590 ""))
1584 (v-f (or (org-capture-get :original-file-nondirectory) "")) 1591 (v-f (or (org-capture-get :original-file-nondirectory) ""))
1585 (v-F (or (org-capture-get :original-file) "")) 1592 (v-F (or (org-capture-get :original-file) ""))
1586 (org-capture--clipboards 1593 (org-capture--clipboards
@@ -1744,24 +1751,27 @@ The template may still contain \"%?\" for cursor positioning."
1744 (_ (error "Invalid `org-capture--clipboards' value: %S" 1751 (_ (error "Invalid `org-capture--clipboards' value: %S"
1745 org-capture--clipboards))))) 1752 org-capture--clipboards)))))
1746 ("p" (org-set-property prompt nil)) 1753 ("p" (org-set-property prompt nil))
1747 ((guard key) 1754 ((or "t" "T" "u" "U")
1748 ;; These are the date/time related ones. 1755 ;; These are the date/time related ones.
1749 (let* ((upcase? (equal (upcase key) key)) 1756 (let* ((upcase? (equal (upcase key) key))
1750 (org-time-was-given upcase?) 1757 (org-end-time-was-given nil)
1751 (org-end-time-was-given)
1752 (time (org-read-date upcase? t nil prompt))) 1758 (time (org-read-date upcase? t nil prompt)))
1753 (org-insert-time-stamp 1759 (let ((org-time-was-given upcase?))
1754 time org-time-was-given 1760 (org-insert-time-stamp
1755 (member key '("u" "U")) 1761 time org-time-was-given
1756 nil nil (list org-end-time-was-given)))) 1762 (member key '("u" "U"))
1757 (_ 1763 nil nil (list org-end-time-was-given)))))
1764 (`nil
1758 (push (org-completing-read 1765 (push (org-completing-read
1759 (concat (or prompt "Enter string") 1766 (concat (or prompt "Enter string")
1760 (and default (format " [%s]" default)) 1767 (and default (format " [%s]" default))
1761 ": ") 1768 ": ")
1762 completions nil nil nil nil default) 1769 completions nil nil nil nil default)
1763 strings) 1770 strings)
1764 (insert (car strings))))))))) 1771 (insert (car strings)))
1772 (_
1773 (error "Unknown template placeholder: \"%%^%s\""
1774 key))))))))
1765 1775
1766 ;; Replace %n escapes with nth %^{...} string. 1776 ;; Replace %n escapes with nth %^{...} string.
1767 (setq strings (nreverse strings)) 1777 (setq strings (nreverse strings))
@@ -1892,9 +1902,7 @@ Assume sexps have been marked with
1892 (if jump-to-captured '(:jump-to-captured t))))) 1902 (if jump-to-captured '(:jump-to-captured t)))))
1893 1903
1894 org-remember-templates)))) 1904 org-remember-templates))))
1895;;; The function was made obsolete by commit 65399674d5 of 1905
1896;;; 2013-02-22. This make-obsolete call was added 2016-09-01.
1897(make-obsolete 'org-capture-import-remember-templates "use the `org-capture-templates' variable instead." "Org 9.0")
1898 1906
1899(provide 'org-capture) 1907(provide 'org-capture)
1900 1908
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index cb6a6c9ad1d..aa5c375cef3 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -1418,11 +1418,13 @@ for a todo state to switch to, overriding the existing value
1418 1418
1419(defun org-clock-get-sum-start () 1419(defun org-clock-get-sum-start ()
1420 "Return the time from which clock times should be counted. 1420 "Return the time from which clock times should be counted.
1421This is for the currently running clock as it is displayed 1421
1422in the mode line. This function looks at the properties 1422This is for the currently running clock as it is displayed in the
1423LAST_REPEAT and in particular CLOCK_MODELINE_TOTAL and the 1423mode line. This function looks at the properties LAST_REPEAT and
1424corresponding variable `org-clock-mode-line-total' and then 1424in particular CLOCK_MODELINE_TOTAL and the corresponding variable
1425decides which time to use." 1425`org-clock-mode-line-total' and then decides which time to use.
1426
1427The time is always returned as UTC."
1426 (let ((cmt (or (org-entry-get nil "CLOCK_MODELINE_TOTAL") 1428 (let ((cmt (or (org-entry-get nil "CLOCK_MODELINE_TOTAL")
1427 (symbol-name org-clock-mode-line-total))) 1429 (symbol-name org-clock-mode-line-total)))
1428 (lr (org-entry-get nil "LAST_REPEAT"))) 1430 (lr (org-entry-get nil "LAST_REPEAT")))
@@ -1432,13 +1434,13 @@ decides which time to use."
1432 (current-time)) 1434 (current-time))
1433 ((equal cmt "today") 1435 ((equal cmt "today")
1434 (setq org--msg-extra "showing today's task time.") 1436 (setq org--msg-extra "showing today's task time.")
1435 (let* ((dt (decode-time)) 1437 (let* ((dt (org-decode-time nil t))
1436 (hour (nth 2 dt)) 1438 (hour (nth 2 dt))
1437 (day (nth 3 dt))) 1439 (day (nth 3 dt)))
1438 (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day))) 1440 (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
1439 (setf (nth 2 dt) org-extend-today-until) 1441 (setf (nth 2 dt) org-extend-today-until)
1440 (setq dt (append (list 0 0) (nthcdr 2 dt))) 1442 (setq dt (append (list 0 0) (nthcdr 2 dt) '(t)))
1441 (apply 'encode-time dt))) 1443 (apply #'encode-time dt)))
1442 ((or (equal cmt "all") 1444 ((or (equal cmt "all")
1443 (and (or (not cmt) (equal cmt "auto")) 1445 (and (or (not cmt) (equal cmt "auto"))
1444 (not lr))) 1446 (not lr)))
@@ -1448,9 +1450,7 @@ decides which time to use."
1448 (and (or (not cmt) (equal cmt "auto")) 1450 (and (or (not cmt) (equal cmt "auto"))
1449 lr)) 1451 lr))
1450 (setq org--msg-extra "showing task time since last repeat.") 1452 (setq org--msg-extra "showing task time since last repeat.")
1451 (if (not lr) 1453 (and lr (org-time-string-to-time lr t)))
1452 nil
1453 (org-time-string-to-time lr)))
1454 (t nil)))) 1454 (t nil))))
1455 1455
1456(defun org-clock-find-position (find-unclosed) 1456(defun org-clock-find-position (find-unclosed)
@@ -1803,14 +1803,15 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
1803 "[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)")) 1803 "[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
1804 (lmax 30) 1804 (lmax 30)
1805 (ltimes (make-vector lmax 0)) 1805 (ltimes (make-vector lmax 0))
1806 (t1 0)
1807 (level 0) 1806 (level 0)
1808 ts te dt 1807 (tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart t))
1808 ((consp tstart) (float-time tstart))
1809 (t tstart)))
1810 (tend (cond ((stringp tend) (org-time-string-to-seconds tend t))
1811 ((consp tend) (float-time tend))
1812 (t tend)))
1813 (t1 0)
1809 time) 1814 time)
1810 (if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
1811 (if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
1812 (if (consp tstart) (setq tstart (float-time tstart)))
1813 (if (consp tend) (setq tend (float-time tend)))
1814 (remove-text-properties (point-min) (point-max) 1815 (remove-text-properties (point-min) (point-max)
1815 `(,(or propname :org-clock-minutes) t 1816 `(,(or propname :org-clock-minutes) t
1816 :org-clock-force-headline-inclusion t)) 1817 :org-clock-force-headline-inclusion t))
@@ -1819,26 +1820,27 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
1819 (while (re-search-backward re nil t) 1820 (while (re-search-backward re nil t)
1820 (cond 1821 (cond
1821 ((match-end 2) 1822 ((match-end 2)
1822 ;; Two time stamps 1823 ;; Two time stamps.
1823 (setq ts (match-string 2) 1824 (let* ((ts (float-time
1824 te (match-string 3) 1825 (apply #'encode-time
1825 ts (float-time 1826 (save-match-data
1826 (apply #'encode-time (org-parse-time-string ts nil t))) 1827 (org-parse-time-string
1827 te (float-time 1828 (match-string 2) nil t)))))
1828 (apply #'encode-time (org-parse-time-string te nil t))) 1829 (te (float-time
1829 ts (if tstart (max ts tstart) ts) 1830 (apply #'encode-time
1830 te (if tend (min te tend) te) 1831 (org-parse-time-string (match-string 3) nil t))))
1831 dt (- te ts) 1832 (dt (- (if tend (min te tend) te)
1832 t1 (if (> dt 0) (+ t1 (floor (/ dt 60))) t1))) 1833 (if tstart (max ts tstart) ts))))
1834 (when (> dt 0) (cl-incf t1 (floor (/ dt 60))))))
1833 ((match-end 4) 1835 ((match-end 4)
1834 ;; A naked time 1836 ;; A naked time.
1835 (setq t1 (+ t1 (string-to-number (match-string 5)) 1837 (setq t1 (+ t1 (string-to-number (match-string 5))
1836 (* 60 (string-to-number (match-string 4)))))) 1838 (* 60 (string-to-number (match-string 4))))))
1837 (t ;; A headline 1839 (t ;A headline
1838 ;; Add the currently clocking item time to the total 1840 ;; Add the currently clocking item time to the total.
1839 (when (and org-clock-report-include-clocking-task 1841 (when (and org-clock-report-include-clocking-task
1840 (equal (org-clocking-buffer) (current-buffer)) 1842 (eq (org-clocking-buffer) (current-buffer))
1841 (equal (marker-position org-clock-hd-marker) (point)) 1843 (eq (marker-position org-clock-hd-marker) (point))
1842 tstart 1844 tstart
1843 tend 1845 tend
1844 (>= (float-time org-clock-start-time) tstart) 1846 (>= (float-time org-clock-start-time) tstart)
@@ -2701,16 +2703,14 @@ LEVEL is an integer. Indent by two spaces per level above 1."
2701 (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts))) 2703 (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts)))
2702 (setq ts (float-time (encode-time 0 0 0 day month year))))) 2704 (setq ts (float-time (encode-time 0 0 0 day month year)))))
2703 (ts 2705 (ts
2704 (setq ts (float-time 2706 (setq ts (float-time (apply #'encode-time (org-parse-time-string ts))))))
2705 (apply #'encode-time (org-parse-time-string ts nil t))))))
2706 (cond 2707 (cond
2707 ((numberp te) 2708 ((numberp te)
2708 ;; Likewise for te. 2709 ;; Likewise for te.
2709 (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te))) 2710 (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te)))
2710 (setq te (float-time (encode-time 0 0 0 day month year))))) 2711 (setq te (float-time (encode-time 0 0 0 day month year)))))
2711 (te 2712 (te
2712 (setq te (float-time 2713 (setq te (float-time (apply #'encode-time (org-parse-time-string te))))))
2713 (apply #'encode-time (org-parse-time-string te nil t))))))
2714 (setq tsb 2714 (setq tsb
2715 (if (eq step0 'week) 2715 (if (eq step0 'week)
2716 (- ts (* 86400 (- (nth 6 (decode-time (seconds-to-time ts))) ws))) 2716 (- ts (* 86400 (- (nth 6 (decode-time (seconds-to-time ts))) ws)))
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index e1d40369f19..68a1166c814 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -60,6 +60,12 @@
60 (defalias 'format-message 'format) 60 (defalias 'format-message 'format)
61 (defalias 'gui-get-selection 'x-get-selection)) 61 (defalias 'gui-get-selection 'x-get-selection))
62 62
63(defun org-decode-time (&optional time zone)
64 "Backward-compatible function for `decode-time'."
65 (if (< emacs-major-version 25)
66 (decode-time time)
67 (decode-time time zone)))
68
63 69
64;;; Obsolete aliases (remove them after the next major release). 70;;; Obsolete aliases (remove them after the next major release).
65 71
@@ -293,6 +299,12 @@ See `org-link-parameters' for documentation on the other parameters."
293(define-obsolete-function-alias 'org-babel-number-p 299(define-obsolete-function-alias 'org-babel-number-p
294 'org-babel--string-to-number "Org 9.0") 300 'org-babel--string-to-number "Org 9.0")
295 301
302;;; The function was made obsolete by commit 65399674d5 of 2013-02-22.
303;;; This make-obsolete call was added 2016-09-01.
304(make-obsolete 'org-capture-import-remember-templates
305 "use the `org-capture-templates' variable instead."
306 "Org 9.0")
307
296 308
297 309
298;;;; Obsolete link types 310;;;; Obsolete link types
diff --git a/lisp/org/org-element.el b/lisp/org/org-element.el
index 41b4a3ac78c..f4fe6447a68 100644
--- a/lisp/org/org-element.el
+++ b/lisp/org/org-element.el
@@ -2983,16 +2983,8 @@ Assume point is at the beginning of the LaTeX fragment."
2983 (save-excursion 2983 (save-excursion
2984 (let* ((begin (point)) 2984 (let* ((begin (point))
2985 (after-fragment 2985 (after-fragment
2986 (if (eq (char-after) ?$) 2986 (cond
2987 (if (eq (char-after (1+ (point))) ?$) 2987 ((not (eq ?$ (char-after)))
2988 (search-forward "$$" nil t 2)
2989 (and (not (eq (char-before) ?$))
2990 (search-forward "$" nil t 2)
2991 (not (memq (char-before (match-beginning 0))
2992 '(?\s ?\t ?\n ?, ?.)))
2993 (looking-at-p
2994 "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
2995 (point)))
2996 (pcase (char-after (1+ (point))) 2988 (pcase (char-after (1+ (point)))
2997 (?\( (search-forward "\\)" nil t)) 2989 (?\( (search-forward "\\)" nil t))
2998 (?\[ (search-forward "\\]" nil t)) 2990 (?\[ (search-forward "\\]" nil t))
@@ -3000,10 +2992,23 @@ Assume point is at the beginning of the LaTeX fragment."
3000 ;; Macro. 2992 ;; Macro.
3001 (and (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\ 2993 (and (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\
3002\\|\\({[^{}\n]*}\\)\\)*") 2994\\|\\({[^{}\n]*}\\)\\)*")
3003 (match-end 0)))))) 2995 (match-end 0)))))
3004 (post-blank (if (not after-fragment) (throw 'no-object nil) 2996 ((eq ?$ (char-after (1+ (point))))
3005 (goto-char after-fragment) 2997 (search-forward "$$" nil t 2))
3006 (skip-chars-forward " \t"))) 2998 (t
2999 (and (not (eq ?$ (char-before)))
3000 (not (memq (char-after (1+ (point)))
3001 '(?\s ?\t ?\n ?, ?. ?\;)))
3002 (search-forward "$" nil t 2)
3003 (not (memq (char-before (match-beginning 0))
3004 '(?\s ?\t ?\n ?, ?.)))
3005 (looking-at-p
3006 "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
3007 (point)))))
3008 (post-blank
3009 (if (not after-fragment) (throw 'no-object nil)
3010 (goto-char after-fragment)
3011 (skip-chars-forward " \t")))
3007 (end (point))) 3012 (end (point)))
3008 (list 'latex-fragment 3013 (list 'latex-fragment
3009 (list :value (buffer-substring-no-properties begin after-fragment) 3014 (list :value (buffer-substring-no-properties begin after-fragment)
diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el
index 10c96179b61..4a22b15050c 100644
--- a/lisp/org/org-indent.el
+++ b/lisp/org/org-indent.el
@@ -142,11 +142,11 @@ useful to make it ever so slightly different."
142 ;; Inline tasks line prefixes 142 ;; Inline tasks line prefixes
143 (aset org-indent--inlinetask-line-prefixes 143 (aset org-indent--inlinetask-line-prefixes
144 n 144 n
145 (org-add-props (if (bound-and-true-p org-inlinetask-show-first-star) 145 (cond ((<= n 1) "")
146 (concat org-indent-inlinetask-first-star 146 ((bound-and-true-p org-inlinetask-show-first-star)
147 (substring heading-prefix 1)) 147 (concat org-indent-inlinetask-first-star
148 heading-prefix) 148 (substring heading-prefix 1)))
149 nil 'face 'org-indent))) 149 (t (org-add-props heading-prefix nil 'face 'org-indent)))))
150 ;; Text line prefixes. 150 ;; Text line prefixes.
151 (aset org-indent--text-line-prefixes 151 (aset org-indent--text-line-prefixes
152 n 152 n
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 3a6a7f4db06..92537fc2cc7 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -205,7 +205,8 @@ default."
205 (require 'erc) 205 (require 'erc)
206 (require 'erc-log) 206 (require 'erc-log)
207 (let* ((server (car (car link))) 207 (let* ((server (car (car link)))
208 (port (or (string-to-number (cadr (pop link))) erc-default-port)) 208 (port (let ((p (cadr (pop link))))
209 (if p (string-to-number p) erc-default-port)))
209 (server-buffer) 210 (server-buffer)
210 (buffer-list 211 (buffer-list
211 (erc-buffer-filter 212 (erc-buffer-filter
diff --git a/lisp/org/org-lint.el b/lisp/org/org-lint.el
index 5abda7c4a6b..9007bf8f958 100644
--- a/lisp/org/org-lint.el
+++ b/lisp/org/org-lint.el
@@ -724,7 +724,7 @@ Use \"export %s\" instead"
724 (org-element-map ast 'footnote-reference 724 (org-element-map ast 'footnote-reference
725 (lambda (f) 725 (lambda (f)
726 (let ((label (org-element-property :label f))) 726 (let ((label (org-element-property :label f)))
727 (and label 727 (and (eq 'standard (org-element-property :type f))
728 (not (member label definitions)) 728 (not (member label definitions))
729 (list (org-element-property :begin f) 729 (list (org-element-property :begin f)
730 (format "Missing definition for footnote [%s]" 730 (format "Missing definition for footnote [%s]"
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index 3dc9c5450ed..3b8f8140c9c 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -186,56 +186,54 @@ found in the buffer with no definition in TEMPLATES.
186 186
187Optional argument KEYWORDS, when non-nil is a list of keywords, 187Optional argument KEYWORDS, when non-nil is a list of keywords,
188as strings, where macro expansion is allowed." 188as strings, where macro expansion is allowed."
189 (save-excursion 189 (org-with-wide-buffer
190 (goto-char (point-min)) 190 (goto-char (point-min))
191 (let ((properties-regexp 191 (let ((properties-regexp (format "\\`EXPORT_%s\\+?\\'"
192 (format "\\`EXPORT_%s\\+?\\'" (regexp-opt keywords))) 192 (regexp-opt keywords)))
193 record) 193 record)
194 (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t) 194 (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t)
195 (unless (save-match-data (org-in-commented-heading-p)) 195 (unless (save-match-data (org-in-commented-heading-p))
196 (let* ((datum (save-match-data (org-element-context))) 196 (let* ((datum (save-match-data (org-element-context)))
197 (type (org-element-type datum)) 197 (type (org-element-type datum))
198 (macro 198 (macro
199 (cond 199 (cond
200 ((eq type 'macro) datum) 200 ((eq type 'macro) datum)
201 ;; In parsed keywords and associated node 201 ;; In parsed keywords and associated node
202 ;; properties, force macro recognition. 202 ;; properties, force macro recognition.
203 ((or (and (eq type 'keyword) 203 ((or (and (eq type 'keyword)
204 (member (org-element-property :key datum) 204 (member (org-element-property :key datum) keywords))
205 keywords)) 205 (and (eq type 'node-property)
206 (and (eq type 'node-property) 206 (string-match-p properties-regexp
207 (string-match-p properties-regexp 207 (org-element-property :key datum))))
208 (org-element-property :key 208 (save-excursion
209 datum)))) 209 (goto-char (match-beginning 0))
210 (save-excursion 210 (org-element-macro-parser))))))
211 (goto-char (match-beginning 0)) 211 (when macro
212 (org-element-macro-parser)))))) 212 (let* ((value (org-macro-expand macro templates))
213 (when macro 213 (begin (org-element-property :begin macro))
214 (let* ((value (org-macro-expand macro templates)) 214 (signature (list begin
215 (begin (org-element-property :begin macro)) 215 macro
216 (signature (list begin 216 (org-element-property :args macro))))
217 macro 217 ;; Avoid circular dependencies by checking if the same
218 (org-element-property :args macro)))) 218 ;; macro with the same arguments is expanded at the
219 ;; Avoid circular dependencies by checking if the same 219 ;; same position twice.
220 ;; macro with the same arguments is expanded at the 220 (cond ((member signature record)
221 ;; same position twice. 221 (error "Circular macro expansion: %s"
222 (cond ((member signature record) 222 (org-element-property :key macro)))
223 (error "Circular macro expansion: %s" 223 (value
224 (org-element-property :key macro))) 224 (push signature record)
225 (value 225 (delete-region
226 (push signature record) 226 begin
227 (delete-region 227 ;; Preserve white spaces after the macro.
228 begin 228 (progn (goto-char (org-element-property :end macro))
229 ;; Preserve white spaces after the macro. 229 (skip-chars-backward " \t")
230 (progn (goto-char (org-element-property :end macro)) 230 (point)))
231 (skip-chars-backward " \t") 231 ;; Leave point before replacement in case of
232 (point))) 232 ;; recursive expansions.
233 ;; Leave point before replacement in case of 233 (save-excursion (insert value)))
234 ;; recursive expansions. 234 (finalize
235 (save-excursion (insert value))) 235 (error "Undefined Org macro: %s; aborting"
236 (finalize 236 (org-element-property :key macro))))))))))))
237 (error "Undefined Org macro: %s; aborting"
238 (org-element-property :key macro))))))))))))
239 237
240(defun org-macro-escape-arguments (&rest args) 238(defun org-macro-escape-arguments (&rest args)
241 "Build macro's arguments string from ARGS. 239 "Build macro's arguments string from ARGS.
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index ca47e5a5a33..aae59d3c1f4 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -304,6 +304,43 @@ error when the user input is empty."
304 (allow-empty? nil) 304 (allow-empty? nil)
305 (t (user-error "Empty input is not valid"))))) 305 (t (user-error "Empty input is not valid")))))
306 306
307(defconst org-unique-local-variables
308 '(org-element--cache
309 org-element--cache-objects
310 org-element--cache-sync-keys
311 org-element--cache-sync-requests
312 org-element--cache-sync-timer)
313 "List of local variables that cannot be transferred to another buffer.")
314
315(defun org-get-local-variables ()
316 "Return a list of all local variables in an Org mode buffer."
317 (delq nil
318 (mapcar
319 (lambda (x)
320 (let* ((binding (if (symbolp x) (list x) (list (car x) (cdr x))))
321 (name (car binding)))
322 (and (not (get name 'org-state))
323 (not (memq name org-unique-local-variables))
324 (string-match-p
325 "\\`\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|\
326auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
327 (symbol-name name))
328 binding)))
329 (with-temp-buffer
330 (org-mode)
331 (buffer-local-variables)))))
332
333(defun org-clone-local-variables (from-buffer &optional regexp)
334 "Clone local variables from FROM-BUFFER.
335Optional argument REGEXP selects variables to clone."
336 (dolist (pair (buffer-local-variables from-buffer))
337 (pcase pair
338 (`(,name . ,value) ;ignore unbound variables
339 (when (and (not (memq name org-unique-local-variables))
340 (or (null regexp) (string-match-p regexp (symbol-name name))))
341 (ignore-errors (set (make-local-variable name) value)))))))
342
343
307(provide 'org-macs) 344(provide 'org-macs)
308 345
309;;; org-macs.el ends here 346;;; org-macs.el ends here
diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
index 9fee09f38e4..192ccadfde6 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -693,7 +693,7 @@ encryption program does not understand them."
693(defun org-mobile-encrypt-file (infile outfile) 693(defun org-mobile-encrypt-file (infile outfile)
694 "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." 694 "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."
695 (shell-command 695 (shell-command
696 (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s" 696 (format "openssl enc -md md5 -aes-256-cbc -salt -pass %s -in %s -out %s"
697 (shell-quote-argument (concat "pass:" 697 (shell-quote-argument (concat "pass:"
698 (org-mobile-encryption-password))) 698 (org-mobile-encryption-password)))
699 (shell-quote-argument (expand-file-name infile)) 699 (shell-quote-argument (expand-file-name infile))
@@ -702,7 +702,7 @@ encryption program does not understand them."
702(defun org-mobile-decrypt-file (infile outfile) 702(defun org-mobile-decrypt-file (infile outfile)
703 "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." 703 "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."
704 (shell-command 704 (shell-command
705 (format "openssl enc -d -aes-256-cbc -salt -pass %s -in %s -out %s" 705 (format "openssl enc -md md5 -d -aes-256-cbc -salt -pass %s -in %s -out %s"
706 (shell-quote-argument (concat "pass:" 706 (shell-quote-argument (concat "pass:"
707 (org-mobile-encryption-password))) 707 (org-mobile-encryption-password)))
708 (shell-quote-argument (expand-file-name infile)) 708 (shell-quote-argument (expand-file-name infile))
diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el
index 82543567456..cd4b216aae9 100644
--- a/lisp/org/org-protocol.el
+++ b/lisp/org/org-protocol.el
@@ -520,7 +520,9 @@ The location for a browser's bookmark should look like this:
520 ;; As we enter this function for a match on our protocol, the return value 520 ;; As we enter this function for a match on our protocol, the return value
521 ;; defaults to nil. 521 ;; defaults to nil.
522 (let ((result nil) 522 (let ((result nil)
523 (f (plist-get (org-protocol-parse-parameters fname nil '(:url)) :url))) 523 (f (org-protocol-sanitize-uri
524 (plist-get (org-protocol-parse-parameters fname nil '(:url))
525 :url))))
524 (catch 'result 526 (catch 'result
525 (dolist (prolist org-protocol-project-alist) 527 (dolist (prolist org-protocol-project-alist)
526 (let* ((base-url (plist-get (cdr prolist) :base-url)) 528 (let* ((base-url (plist-get (cdr prolist) :base-url))
@@ -554,7 +556,7 @@ The location for a browser's bookmark should look like this:
554 ;; Try to match a rewritten URL and map it to 556 ;; Try to match a rewritten URL and map it to
555 ;; a real file. Compare redirects without 557 ;; a real file. Compare redirects without
556 ;; suffix. 558 ;; suffix.
557 (when (string-match-p (car rewrite) f2) 559 (when (string-match-p (car rewrite) f1)
558 (throw 'result (concat wdir (cdr rewrite)))))))) 560 (throw 'result (concat wdir (cdr rewrite))))))))
559 ;; -- end of redirects -- 561 ;; -- end of redirects --
560 562
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el
index 0e04d4b5a89..9a3ff53aa4d 100644
--- a/lisp/org/org-src.el
+++ b/lisp/org/org-src.el
@@ -424,11 +424,10 @@ Assume point is in the corresponding edit buffer."
424 (buffer-string)))) 424 (buffer-string))))
425 425
426(defun org-src--edit-element 426(defun org-src--edit-element
427 (datum name &optional major write-back contents remote) 427 (datum name &optional initialize write-back contents remote)
428 "Edit DATUM contents in a dedicated buffer NAME. 428 "Edit DATUM contents in a dedicated buffer NAME.
429 429
430MAJOR is the major mode used in the edit buffer. A nil value is 430INITIALIZE is a function to call upon creating the buffer.
431equivalent to `fundamental-mode'.
432 431
433When WRITE-BACK is non-nil, assume contents will replace original 432When WRITE-BACK is non-nil, assume contents will replace original
434region. Moreover, if it is a function, apply it in the edit 433region. Moreover, if it is a function, apply it in the edit
@@ -489,12 +488,13 @@ Leave point in edit buffer."
489 (unless preserve-ind (org-do-remove-indentation)) 488 (unless preserve-ind (org-do-remove-indentation))
490 (set-buffer-modified-p nil) 489 (set-buffer-modified-p nil)
491 (setq buffer-file-name nil) 490 (setq buffer-file-name nil)
492 ;; Start major mode. 491 ;; Initialize buffer.
493 (if (not major) (fundamental-mode) 492 (when (functionp initialize)
494 (let ((org-inhibit-startup t)) 493 (let ((org-inhibit-startup t))
495 (condition-case e (funcall major) 494 (condition-case e
496 (error (message "Language mode `%s' fails with: %S" 495 (funcall initialize)
497 major (nth 1 e)))))) 496 (error (message "Initialization fails with: %S"
497 (error-message-string e))))))
498 ;; Transmit buffer-local variables for exit function. It must 498 ;; Transmit buffer-local variables for exit function. It must
499 ;; be done after initializing major mode, as this operation 499 ;; be done after initializing major mode, as this operation
500 ;; may reset them otherwise. 500 ;; may reset them otherwise.
@@ -837,7 +837,10 @@ A coderef format regexp can only match at the end of a line."
837 (org-src--edit-element 837 (org-src--edit-element
838 definition 838 definition
839 (format "*Edit footnote [%s]*" label) 839 (format "*Edit footnote [%s]*" label)
840 #'org-mode 840 (let ((source (current-buffer)))
841 (lambda ()
842 (org-mode)
843 (org-clone-local-variables source)))
841 (lambda () 844 (lambda ()
842 (if (not inline?) (delete-region (point) (search-forward "]")) 845 (if (not inline?) (delete-region (point) (search-forward "]"))
843 (delete-region (point) (search-forward ":" nil t 2)) 846 (delete-region (point) (search-forward ":" nil t 2))
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 357fdcfa441..6b4e21b6468 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -1335,7 +1335,7 @@ Only data lines count for this."
1335 (org-table-check-inside-data-field)) 1335 (org-table-check-inside-data-field))
1336 (save-excursion 1336 (save-excursion
1337 (let ((c 0) 1337 (let ((c 0)
1338 (pos (point))) 1338 (pos (line-beginning-position)))
1339 (goto-char (org-table-begin)) 1339 (goto-char (org-table-begin))
1340 (while (<= (point) pos) 1340 (while (<= (point) pos)
1341 (when (looking-at org-table-dataline-regexp) (cl-incf c)) 1341 (when (looking-at org-table-dataline-regexp) (cl-incf c))
@@ -1532,28 +1532,31 @@ non-nil, the one above is used."
1532 (dline1 (org-table-current-dline)) 1532 (dline1 (org-table-current-dline))
1533 (dline2 (+ dline1 (if up -1 1))) 1533 (dline2 (+ dline1 (if up -1 1)))
1534 (tonew (if up 0 2)) 1534 (tonew (if up 0 2))
1535 txt hline2p) 1535 hline2p)
1536 (when (and up (= (point-min) (line-beginning-position)))
1537 (user-error "Cannot move row further"))
1536 (beginning-of-line tonew) 1538 (beginning-of-line tonew)
1537 (unless (org-at-table-p) 1539 (when (or (and (not up) (eobp)) (not (org-at-table-p)))
1538 (goto-char pos) 1540 (goto-char pos)
1539 (user-error "Cannot move row further")) 1541 (user-error "Cannot move row further"))
1540 (setq hline2p (looking-at org-table-hline-regexp)) 1542 (setq hline2p (looking-at org-table-hline-regexp))
1541 (goto-char pos) 1543 (goto-char pos)
1542 (beginning-of-line 1) 1544 (let ((row (delete-and-extract-region (line-beginning-position)
1543 (setq pos (point)) 1545 (line-beginning-position 2))))
1544 (setq txt (buffer-substring (point) (1+ (point-at-eol)))) 1546 (beginning-of-line tonew)
1545 (delete-region (point) (1+ (point-at-eol))) 1547 (unless (bolp) (insert "\n")) ;at eob without a newline
1546 (beginning-of-line tonew) 1548 (insert row)
1547 (insert txt) 1549 (unless (bolp) (insert "\n")) ;missing final newline in ROW
1548 (beginning-of-line 0) 1550 (beginning-of-line 0)
1549 (org-move-to-column col) 1551 (org-move-to-column col)
1550 (unless (or hline1p hline2p 1552 (unless (or hline1p hline2p
1551 (not (or (not org-table-fix-formulas-confirm) 1553 (not (or (not org-table-fix-formulas-confirm)
1552 (funcall org-table-fix-formulas-confirm 1554 (funcall org-table-fix-formulas-confirm
1553 "Fix formulas? ")))) 1555 "Fix formulas? "))))
1554 (org-table-fix-formulas 1556 (org-table-fix-formulas
1555 "@" (list (cons (number-to-string dline1) (number-to-string dline2)) 1557 "@" (list
1556 (cons (number-to-string dline2) (number-to-string dline1))))))) 1558 (cons (number-to-string dline1) (number-to-string dline2))
1559 (cons (number-to-string dline2) (number-to-string dline1))))))))
1557 1560
1558;;;###autoload 1561;;;###autoload
1559(defun org-table-insert-row (&optional arg) 1562(defun org-table-insert-row (&optional arg)
diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el
index 2db3eae2d8a..182290a707e 100644
--- a/lisp/org/org-version.el
+++ b/lisp/org/org-version.el
@@ -5,13 +5,13 @@
5(defun org-release () 5(defun org-release ()
6 "The release version of Org. 6 "The release version of Org.
7Inserted by installing Org mode or when a release is made." 7Inserted by installing Org mode or when a release is made."
8 (let ((org-release "9.0.9")) 8 (let ((org-release "9.0.10"))
9 org-release)) 9 org-release))
10;;;###autoload 10;;;###autoload
11(defun org-git-version () 11(defun org-git-version ()
12 "The Git version of org-mode. 12 "The Git version of org-mode.
13Inserted by installing Org or when a release is made." 13Inserted by installing Org or when a release is made."
14 (let ((org-git-version "release_9.0.9")) 14 (let ((org-git-version "release_9.0.10"))
15 org-git-version)) 15 org-git-version))
16 16
17(provide 'org-version) 17(provide 'org-version)
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 5d10eed1511..87758fdfdd0 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -128,6 +128,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
128(declare-function org-clock-timestamps-down "org-clock" (&optional n)) 128(declare-function org-clock-timestamps-down "org-clock" (&optional n))
129(declare-function org-clock-timestamps-up "org-clock" (&optional n)) 129(declare-function org-clock-timestamps-up "org-clock" (&optional n))
130(declare-function org-clock-update-time-maybe "org-clock" ()) 130(declare-function org-clock-update-time-maybe "org-clock" ())
131(declare-function org-clocking-buffer "org-clock" ())
131(declare-function org-clocktable-shift "org-clock" (dir n)) 132(declare-function org-clocktable-shift "org-clock" (dir n))
132(declare-function org-element-at-point "org-element" ()) 133(declare-function org-element-at-point "org-element" ())
133(declare-function org-element-cache-refresh "org-element" (pos)) 134(declare-function org-element-cache-refresh "org-element" (pos))
@@ -1119,8 +1120,8 @@ Or return the original if not disputed."
1119(defcustom org-ellipsis nil 1120(defcustom org-ellipsis nil
1120 "The ellipsis to use in the Org mode outline. 1121 "The ellipsis to use in the Org mode outline.
1121 1122
1122When nil, just use the standard three dots. 1123When nil, just use the standard three dots. When a non-empty string,
1123When a string, use that string instead. 1124use that string instead.
1124 1125
1125The change affects only Org mode (which will then use its own display table). 1126The change affects only Org mode (which will then use its own display table).
1126Changing this requires executing `\\[org-mode]' in a buffer to become 1127Changing this requires executing `\\[org-mode]' in a buffer to become
@@ -1128,10 +1129,10 @@ effective."
1128 :group 'org-startup 1129 :group 'org-startup
1129 :type '(choice (const :tag "Default" nil) 1130 :type '(choice (const :tag "Default" nil)
1130 (string :tag "String" :value "...#")) 1131 (string :tag "String" :value "...#"))
1131 :safe #'string-or-null-p) 1132 :safe (lambda (v) (and (string-or-null-p v) (not (equal "" v)))))
1132 1133
1133(defvar org-display-table nil 1134(defvar org-display-table nil
1134 "The display table for org-mode, in case `org-ellipsis' is non-nil.") 1135 "The display table for Org mode, in case `org-ellipsis' is non-nil.")
1135 1136
1136(defgroup org-keywords nil 1137(defgroup org-keywords nil
1137 "Keywords in Org mode." 1138 "Keywords in Org mode."
@@ -3573,8 +3574,10 @@ See also `org-tag-persistent-alist' to sidestep this behavior."
3573 :group 'org-tags 3574 :group 'org-tags
3574 :type '(repeat 3575 :type '(repeat
3575 (choice 3576 (choice
3576 (cons (string :tag "Tag name") 3577 (cons :tag "Tag with key"
3577 (character :tag "Access char")) 3578 (string :tag "Tag name")
3579 (character :tag "Access char"))
3580 (list :tag "Tag" (string :tag "Tag name"))
3578 (const :tag "Start radio group" (:startgroup)) 3581 (const :tag "Start radio group" (:startgroup))
3579 (const :tag "Start tag group, non distinct" (:startgrouptag)) 3582 (const :tag "Start tag group, non distinct" (:startgrouptag))
3580 (const :tag "Group tags delimiter" (:grouptags)) 3583 (const :tag "Group tags delimiter" (:grouptags))
@@ -3606,8 +3609,10 @@ on a per-file basis, insert anywhere in the file:
3606 :group 'org-tags 3609 :group 'org-tags
3607 :type '(repeat 3610 :type '(repeat
3608 (choice 3611 (choice
3609 (cons (string :tag "Tag name") 3612 (cons :tag "Tag with key"
3613 (string :tag "Tag name")
3610 (character :tag "Access char")) 3614 (character :tag "Access char"))
3615 (list :tag "Tag" (string :tag "Tag name"))
3611 (const :tag "Start radio group" (:startgroup)) 3616 (const :tag "Start radio group" (:startgroup))
3612 (const :tag "Start tag group, non distinct" (:startgrouptag)) 3617 (const :tag "Start tag group, non distinct" (:startgrouptag))
3613 (const :tag "Group tags delimiter" (:grouptags)) 3618 (const :tag "Group tags delimiter" (:grouptags))
@@ -4852,7 +4857,9 @@ Otherwise, these types are allowed:
4852 :group 'org-sparse-trees) 4857 :group 'org-sparse-trees)
4853 4858
4854(defun org-cycle-hide-archived-subtrees (state) 4859(defun org-cycle-hide-archived-subtrees (state)
4855 "Re-hide all archived subtrees after a visibility state change." 4860 "Re-hide all archived subtrees after a visibility state change.
4861STATE should be one of the symbols listed in the docstring of
4862`org-cycle-hook'."
4856 (when (and (not org-cycle-open-archived-trees) 4863 (when (and (not org-cycle-open-archived-trees)
4857 (not (memq state '(overview folded)))) 4864 (not (memq state '(overview folded))))
4858 (save-excursion 4865 (save-excursion
@@ -5582,15 +5589,13 @@ The following commands are available:
5582 (setq-local outline-regexp org-outline-regexp) 5589 (setq-local outline-regexp org-outline-regexp)
5583 (setq-local outline-level 'org-outline-level) 5590 (setq-local outline-level 'org-outline-level)
5584 (setq bidi-paragraph-direction 'left-to-right) 5591 (setq bidi-paragraph-direction 'left-to-right)
5585 (when (and org-ellipsis 5592 (when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
5586 (fboundp 'set-display-table-slot) (boundp 'buffer-display-table)
5587 (fboundp 'make-glyph-code))
5588 (unless org-display-table 5593 (unless org-display-table
5589 (setq org-display-table (make-display-table))) 5594 (setq org-display-table (make-display-table)))
5590 (set-display-table-slot 5595 (set-display-table-slot
5591 org-display-table 4 5596 org-display-table 4
5592 (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis)) 5597 (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis))
5593 (if (stringp org-ellipsis) org-ellipsis "...")))) 5598 org-ellipsis)))
5594 (setq buffer-display-table org-display-table)) 5599 (setq buffer-display-table org-display-table))
5595 (org-set-regexps-and-options) 5600 (org-set-regexps-and-options)
5596 (org-set-font-lock-defaults) 5601 (org-set-font-lock-defaults)
@@ -6210,9 +6215,10 @@ by a #."
6210 'keymap org-mouse-map)) 6215 'keymap org-mouse-map))
6211 (org-rear-nonsticky-at (match-end 0)) 6216 (org-rear-nonsticky-at (match-end 0))
6212 (when org-display-custom-times 6217 (when org-display-custom-times
6213 (if (match-end 3) 6218 ;; If it's a date range, activate custom time for second date.
6214 (org-display-custom-time (match-beginning 3) (match-end 3)) 6219 (when (match-end 3)
6215 (org-display-custom-time (match-beginning 1) (match-end 1)))) 6220 (org-display-custom-time (match-beginning 3) (match-end 3)))
6221 (org-display-custom-time (match-beginning 1) (match-end 1)))
6216 t)) 6222 t))
6217 6223
6218(defvar-local org-target-link-regexp nil 6224(defvar-local org-target-link-regexp nil
@@ -7318,12 +7324,13 @@ open and agenda-wise Org files."
7318 7324
7319(defun org-cycle-hide-drawers (state &optional exceptions) 7325(defun org-cycle-hide-drawers (state &optional exceptions)
7320 "Re-hide all drawers after a visibility state change. 7326 "Re-hide all drawers after a visibility state change.
7321When non-nil, optional argument EXCEPTIONS is a list of strings 7327STATE should be one of the symbols listed in the docstring of
7322specifying which drawers should not be hidden." 7328`org-cycle-hook'. When non-nil, optional argument EXCEPTIONS is
7329a list of strings specifying which drawers should not be hidden."
7323 (when (and (derived-mode-p 'org-mode) 7330 (when (and (derived-mode-p 'org-mode)
7324 (not (memq state '(overview folded contents)))) 7331 (not (memq state '(overview folded contents))))
7325 (save-excursion 7332 (save-excursion
7326 (let* ((globalp (memq state '(contents all))) 7333 (let* ((globalp (eq state 'all))
7327 (beg (if globalp (point-min) (point))) 7334 (beg (if globalp (point-min) (point)))
7328 (end (if globalp (point-max) 7335 (end (if globalp (point-max)
7329 (if (eq state 'children) 7336 (if (eq state 'children)
@@ -9049,14 +9056,6 @@ A non-nil value for INTERACTIVE? is used to signal that this
9049function is being called interactively." 9056function is being called interactively."
9050 (interactive (list current-prefix-arg nil nil nil nil t)) 9057 (interactive (list current-prefix-arg nil nil nil nil t))
9051 (let ((case-func (if with-case 'identity 'downcase)) 9058 (let ((case-func (if with-case 'identity 'downcase))
9052 (cmstr
9053 ;; The clock marker is lost when using `sort-subr', let's
9054 ;; store the clocking string.
9055 (when (equal (marker-buffer org-clock-marker) (current-buffer))
9056 (save-excursion
9057 (goto-char org-clock-marker)
9058 (buffer-substring-no-properties (line-beginning-position)
9059 (point)))))
9060 start beg end stars re re2 9059 start beg end stars re re2
9061 txt what tmp) 9060 txt what tmp)
9062 ;; Find beginning and end of region to sort 9061 ;; Find beginning and end of region to sort
@@ -9138,9 +9137,20 @@ function is being called interactively."
9138 9137
9139 (save-restriction 9138 (save-restriction
9140 (narrow-to-region start end) 9139 (narrow-to-region start end)
9141 (let ((dcst (downcase sorting-type)) 9140 (let ((restore-clock?
9141 ;; The clock marker is lost when using `sort-subr'; mark
9142 ;; the clock with temporary `:org-clock-marker-backup'
9143 ;; text property.
9144 (when (and (eq (org-clocking-buffer) (current-buffer))
9145 (<= start (marker-position org-clock-marker))
9146 (>= end (marker-position org-clock-marker)))
9147 (org-with-silent-modifications
9148 (put-text-property (1- org-clock-marker) org-clock-marker
9149 :org-clock-marker-backup t))
9150 t))
9151 (dcst (downcase sorting-type))
9142 (case-fold-search nil) 9152 (case-fold-search nil)
9143 (now (current-time))) 9153 (now (current-time)))
9144 (sort-subr 9154 (sort-subr
9145 (/= dcst sorting-type) 9155 (/= dcst sorting-type)
9146 ;; This function moves to the beginning character of the "record" to 9156 ;; This function moves to the beginning character of the "record" to
@@ -9222,14 +9232,14 @@ function is being called interactively."
9222 (concat "Function for comparing keys " 9232 (concat "Function for comparing keys "
9223 "(empty for default `sort-subr' predicate): ") 9233 "(empty for default `sort-subr' predicate): ")
9224 'allow-empty)))) 9234 'allow-empty))))
9225 ((member dcst '(?p ?t ?s ?d ?c ?k)) '<))))) 9235 ((member dcst '(?p ?t ?s ?d ?c ?k)) '<)))
9236 (when restore-clock?
9237 (move-marker org-clock-marker
9238 (1+ (next-single-property-change
9239 start :org-clock-marker-backup)))
9240 (remove-text-properties (1- org-clock-marker) org-clock-marker
9241 '(:org-clock-marker-backup t)))))
9226 (run-hooks 'org-after-sorting-entries-or-items-hook) 9242 (run-hooks 'org-after-sorting-entries-or-items-hook)
9227 ;; Reset the clock marker if needed
9228 (when cmstr
9229 (save-excursion
9230 (goto-char start)
9231 (search-forward cmstr nil t)
9232 (move-marker org-clock-marker (point))))
9233 (message "Sorting entries...done"))) 9243 (message "Sorting entries...done")))
9234 9244
9235;;; The orgstruct minor mode 9245;;; The orgstruct minor mode
@@ -9590,42 +9600,6 @@ Possible values in the list of contexts are `table', `headline', and `item'."
9590 (org-in-item-p))) 9600 (org-in-item-p)))
9591 (goto-char pos)))) 9601 (goto-char pos))))
9592 9602
9593(defconst org-unique-local-variables
9594 '(org-element--cache
9595 org-element--cache-objects
9596 org-element--cache-sync-keys
9597 org-element--cache-sync-requests
9598 org-element--cache-sync-timer)
9599 "List of local variables that cannot be transferred to another buffer.")
9600
9601(defun org-get-local-variables ()
9602 "Return a list of all local variables in an Org mode buffer."
9603 (delq nil
9604 (mapcar
9605 (lambda (x)
9606 (let* ((binding (if (symbolp x) (list x) (list (car x) (cdr x))))
9607 (name (car binding)))
9608 (and (not (get name 'org-state))
9609 (not (memq name org-unique-local-variables))
9610 (string-match-p
9611 "\\`\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|\
9612auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
9613 (symbol-name name))
9614 binding)))
9615 (with-temp-buffer
9616 (org-mode)
9617 (buffer-local-variables)))))
9618
9619(defun org-clone-local-variables (from-buffer &optional regexp)
9620 "Clone local variables from FROM-BUFFER.
9621Optional argument REGEXP selects variables to clone."
9622 (dolist (pair (buffer-local-variables from-buffer))
9623 (pcase pair
9624 (`(,name . ,value) ;ignore unbound variables
9625 (when (and (not (memq name org-unique-local-variables))
9626 (or (null regexp) (string-match-p regexp (symbol-name name))))
9627 (set (make-local-variable name) value))))))
9628
9629;;;###autoload 9603;;;###autoload
9630(defun org-run-like-in-org-mode (cmd) 9604(defun org-run-like-in-org-mode (cmd)
9631 "Run a command, pretending that the current buffer is in Org mode. 9605 "Run a command, pretending that the current buffer is in Org mode.
@@ -10780,9 +10754,10 @@ When optional argument REFERENCE-BUFFER is non-nil, it should
10780specify a buffer from where the link search should happen. This 10754specify a buffer from where the link search should happen. This
10781is used internally by `org-open-link-from-string'. 10755is used internally by `org-open-link-from-string'.
10782 10756
10783On top of syntactically correct links, this function will open 10757On top of syntactically correct links, this function will also
10784the link at point in comments or comment blocks and the first 10758try to open links and time-stamps in comments, example
10785link in a property drawer line." 10759blocks... i.e., whenever point is on something looking like
10760a timestamp or a link."
10786 (interactive "P") 10761 (interactive "P")
10787 ;; On a code block, open block's results. 10762 ;; On a code block, open block's results.
10788 (unless (call-interactively 'org-babel-open-src-block-result) 10763 (unless (call-interactively 'org-babel-open-src-block-result)
@@ -10795,38 +10770,51 @@ link in a property drawer line."
10795 ;; the closest one. 10770 ;; the closest one.
10796 (org-element-lineage 10771 (org-element-lineage
10797 (org-element-context) 10772 (org-element-context)
10798 '(clock comment comment-block footnote-definition 10773 '(clock footnote-definition footnote-reference headline
10799 footnote-reference headline inlinetask keyword link 10774 inlinetask link timestamp)
10800 node-property timestamp)
10801 t)) 10775 t))
10802 (type (org-element-type context)) 10776 (type (org-element-type context))
10803 (value (org-element-property :value context))) 10777 (value (org-element-property :value context)))
10804 (cond 10778 (cond
10805 ((not context) (user-error "No link found"))
10806 ;; Exception: open timestamps and links in properties
10807 ;; drawers, keywords and comments.
10808 ((memq type '(comment comment-block keyword node-property))
10809 (call-interactively #'org-open-at-point-global))
10810 ;; On a headline or an inlinetask, but not on a timestamp, 10779 ;; On a headline or an inlinetask, but not on a timestamp,
10811 ;; a link, a footnote reference or on tags. 10780 ;; a link, a footnote reference.
10812 ((and (memq type '(headline inlinetask)) 10781 ((memq type '(headline inlinetask))
10813 ;; Not on tags. 10782 (org-match-line org-complex-heading-regexp)
10814 (let ((case-fold-search nil)) 10783 (if (and (match-beginning 5)
10815 (save-excursion 10784 (>= (point) (match-beginning 5))
10816 (beginning-of-line) 10785 (< (point) (match-end 5)))
10817 (looking-at org-complex-heading-regexp)) 10786 ;; On tags.
10818 (or (not (match-beginning 5)) 10787 (org-tags-view arg (substring (match-string 5) 0 -1))
10819 (< (point) (match-beginning 5))))) 10788 ;; Not on tags.
10820 (let* ((data (org-offer-links-in-entry (current-buffer) (point) arg)) 10789 (pcase (org-offer-links-in-entry (current-buffer) (point) arg)
10821 (links (car data)) 10790 (`(nil . ,_)
10822 (links-end (cdr data))) 10791 (require 'org-attach)
10823 (if links 10792 (org-attach-reveal 'if-exists))
10824 (dolist (link (if (stringp links) (list links) links)) 10793 (`(,links . ,links-end)
10825 (search-forward link nil links-end) 10794 (dolist (link (if (stringp links) (list links) links))
10826 (goto-char (match-beginning 0)) 10795 (search-forward link nil links-end)
10827 (org-open-at-point)) 10796 (goto-char (match-beginning 0))
10828 (require 'org-attach) 10797 (org-open-at-point))))))
10829 (org-attach-reveal 'if-exists)))) 10798 ;; On a footnote reference or at definition's label.
10799 ((or (eq type 'footnote-reference)
10800 (and (eq type 'footnote-definition)
10801 (save-excursion
10802 ;; Do not validate action when point is on the
10803 ;; spaces right after the footnote label, in
10804 ;; order to be on par with behaviour on links.
10805 (skip-chars-forward " \t")
10806 (let ((begin
10807 (org-element-property :contents-begin context)))
10808 (if begin (< (point) begin)
10809 (= (org-element-property :post-affiliated context)
10810 (line-beginning-position)))))))
10811 (org-footnote-action))
10812 ;; No valid context. Ignore catch-all types like `headline'.
10813 ;; If point is on something looking like a link or
10814 ;; a time-stamp, try opening it. It may be useful in
10815 ;; comments, example blocks...
10816 ((memq type '(footnote-definition headline inlinetask nil))
10817 (call-interactively #'org-open-at-point-global))
10830 ;; On a clock line, make sure point is on the timestamp 10818 ;; On a clock line, make sure point is on the timestamp
10831 ;; before opening it. 10819 ;; before opening it.
10832 ((and (eq type 'clock) 10820 ((and (eq type 'clock)
@@ -10842,14 +10830,6 @@ link in a property drawer line."
10842 (point))) 10830 (point)))
10843 (user-error "No link found")) 10831 (user-error "No link found"))
10844 ((eq type 'timestamp) (org-follow-timestamp-link)) 10832 ((eq type 'timestamp) (org-follow-timestamp-link))
10845 ;; On tags within a headline or an inlinetask.
10846 ((and (memq type '(headline inlinetask))
10847 (let ((case-fold-search nil))
10848 (save-excursion (beginning-of-line)
10849 (looking-at org-complex-heading-regexp))
10850 (and (match-beginning 5)
10851 (>= (point) (match-beginning 5)))))
10852 (org-tags-view arg (substring (match-string 5) 0 -1)))
10853 ((eq type 'link) 10833 ((eq type 'link)
10854 ;; When link is located within the description of another 10834 ;; When link is located within the description of another
10855 ;; link (e.g., an inline image), always open the parent 10835 ;; link (e.g., an inline image), always open the parent
@@ -10919,20 +10899,6 @@ link in a property drawer line."
10919 (widen)) 10899 (widen))
10920 (goto-char destination)))) 10900 (goto-char destination))))
10921 (t (browse-url-at-point)))))) 10901 (t (browse-url-at-point))))))
10922 ;; On a footnote reference or at a footnote definition's label.
10923 ((or (eq type 'footnote-reference)
10924 (and (eq type 'footnote-definition)
10925 (save-excursion
10926 ;; Do not validate action when point is on the
10927 ;; spaces right after the footnote label, in
10928 ;; order to be on par with behaviour on links.
10929 (skip-chars-forward " \t")
10930 (let ((begin
10931 (org-element-property :contents-begin context)))
10932 (if begin (< (point) begin)
10933 (= (org-element-property :post-affiliated context)
10934 (line-beginning-position)))))))
10935 (org-footnote-action))
10936 (t (user-error "No link found"))))) 10902 (t (user-error "No link found")))))
10937 (run-hook-with-args 'org-follow-link-hook))) 10903 (run-hook-with-args 'org-follow-link-hook)))
10938 10904
@@ -11985,7 +11951,9 @@ prefix argument (`C-u C-u C-u C-c C-w')."
11985 (if (and arg (not (equal arg 3))) 11951 (if (and arg (not (equal arg 3)))
11986 (progn 11952 (progn
11987 (pop-to-buffer-same-window nbuf) 11953 (pop-to-buffer-same-window nbuf)
11988 (goto-char pos) 11954 (goto-char (cond (pos)
11955 ((org-notes-order-reversed-p) (point-min))
11956 (t (point-max))))
11989 (org-show-context 'org-goto)) 11957 (org-show-context 'org-goto))
11990 (if regionp 11958 (if regionp
11991 (progn 11959 (progn
@@ -12682,7 +12650,7 @@ When called through ELisp, arg is also interpreted in the following way:
12682 (replace-match next t t) 12650 (replace-match next t t)
12683 (cond ((equal this org-state) 12651 (cond ((equal this org-state)
12684 (message "TODO state was already %s" (org-trim next))) 12652 (message "TODO state was already %s" (org-trim next)))
12685 ((pos-visible-in-window-p hl-pos) 12653 ((not (pos-visible-in-window-p hl-pos))
12686 (message "TODO state changed to %s" (org-trim next)))) 12654 (message "TODO state changed to %s" (org-trim next))))
12687 (unless head 12655 (unless head
12688 (setq head (org-get-todo-sequence-head org-state) 12656 (setq head (org-get-todo-sequence-head org-state)
@@ -13741,7 +13709,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
13741 (org-switch-to-buffer-other-window "*Org Note*") 13709 (org-switch-to-buffer-other-window "*Org Note*")
13742 (erase-buffer) 13710 (erase-buffer)
13743 (if (memq org-log-note-how '(time state)) 13711 (if (memq org-log-note-how '(time state))
13744 (let (current-prefix-arg) (org-store-log-note)) 13712 (org-store-log-note)
13745 (let ((org-inhibit-startup t)) (org-mode)) 13713 (let ((org-inhibit-startup t)) (org-mode))
13746 (insert (format "# Insert note for %s. 13714 (insert (format "# Insert note for %s.
13747# Finish with C-c C-c, or cancel with C-c C-k.\n\n" 13715# Finish with C-c C-c, or cancel with C-c C-k.\n\n"
@@ -13818,7 +13786,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
13818 org-log-note-previous-state))))))) 13786 org-log-note-previous-state)))))))
13819 (when lines (setq note (concat note " \\\\"))) 13787 (when lines (setq note (concat note " \\\\")))
13820 (push note lines)) 13788 (push note lines))
13821 (when (and lines (not (or current-prefix-arg org-note-abort))) 13789 (when (and lines (not org-note-abort))
13822 (with-current-buffer (marker-buffer org-log-note-marker) 13790 (with-current-buffer (marker-buffer org-log-note-marker)
13823 (org-with-wide-buffer 13791 (org-with-wide-buffer
13824 ;; Find location for the new note. 13792 ;; Find location for the new note.
@@ -14811,7 +14779,7 @@ it as a time string and apply `float-time' to it. If S is nil, just return 0."
14811 ((numberp s) s) 14779 ((numberp s) s)
14812 ((stringp s) 14780 ((stringp s)
14813 (condition-case nil 14781 (condition-case nil
14814 (float-time (apply 'encode-time (org-parse-time-string s))) 14782 (float-time (apply #'encode-time (org-parse-time-string s nil t)))
14815 (error 0.))) 14783 (error 0.)))
14816 (t 0.))) 14784 (t 0.)))
14817 14785
@@ -19030,9 +18998,7 @@ looks only before point, not after."
19030 (catch 'exit 18998 (catch 'exit
19031 (let ((pos (point)) 18999 (let ((pos (point))
19032 (dodollar (member "$" (plist-get org-format-latex-options :matchers))) 19000 (dodollar (member "$" (plist-get org-format-latex-options :matchers)))
19033 (lim (progn 19001 (lim (save-excursion (org-backward-paragraph) (point)))
19034 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t)
19035 (point)))
19036 dd-on str (start 0) m re) 19002 dd-on str (start 0) m re)
19037 (goto-char pos) 19003 (goto-char pos)
19038 (when dodollar 19004 (when dodollar
@@ -19466,7 +19432,7 @@ a HTML file."
19466 (insert latex-header) 19432 (insert latex-header)
19467 (insert "\n\\begin{document}\n" string "\n\\end{document}\n"))) 19433 (insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
19468 19434
19469 (let* ((err-msg (format "Please adjust '%s' part of \ 19435 (let* ((err-msg (format "Please adjust `%s' part of \
19470`org-preview-latex-process-alist'." 19436`org-preview-latex-process-alist'."
19471 processing-type)) 19437 processing-type))
19472 (image-input-file 19438 (image-input-file
@@ -20156,6 +20122,8 @@ overwritten, and the table is not marked as requiring realignment."
20156 (call-interactively 'org-self-insert-command))))) 20122 (call-interactively 'org-self-insert-command)))))
20157 ((and 20123 ((and
20158 (org-at-table-p) 20124 (org-at-table-p)
20125 (eq N 1)
20126 (not (org-region-active-p))
20159 (progn 20127 (progn
20160 ;; Check if we blank the field, and if that triggers align. 20128 ;; Check if we blank the field, and if that triggers align.
20161 (and (featurep 'org-table) org-table-auto-blank-field 20129 (and (featurep 'org-table) org-table-auto-blank-field
@@ -20169,7 +20137,6 @@ overwritten, and the table is not marked as requiring realignment."
20169 ;; width. 20137 ;; width.
20170 (org-table-blank-field))) 20138 (org-table-blank-field)))
20171 t) 20139 t)
20172 (eq N 1)
20173 (looking-at "[^|\n]* \\( \\)|")) 20140 (looking-at "[^|\n]* \\( \\)|"))
20174 ;; There is room for insertion without re-aligning the table. 20141 ;; There is room for insertion without re-aligning the table.
20175 (delete-region (match-beginning 1) (match-end 1)) 20142 (delete-region (match-beginning 1) (match-end 1))
@@ -20198,14 +20165,24 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
20198 (or (not (boundp 'visible-mode)) (not visible-mode)) 20165 (or (not (boundp 'visible-mode)) (not visible-mode))
20199 (or (get-char-property (point) 'invisible) 20166 (or (get-char-property (point) 'invisible)
20200 (get-char-property (max (point-min) (1- (point))) 'invisible))) 20167 (get-char-property (max (point-min) (1- (point))) 'invisible)))
20201 ;; OK, we need to take a closer look 20168 ;; OK, we need to take a closer look. Do not consider
20202 (let* ((invisible-at-point (get-char-property (point) 'invisible)) 20169 ;; invisibility obtained through text properties (e.g., link
20203 (invisible-before-point (unless (bobp) (get-char-property 20170 ;; fontification), as it cannot be toggled.
20204 (1- (point)) 'invisible))) 20171 (let* ((invisible-at-point
20172 (pcase (get-char-property-and-overlay (point) 'invisible)
20173 (`(,_ . ,(and (pred overlayp) o)) o)))
20174 ;; Assume that point cannot land in the middle of an
20175 ;; overlay, or between two overlays.
20176 (invisible-before-point
20177 (and (not invisible-at-point)
20178 (not (bobp))
20179 (pcase (get-char-property-and-overlay (1- (point)) 'invisible)
20180 (`(,_ . ,(and (pred overlayp) o)) o))))
20205 (border-and-ok-direction 20181 (border-and-ok-direction
20206 (or 20182 (or
20207 ;; Check if we are acting predictably before invisible text 20183 ;; Check if we are acting predictably before invisible
20208 (and invisible-at-point (not invisible-before-point) 20184 ;; text.
20185 (and invisible-at-point
20209 (memq kind '(insert delete-backward))) 20186 (memq kind '(insert delete-backward)))
20210 ;; Check if we are acting predictably after invisible text 20187 ;; Check if we are acting predictably after invisible text
20211 ;; This works not well, and I have turned it off. It seems 20188 ;; This works not well, and I have turned it off. It seems
@@ -20213,8 +20190,7 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
20213 ;; (and (not invisible-at-point) invisible-before-point 20190 ;; (and (not invisible-at-point) invisible-before-point
20214 ;; (memq kind '(insert delete))) 20191 ;; (memq kind '(insert delete)))
20215 ))) 20192 )))
20216 (when (or (memq invisible-at-point '(outline org-hide-block t)) 20193 (when (or invisible-at-point invisible-before-point)
20217 (memq invisible-before-point '(outline org-hide-block t)))
20218 (when (eq org-catch-invisible-edits 'error) 20194 (when (eq org-catch-invisible-edits 'error)
20219 (user-error "Editing in invisible areas is prohibited, make them visible first")) 20195 (user-error "Editing in invisible areas is prohibited, make them visible first"))
20220 (if (and org-custom-properties-overlays 20196 (if (and org-custom-properties-overlays
@@ -20223,9 +20199,17 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
20223 ;; Make the area visible 20199 ;; Make the area visible
20224 (save-excursion 20200 (save-excursion
20225 (when invisible-before-point 20201 (when invisible-before-point
20226 (goto-char (previous-single-char-property-change 20202 (goto-char
20227 (point) 'invisible))) 20203 (previous-single-char-property-change (point) 'invisible)))
20228 (outline-show-subtree)) 20204 ;; Remove whatever overlay is currently making yet-to-be
20205 ;; edited text invisible. Also remove nested invisibility
20206 ;; related overlays.
20207 (delete-overlay (or invisible-at-point invisible-before-point))
20208 (let ((origin (if invisible-at-point (point) (1- (point)))))
20209 (while (pcase (get-char-property-and-overlay origin 'invisible)
20210 (`(,_ . ,(and (pred overlayp) o))
20211 (delete-overlay o)
20212 t)))))
20229 (cond 20213 (cond
20230 ((eq org-catch-invisible-edits 'show) 20214 ((eq org-catch-invisible-edits 'show)
20231 ;; That's it, we do the edit after showing 20215 ;; That's it, we do the edit after showing
@@ -20914,16 +20898,14 @@ this numeric value."
20914(defun org-copy-visible (beg end) 20898(defun org-copy-visible (beg end)
20915 "Copy the visible parts of the region." 20899 "Copy the visible parts of the region."
20916 (interactive "r") 20900 (interactive "r")
20917 (let (snippets s) 20901 (let ((result ""))
20918 (save-excursion 20902 (while (/= beg end)
20919 (save-restriction 20903 (when (get-char-property beg 'invisible)
20920 (narrow-to-region beg end) 20904 (setq beg (next-single-char-property-change beg 'invisible nil end)))
20921 (setq s (goto-char (point-min))) 20905 (let ((next (next-single-char-property-change beg 'invisible nil end)))
20922 (while (not (= (point) (point-max))) 20906 (setq result (concat result (buffer-substring beg next)))
20923 (goto-char (org-find-invisible)) 20907 (setq beg next)))
20924 (push (buffer-substring s (point)) snippets) 20908 (kill-new result)))
20925 (setq s (goto-char (org-find-visible))))))
20926 (kill-new (apply 'concat (nreverse snippets)))))
20927 20909
20928(defun org-copy-special () 20910(defun org-copy-special ()
20929 "Copy region in table or copy current subtree. 20911 "Copy region in table or copy current subtree.
@@ -24416,74 +24398,74 @@ item, etc. It also provides some special moves for convenience:
24416 - On a table or a property drawer, jump after it. 24398 - On a table or a property drawer, jump after it.
24417 - On a verse or source block, stop after blank lines." 24399 - On a verse or source block, stop after blank lines."
24418 (interactive) 24400 (interactive)
24419 (when (eobp) (user-error "Cannot move further down")) 24401 (unless (eobp)
24420 (let* ((deactivate-mark nil) 24402 (let* ((deactivate-mark nil)
24421 (element (org-element-at-point)) 24403 (element (org-element-at-point))
24422 (type (org-element-type element)) 24404 (type (org-element-type element))
24423 (post-affiliated (org-element-property :post-affiliated element)) 24405 (post-affiliated (org-element-property :post-affiliated element))
24424 (contents-begin (org-element-property :contents-begin element)) 24406 (contents-begin (org-element-property :contents-begin element))
24425 (contents-end (org-element-property :contents-end element)) 24407 (contents-end (org-element-property :contents-end element))
24426 (end (let ((end (org-element-property :end element)) (parent element)) 24408 (end (let ((end (org-element-property :end element)) (parent element))
24427 (while (and (setq parent (org-element-property :parent parent)) 24409 (while (and (setq parent (org-element-property :parent parent))
24428 (= (org-element-property :contents-end parent) end)) 24410 (= (org-element-property :contents-end parent) end))
24429 (setq end (org-element-property :end parent))) 24411 (setq end (org-element-property :end parent)))
24430 end))) 24412 end)))
24431 (cond ((not element) 24413 (cond ((not element)
24432 (skip-chars-forward " \r\t\n") 24414 (skip-chars-forward " \r\t\n")
24433 (or (eobp) (beginning-of-line))) 24415 (or (eobp) (beginning-of-line)))
24434 ;; On affiliated keywords, move to element's beginning. 24416 ;; On affiliated keywords, move to element's beginning.
24435 ((< (point) post-affiliated) 24417 ((< (point) post-affiliated)
24436 (goto-char post-affiliated)) 24418 (goto-char post-affiliated))
24437 ;; At a table row, move to the end of the table. Similarly, 24419 ;; At a table row, move to the end of the table. Similarly,
24438 ;; at a node property, move to the end of the property 24420 ;; at a node property, move to the end of the property
24439 ;; drawer. 24421 ;; drawer.
24440 ((memq type '(node-property table-row)) 24422 ((memq type '(node-property table-row))
24441 (goto-char (org-element-property 24423 (goto-char (org-element-property
24442 :end (org-element-property :parent element)))) 24424 :end (org-element-property :parent element))))
24443 ((memq type '(property-drawer table)) (goto-char end)) 24425 ((memq type '(property-drawer table)) (goto-char end))
24444 ;; Consider blank lines as separators in verse and source 24426 ;; Consider blank lines as separators in verse and source
24445 ;; blocks to ease editing. 24427 ;; blocks to ease editing.
24446 ((memq type '(src-block verse-block)) 24428 ((memq type '(src-block verse-block))
24447 (when (eq type 'src-block) 24429 (when (eq type 'src-block)
24448 (setq contents-end 24430 (setq contents-end
24449 (save-excursion (goto-char end) 24431 (save-excursion (goto-char end)
24450 (skip-chars-backward " \r\t\n") 24432 (skip-chars-backward " \r\t\n")
24451 (line-beginning-position)))) 24433 (line-beginning-position))))
24452 (beginning-of-line) 24434 (beginning-of-line)
24453 (when (looking-at "[ \t]*$") (skip-chars-forward " \r\t\n")) 24435 (when (looking-at "[ \t]*$") (skip-chars-forward " \r\t\n"))
24454 (if (not (re-search-forward "^[ \t]*$" contents-end t)) 24436 (if (not (re-search-forward "^[ \t]*$" contents-end t))
24455 (goto-char end) 24437 (goto-char end)
24456 (skip-chars-forward " \r\t\n") 24438 (skip-chars-forward " \r\t\n")
24457 (if (= (point) contents-end) (goto-char end) 24439 (if (= (point) contents-end) (goto-char end)
24458 (beginning-of-line)))) 24440 (beginning-of-line))))
24459 ;; With no contents, just skip element. 24441 ;; With no contents, just skip element.
24460 ((not contents-begin) (goto-char end)) 24442 ((not contents-begin) (goto-char end))
24461 ;; If contents are invisible, skip the element altogether. 24443 ;; If contents are invisible, skip the element altogether.
24462 ((org-invisible-p (line-end-position)) 24444 ((org-invisible-p (line-end-position))
24463 (cl-case type 24445 (cl-case type
24464 (headline 24446 (headline
24465 (org-with-limited-levels (outline-next-visible-heading 1))) 24447 (org-with-limited-levels (outline-next-visible-heading 1)))
24466 ;; At a plain list, make sure we move to the next item 24448 ;; At a plain list, make sure we move to the next item
24467 ;; instead of skipping the whole list. 24449 ;; instead of skipping the whole list.
24468 (plain-list (forward-char) 24450 (plain-list (forward-char)
24469 (org-forward-paragraph)) 24451 (org-forward-paragraph))
24470 (otherwise (goto-char end)))) 24452 (otherwise (goto-char end))))
24471 ((>= (point) contents-end) (goto-char end)) 24453 ((>= (point) contents-end) (goto-char end))
24472 ((>= (point) contents-begin) 24454 ((>= (point) contents-begin)
24473 ;; This can only happen on paragraphs and plain lists. 24455 ;; This can only happen on paragraphs and plain lists.
24474 (cl-case type 24456 (cl-case type
24475 (paragraph (goto-char end)) 24457 (paragraph (goto-char end))
24476 ;; At a plain list, try to move to second element in 24458 ;; At a plain list, try to move to second element in
24477 ;; first item, if possible. 24459 ;; first item, if possible.
24478 (plain-list (end-of-line) 24460 (plain-list (end-of-line)
24479 (org-forward-paragraph)))) 24461 (org-forward-paragraph))))
24480 ;; When contents start on the middle of a line (e.g. in 24462 ;; When contents start on the middle of a line (e.g. in
24481 ;; items and footnote definitions), try to reach first 24463 ;; items and footnote definitions), try to reach first
24482 ;; element starting after current line. 24464 ;; element starting after current line.
24483 ((> (line-end-position) contents-begin) 24465 ((> (line-end-position) contents-begin)
24484 (end-of-line) 24466 (end-of-line)
24485 (org-forward-paragraph)) 24467 (org-forward-paragraph))
24486 (t (goto-char contents-begin))))) 24468 (t (goto-char contents-begin))))))
24487 24469
24488(defun org-backward-paragraph () 24470(defun org-backward-paragraph ()
24489 "Move backward to start of previous paragraph or equivalent. 24471 "Move backward to start of previous paragraph or equivalent.
@@ -24498,55 +24480,55 @@ convenience:
24498 - On a table or a property drawer, move to its beginning. 24480 - On a table or a property drawer, move to its beginning.
24499 - On a verse or source block, stop before blank lines." 24481 - On a verse or source block, stop before blank lines."
24500 (interactive) 24482 (interactive)
24501 (when (bobp) (user-error "Cannot move further up")) 24483 (unless (bobp)
24502 (let* ((deactivate-mark nil) 24484 (let* ((deactivate-mark nil)
24503 (element (org-element-at-point)) 24485 (element (org-element-at-point))
24504 (type (org-element-type element)) 24486 (type (org-element-type element))
24505 (contents-begin (org-element-property :contents-begin element)) 24487 (contents-begin (org-element-property :contents-begin element))
24506 (contents-end (org-element-property :contents-end element)) 24488 (contents-end (org-element-property :contents-end element))
24507 (post-affiliated (org-element-property :post-affiliated element)) 24489 (post-affiliated (org-element-property :post-affiliated element))
24508 (begin (org-element-property :begin element))) 24490 (begin (org-element-property :begin element)))
24509 (cond 24491 (cond
24510 ((not element) (goto-char (point-min))) 24492 ((not element) (goto-char (point-min)))
24511 ((= (point) begin) 24493 ((= (point) begin)
24512 (backward-char) 24494 (backward-char)
24513 (org-backward-paragraph)) 24495 (org-backward-paragraph))
24514 ((<= (point) post-affiliated) (goto-char begin)) 24496 ((<= (point) post-affiliated) (goto-char begin))
24515 ((memq type '(node-property table-row)) 24497 ((memq type '(node-property table-row))
24516 (goto-char (org-element-property 24498 (goto-char (org-element-property
24517 :post-affiliated (org-element-property :parent element)))) 24499 :post-affiliated (org-element-property :parent element))))
24518 ((memq type '(property-drawer table)) (goto-char begin)) 24500 ((memq type '(property-drawer table)) (goto-char begin))
24519 ((memq type '(src-block verse-block)) 24501 ((memq type '(src-block verse-block))
24520 (when (eq type 'src-block) 24502 (when (eq type 'src-block)
24521 (setq contents-begin 24503 (setq contents-begin
24522 (save-excursion (goto-char begin) (forward-line) (point)))) 24504 (save-excursion (goto-char begin) (forward-line) (point))))
24523 (if (= (point) contents-begin) (goto-char post-affiliated) 24505 (if (= (point) contents-begin) (goto-char post-affiliated)
24524 ;; Inside a verse block, see blank lines as paragraph 24506 ;; Inside a verse block, see blank lines as paragraph
24525 ;; separators. 24507 ;; separators.
24526 (let ((origin (point))) 24508 (let ((origin (point)))
24527 (skip-chars-backward " \r\t\n" contents-begin) 24509 (skip-chars-backward " \r\t\n" contents-begin)
24528 (when (re-search-backward "^[ \t]*$" contents-begin 'move) 24510 (when (re-search-backward "^[ \t]*$" contents-begin 'move)
24529 (skip-chars-forward " \r\t\n" origin) 24511 (skip-chars-forward " \r\t\n" origin)
24530 (if (= (point) origin) (goto-char contents-begin) 24512 (if (= (point) origin) (goto-char contents-begin)
24531 (beginning-of-line)))))) 24513 (beginning-of-line))))))
24532 ((not contents-begin) (goto-char (or post-affiliated begin))) 24514 ((not contents-begin) (goto-char (or post-affiliated begin)))
24533 ((eq type 'paragraph) 24515 ((eq type 'paragraph)
24534 (goto-char contents-begin) 24516 (goto-char contents-begin)
24535 ;; When at first paragraph in an item or a footnote definition, 24517 ;; When at first paragraph in an item or a footnote definition,
24536 ;; move directly to beginning of line. 24518 ;; move directly to beginning of line.
24537 (let ((parent-contents 24519 (let ((parent-contents
24538 (org-element-property 24520 (org-element-property
24539 :contents-begin (org-element-property :parent element)))) 24521 :contents-begin (org-element-property :parent element))))
24540 (when (and parent-contents (= parent-contents contents-begin)) 24522 (when (and parent-contents (= parent-contents contents-begin))
24541 (beginning-of-line)))) 24523 (beginning-of-line))))
24542 ;; At the end of a greater element, move to the beginning of the 24524 ;; At the end of a greater element, move to the beginning of the
24543 ;; last element within. 24525 ;; last element within.
24544 ((>= (point) contents-end) 24526 ((>= (point) contents-end)
24545 (goto-char (1- contents-end)) 24527 (goto-char (1- contents-end))
24546 (org-backward-paragraph)) 24528 (org-backward-paragraph))
24547 (t (goto-char (or post-affiliated begin)))) 24529 (t (goto-char (or post-affiliated begin))))
24548 ;; Ensure we never leave point invisible. 24530 ;; Ensure we never leave point invisible.
24549 (when (org-invisible-p (point)) (beginning-of-visual-line)))) 24531 (when (org-invisible-p (point)) (beginning-of-visual-line)))))
24550 24532
24551(defun org-forward-element () 24533(defun org-forward-element ()
24552 "Move forward by one element. 24534 "Move forward by one element.
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el
index 49562fa6918..aeb38ebc102 100644
--- a/lisp/org/ox-html.el
+++ b/lisp/org/ox-html.el
@@ -2034,7 +2034,8 @@ holding export options."
2034 (format 2034 (format
2035 (if html5-fancy 2035 (if html5-fancy
2036 "<p class=\"subtitle\">%s</p>\n" 2036 "<p class=\"subtitle\">%s</p>\n"
2037 "\n<br>\n<span class=\"subtitle\">%s</span>\n") 2037 (concat "\n" (org-html-close-tag "br" nil info) "\n"
2038 "<span class=\"subtitle\">%s</span>\n"))
2038 (org-export-data subtitle info)) 2039 (org-export-data subtitle info))
2039 ""))))) 2040 "")))))
2040 contents 2041 contents
diff --git a/lisp/org/ox-icalendar.el b/lisp/org/ox-icalendar.el
index 9ccbb272448..e1956ccdcf3 100644
--- a/lisp/org/ox-icalendar.el
+++ b/lisp/org/ox-icalendar.el
@@ -879,22 +879,24 @@ The file is stored under the name chosen in
879 "Export current agenda view to an iCalendar FILE. 879 "Export current agenda view to an iCalendar FILE.
880This function assumes major mode for current buffer is 880This function assumes major mode for current buffer is
881`org-agenda-mode'." 881`org-agenda-mode'."
882 (let* ((org-export-babel-evaluate) ; Don't evaluate Babel block. 882 (let* ((org-export-babel-evaluate) ;don't evaluate Babel blocks
883 (contents 883 (contents
884 (org-export-string-as 884 (org-export-string-as
885 (with-output-to-string 885 (with-output-to-string
886 (save-excursion 886 (save-excursion
887 (let ((p (point-min))) 887 (let ((p (point-min))
888 (seen nil)) ;prevent duplicates
888 (while (setq p (next-single-property-change p 'org-hd-marker)) 889 (while (setq p (next-single-property-change p 'org-hd-marker))
889 (let ((m (get-text-property p 'org-hd-marker))) 890 (let ((m (get-text-property p 'org-hd-marker)))
890 (when m 891 (when (and m (not (member m seen)))
892 (push m seen)
891 (with-current-buffer (marker-buffer m) 893 (with-current-buffer (marker-buffer m)
892 (org-with-wide-buffer 894 (org-with-wide-buffer
893 (goto-char (marker-position m)) 895 (goto-char (marker-position m))
894 (princ 896 (princ
895 (org-element-normalize-string 897 (org-element-normalize-string
896 (buffer-substring 898 (buffer-substring (point)
897 (point) (progn (outline-next-heading) (point))))))))) 899 (org-entry-end-position))))))))
898 (forward-line))))) 900 (forward-line)))))
899 'icalendar t 901 'icalendar t
900 '(:ascii-charset utf-8 :ascii-links-to-notes nil 902 '(:ascii-charset utf-8 :ascii-links-to-notes nil
diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el
index f11a8a63a2a..ec4b49585f8 100644
--- a/lisp/org/ox-latex.el
+++ b/lisp/org/ox-latex.el
@@ -1623,15 +1623,15 @@ non-nil, only includes packages relevant to image generation, as
1623specified in `org-latex-default-packages-alist' or 1623specified in `org-latex-default-packages-alist' or
1624`org-latex-packages-alist'." 1624`org-latex-packages-alist'."
1625 (let* ((class (plist-get info :latex-class)) 1625 (let* ((class (plist-get info :latex-class))
1626 (class-options (plist-get info :latex-class-options))
1627 (header (nth 1 (assoc class (plist-get info :latex-classes))))
1628 (class-template 1626 (class-template
1629 (or template 1627 (or template
1630 (and (stringp header) 1628 (let* ((class-options (plist-get info :latex-class-options))
1631 (if (not class-options) header 1629 (header (nth 1 (assoc class (plist-get info :latex-classes)))))
1632 (replace-regexp-in-string 1630 (and (stringp header)
1633 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)" 1631 (if (not class-options) header
1634 class-options header t nil 1))) 1632 (replace-regexp-in-string
1633 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
1634 class-options header t nil 1))))
1635 (user-error "Unknown LaTeX class `%s'" class)))) 1635 (user-error "Unknown LaTeX class `%s'" class))))
1636 (org-latex-guess-polyglossia-language 1636 (org-latex-guess-polyglossia-language
1637 (org-latex-guess-babel-language 1637 (org-latex-guess-babel-language
@@ -1644,7 +1644,9 @@ specified in `org-latex-default-packages-alist' or
1644 snippet? 1644 snippet?
1645 (mapconcat #'org-element-normalize-string 1645 (mapconcat #'org-element-normalize-string
1646 (list (plist-get info :latex-header) 1646 (list (plist-get info :latex-header)
1647 (plist-get info :latex-header-extra)) "")))) 1647 (and (not snippet?)
1648 (plist-get info :latex-header-extra)))
1649 ""))))
1648 info) 1650 info)
1649 info))) 1651 info)))
1650 1652
diff --git a/lisp/org/ox-md.el b/lisp/org/ox-md.el
index c8ea1fa045e..2478cc6ab8f 100644
--- a/lisp/org/ox-md.el
+++ b/lisp/org/ox-md.el
@@ -395,8 +395,9 @@ a communication channel."
395 (org-export-get-reference destination info)))))))) 395 (org-export-get-reference destination info))))))))
396 ((org-export-inline-image-p link org-html-inline-image-rules) 396 ((org-export-inline-image-p link org-html-inline-image-rules)
397 (let ((path (let ((raw-path (org-element-property :path link))) 397 (let ((path (let ((raw-path (org-element-property :path link)))
398 (if (not (file-name-absolute-p raw-path)) raw-path 398 (cond ((not (equal "file" type)) (concat type ":" raw-path))
399 (expand-file-name raw-path)))) 399 ((not (file-name-absolute-p raw-path)) raw-path)
400 (t (expand-file-name raw-path)))))
400 (caption (org-export-data 401 (caption (org-export-data
401 (org-export-get-caption 402 (org-export-get-caption
402 (org-export-get-parent-element link)) info))) 403 (org-export-get-parent-element link)) info)))
@@ -411,7 +412,7 @@ a communication channel."
411 (t (let* ((raw-path (org-element-property :path link)) 412 (t (let* ((raw-path (org-element-property :path link))
412 (path 413 (path
413 (cond 414 (cond
414 ((member type '("http" "https" "ftp")) 415 ((member type '("http" "https" "ftp" "mailto" "irc"))
415 (concat type ":" raw-path)) 416 (concat type ":" raw-path))
416 ((string= type "file") 417 ((string= type "file")
417 (org-export-file-uri (funcall link-org-files-as-md raw-path))) 418 (org-export-file-uri (funcall link-org-files-as-md raw-path)))
diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
index 943a6be0310..75554689aaf 100644
--- a/lisp/org/ox-odt.el
+++ b/lisp/org/ox-odt.el
@@ -112,7 +112,9 @@
112 (:odt-table-styles nil nil org-odt-table-styles) 112 (:odt-table-styles nil nil org-odt-table-styles)
113 (:odt-use-date-fields nil nil org-odt-use-date-fields) 113 (:odt-use-date-fields nil nil org-odt-use-date-fields)
114 ;; Redefine regular option. 114 ;; Redefine regular option.
115 (:with-latex nil "tex" org-odt-with-latex))) 115 (:with-latex nil "tex" org-odt-with-latex)
116 ;; Retrieve LaTeX header for fragments.
117 (:latex-header "LATEX_HEADER" nil nil newline)))
116 118
117 119
118;;; Dependencies 120;;; Dependencies
@@ -3731,42 +3733,45 @@ contextual information."
3731 (mathml (format "Creating MathML snippet %d..." count)))) 3733 (mathml (format "Creating MathML snippet %d..." count))))
3732 ;; Get an Org-style link to PNG image or the MathML 3734 ;; Get an Org-style link to PNG image or the MathML
3733 ;; file. 3735 ;; file.
3734 (org-link 3736 (link
3735 (let ((link (with-temp-buffer 3737 (with-temp-buffer
3736 (insert latex-frag) 3738 (insert latex-frag)
3737 (org-format-latex cache-subdir nil nil cache-dir 3739 ;; When converting to a PNG image, make sure to
3738 nil display-msg nil 3740 ;; copy all LaTeX header specifications from the
3739 processing-type) 3741 ;; Org source.
3740 (buffer-substring-no-properties 3742 (unless (eq processing-type 'mathml)
3741 (point-min) (point-max))))) 3743 (let ((h (plist-get info :latex-header)))
3742 (if (string-match-p "file:\\([^]]*\\)" link) link 3744 (when h
3743 (message "LaTeX Conversion failed.") 3745 (insert "\n"
3744 nil)))) 3746 (replace-regexp-in-string
3745 (when org-link 3747 "^" "#+LATEX_HEADER: " h)))))
3748 (org-format-latex cache-subdir nil nil cache-dir
3749 nil display-msg nil
3750 processing-type)
3751 (goto-char (point-min))
3752 (org-element-link-parser))))
3753 (if (not (eq 'link (org-element-type link)))
3754 (message "LaTeX Conversion failed.")
3746 ;; Conversion succeeded. Parse above Org-style link to 3755 ;; Conversion succeeded. Parse above Org-style link to
3747 ;; a `link' object. 3756 ;; a `link' object.
3748 (let* ((link 3757 (let ((replacement
3749 (org-element-map 3758 (cl-case (org-element-type latex-*)
3750 (org-element-parse-secondary-string org-link '(link)) 3759 ;;LaTeX environment. Mimic a "standalone image
3751 'link #'identity info t)) 3760 ;; or formula" by enclosing the `link' in
3752 (replacement 3761 ;; a `paragraph'. Copy over original
3753 (cl-case (org-element-type latex-*) 3762 ;; attributes, captions to the enclosing
3754 ;; Case 1: LaTeX environment. Mimic 3763 ;; paragraph.
3755 ;; a "standalone image or formula" by 3764 (latex-environment
3756 ;; enclosing the `link' in a `paragraph'. 3765 (org-element-adopt-elements
3757 ;; Copy over original attributes, captions to 3766 (list 'paragraph
3758 ;; the enclosing paragraph. 3767 (list :style "OrgFormula"
3759 (latex-environment 3768 :name
3760 (org-element-adopt-elements 3769 (org-element-property :name latex-*)
3761 (list 'paragraph 3770 :caption
3762 (list :style "OrgFormula" 3771 (org-element-property :caption latex-*)))
3763 :name 3772 link))
3764 (org-element-property :name latex-*) 3773 ;; LaTeX fragment. No special action.
3765 :caption 3774 (latex-fragment link))))
3766 (org-element-property :caption latex-*)))
3767 link))
3768 ;; Case 2: LaTeX fragment. No special action.
3769 (latex-fragment link))))
3770 ;; Note down the object that link replaces. 3775 ;; Note down the object that link replaces.
3771 (org-element-put-property replacement :replaces 3776 (org-element-put-property replacement :replaces
3772 (list (org-element-type latex-*) 3777 (list (org-element-type latex-*)
diff --git a/lisp/org/ox.el b/lisp/org/ox.el
index f39a3952e76..7d2f3d1714a 100644
--- a/lisp/org/ox.el
+++ b/lisp/org/ox.el
@@ -2712,14 +2712,11 @@ from tree."
2712 (org-element-map data '(footnote-definition footnote-reference) 2712 (org-element-map data '(footnote-definition footnote-reference)
2713 (lambda (f) 2713 (lambda (f)
2714 (cond 2714 (cond
2715 ((eq (org-element-type f) 'footnote-definition) f) 2715 ((eq 'footnote-definition (org-element-type f)) f)
2716 ((eq (org-element-property :type f) 'standard) nil) 2716 ((and (eq 'inline (org-element-property :type f))
2717 (t (let ((label (org-element-property :label f))) 2717 (org-element-property :label f))
2718 (when label ;Skip anonymous references. 2718 f)
2719 (apply 2719 (t nil))))))
2720 #'org-element-create
2721 'footnote-definition `(:label ,label :post-blank 1)
2722 (org-element-contents f))))))))))
2723 ;; If a select tag is active, also ignore the section before the 2720 ;; If a select tag is active, also ignore the section before the
2724 ;; first headline, if any. 2721 ;; first headline, if any.
2725 (when selected 2722 (when selected