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.
Merge branch 'maint'
ob-exp: Fix a failing test

* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
  Fix a test
Merge branch 'maint'
org-element: Comply to Emacs 23 signature requirements

* lisp/org-element.el (org-element--cache-sync): Call
  `avl-tree-delete' with 2 arguments only as a 4-arguments call is
  only compatible with Emacs 24.1 and later.
org-agenda.el: Fix buglets

* org-agenda.el (org-agenda-next-item)
(org-agenda-previous-item, org-agenda-toggle-archive-tag)
(org-agenda-todo, org-agenda-priority, org-agenda-clock-in)
(org-agenda-clock-out): Put the cursor back on the correct
column, when possible.
(org-agenda-todo): When `org-clock-out-when-done' is `t', also
remove the current clock overlay.
org.el (org-priority): Don't use `org-preserve-lc'

* org.el (org-priority): Don't use `org-preserve-lc' as it is
not necessary here.
Merge branch 'maint'
mention ob-sh renamed to ob-shell in ORG-NEWS
org-element: Preserve Emacs 23 compatibility

* lisp/org-element.el (org-element--cache-mapc): New function.
(org-element--cache-sync): Use new function.

`avl-tree-mapc' exists in Emacs 24's "avl-tree" but not in Emacs
23's. The new function implements it.
ox-md: Set correctly blank lines between elements

* lisp/ox-md (org-md-separate-elements): Fix blank line insertion
  between elements.
* lisp/ox-md.el (org-md-inner-template): New function.