Backport Emacs changes from r116063
Merge branch 'maint'
ob-exp: Fix code execution in some corner cases

* lisp/ob-exp.el (org-babel-exp-process-buffer): Make processing more
  robust when results are inserted before source block or when source
  block is followed by multiple blank lines.
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
  Add test.
Merge branch 'maint'
renamed test file for shell code blocks
updated names in test-ob-shell
do not eval vars in call lines before hashing

* lisp/ob-lob.el (org-babel-lob-execute): Do not eval vars in call
  lines before hashing, because for a call lines variable
  expansion *is* evaluation.
test of caching call line behavior
failing test of named caching call line
named and caching call lines working

* lisp/ob-core.el (org-babel-current-result-hash): Additional info
  argument so that named call line results may be found.
  (org-babel-set-current-result-hash): Additional info argument so
  that named call line results may be found.
* lisp/ob-lob.el (org-babel-lob-execute): Passing info to hash finding
  functions so that named results may be found.
org-element: Small optimization

* lisp/org-element.el (org-element-at-point): Do not call
  `outline-next-heading' when an element at top level contains point.
  This is particularly important when the current section ends way
  after the point.
ox.el (org-export--get-subtree-options): Fix bug

* ox.el (org-export--get-subtree-options): When using the
headline as a title for a subtree export, only take the true
heading, no TODO keyword, no priority cookie, no tag.

Thanks to Robert Klein for reporting this.
Merge branch 'maint'
org.el (org-format-latex-options): Fix docstring

* org.el (org-format-latex-options): Fix docstring.

Thanks to Mirko Vukovic for reporting this.
Merge branch 'maint'
Fix ae0f1c56a7934cde23d30e5481510cbe79562fea

* lisp/org.el (org-toggle-item): Fix ae0f1c56a7934cde23d30e5481510cbe79562fea.
Fix `org-outline-overlay-data' marker insertion-type

* org.el (org-outline-overlay-data): Set the insertion-type of end
bound marker of the function to t (means marker advances when you
insert text at it)

This is to conserve outline visibility property when changes are made
at the end bound of the data.
For example: try `org-babel-execute-subtree' on a folded outline:
The new result will be shown after the folded part of the outline
whereas the outline body should not be visible.

TINYCHANGE
ob-exp: Fix export of src blocks with flags

* lisp/ob-exp.el (org-babel-exp-code): Fix export of src blocks with
  flags.
* testing/lisp/test-ob-exp.el (ob-export/export-src-block-with-flags):
  New test.

Thanks to Giuseppe Lipari for reporting it.
org.el: New command org-insert-last-stored-link bound to `C-c M-l'

* org.el (org-insert-all-links): New parameters `pre' and
`post' to specify a string to preprend and append.
(org-insert-last-stored-link): New command.
(org-mode-map): Bind the new command to `C-c M-l'.

Thanks to Sébastien Vauban for requesting this and to Nick
Dokos for testing and fixing the patch.
org.el (org-provide-todo-statistics): Allow to set to a list of two lists, for TODO and DONE keywords

* org.el (org-provide-todo-statistics): Allow to set to a list
of two lists, one with TODO keywords, the other one with DONE
keywords.
(org-update-parent-todo-statistics): Correctly handle
`org-provide-todo-statistics' when it is set as a list of two
lists, for TODO and DONE keywords.

Thanks to Fletcher Charest for reporting this and requesting
this feature.