ob-exp: Fix code indentation after src block evaluation

* lisp/ob-exp.el (org-export-blocks-preprocess): Do not use
  `indent-code-rigidly' as it doesn't indent contents of strings.
org-export: Fix smart quote bug with footnote definitions in ascii back-end

* contrib/lisp/org-export.el (org-export-activate-smart-quotes): Fix
  error when exporting a footnote definition.
org-exp.el (org-export-normalize-links): Don't match links within tags

* org-exp.el (org-export-normalize-links): Don't match links
within tags.

A headline with tags like :info:test: would not be exported correctly
because info:test is first matched and normalized as a link.
Merge branch 'maint'
org.el (org-get-wdays): Handle matching a lead time specified in hours

* org.el (org-get-wdays): Handle matching a lead time specified in
hours.

TINYCHANGE

A lead time in hours is matched but will erroneously return nil.
Merge branch 'maint'
org-agenda.el: Bugfix.

* org-agenda.el (org-agenda-get-deadlines)
(org-agenda-get-scheduled): Fix bug: use text properties for
the headline text since we rely on properties to get e.g. the
effort.
Merge branch 'maint'

Conflicts:
	lisp/org-agenda.el
org-agenda.el: Implement new sorting strategies

* org-agenda.el (org-agenda-sorting-strategy): Document the
new sorting strategies.
(org-agenda-get-todos, org-agenda-get-timestamps)
(org-agenda-get-deadlines, org-agenda-get-scheduled): Add a
`ts-date' text property with scheduled, deadline or timetamp
date.
(org-cmp-ts): New function to compare timestamps.
(org-em): Add a docstring.
(org-entries-lessp): Use `org-cmp-ts' to compare timestamps.
Implement the following sorting strategies: timestamp-up/down,
scheduled-up/down, deadline-up/down, ts-up/down (for active
timestamps) and tsia-up/down (for inactive timestamps.)
Implement "delay" cookies for scheduled items.

* org-agenda.el (org-agenda-skip-scheduled-delay-if-deadline):
New option.  The structure of the possible values is copied
from `org-agenda-skip-deadline-prewarning-if-scheduled'.
(org-agenda-get-scheduled): Honor the two new option,
`org-scheduled-delay-days' and
`org-agenda-skip-deadline-prewarning-if-scheduled'.  I.e. if a
scheduled entry has a delay cookie like "-2d" (similar to the
prewarning cookie for deadline), don't show the entry until
needed.

* org.el (org-deadline-warning-days): Small docstring fix.
(org-scheduled-delay-days): New option (see
`org-deadline-warning-days'.)
(org-get-wdays): Use the new option.

Thanks to Andrew M. Nuxoll and Michael Brand for this idea.

You can now use a "delay cookie" in scheduled items.  For example,

* TODO Sleep
  SCHEDULED: <2013-02-06 mer. -3d>

will not be shown on 06/02 but on 09/02, three days later.

The value of the cookie overrides any value of `org-scheduled-delay-days',
unless `org-scheduled-delay-days' is negative (same logic than for
`org-deadline-warning-days'.)

Also check org-agenda-skip-scheduled-delay-if-deadline, which does for
delay cookies what `org-agenda-skip-deadline-prewarning-if-scheduled' does
for prewarning deadline cookies.
org.el: Allow C-u C-u to insert a warning/delay cookie for org-deadline/org-schedule

* org.el (org-deadline): Allow a double universal prefix
argument to insert/update a warning cookie.
(org-deadline): Allow a double universal prefix argument to
insert/update a delay cookie.
org-agenda.el: New options to limit the number of displayed entries

* org-agenda.el (org-agenda-max-entries)
(org-agenda-max-todos, org-agenda-max-tags)
(org-agenda-max-effort): New options.
(org-timeline, org-agenda-list, org-search-view)
(org-todo-list, org-tags-view): Tell
`org-agenda-finalize-entries' what agenda type we are
currently finalizing for.
(org-agenda-finalize-entries): Limit the number of entries
depending on the new options.
(org-agenda-limit-entries): New function.

Thanks to the various people who asked for this feature
or for a variation of it.

You can set the new options to an integer or to an alist.

(setq org-agenda-max-effort 120)
  => Don't display entries beyond 120 minutes of effort

(setq org-agenda-max-effort '((todo . 60) (agenda . 240)))
  => Limit to 60 minutes in TODO agenda and to 240 in
     "agenda" agenda views.
Move new export framework files into core

* contrib/README: Remove references to new export framework.
* contrib/lisp/org-e-ascii.el: Removed file.
* contrib/lisp/org-e-beamer.el: Removed file.
* contrib/lisp/org-e-confluence.el: Removed file.
* contrib/lisp/org-e-groff.el: Removed file.
* contrib/lisp/org-e-html.el: Removed file.
* contrib/lisp/org-e-icalendar.el: Removed file.
* contrib/lisp/org-e-latex.el: Removed file.
* contrib/lisp/org-e-man.el: Removed file.
* contrib/lisp/org-e-odt.el: Removed file.
* contrib/lisp/org-e-publish.el: Removed file.
* contrib/lisp/org-e-texinfo.el: Removed file.
* contrib/lisp/org-export.el: Removed file.
* contrib/lisp/org-koma-letter.el: Removed file.
* contrib/lisp/org-md.el: Removed file.
* contrib/lisp/ox-confluence.el: New file.
* contrib/lisp/ox-groff.el: New file.
* contrib/lisp/ox-koma-letter.el: New file.
* lisp/ox-ascii.el: New file.
* lisp/ox-beamer.el: New file.
* lisp/ox-html.el: New file.
* lisp/ox-icalendar.el: New file.
* lisp/ox-jsinfo.el: New file.
* lisp/ox-latex.el: New file.
* lisp/ox-man.el: New file.
* lisp/ox-md.el: New file.
* lisp/ox-odt.el: New file.
* lisp/ox-publish.el: New file.
* lisp/ox-texinfo.el: New file.
* lisp/ox.el: New file.
* mk/org-fixup.el (org-make-org-loaddefs): Install new export
  framework and back-end files.
* testing/lisp/test-org-export.el: Removed file.
* testing/lisp/test-ox.el: New file.
Move previous export framework into contrib

* contrib/lisp/org-ascii.el: New file.
* contrib/lisp/org-beamer.el: New file.
* contrib/lisp/org-docbook.el: New file.
* contrib/lisp/org-exp-blocks.el: New file.
* contrib/lisp/org-exp.el: New file.
* contrib/lisp/org-freemind.el: New file.
* contrib/lisp/org-html.el: New file.
* contrib/lisp/org-icalendar.el: New file.
* contrib/lisp/org-jsinfo.el: New file.
* contrib/lisp/org-latex.el: New file.
* contrib/lisp/org-lparse.el: New file.
* contrib/lisp/org-odt.el: New file.
* contrib/lisp/org-publish.el: New file.
* contrib/lisp/org-special-blocks.el: New file.
* contrib/lisp/org-taskjuggler.el: New file.
* contrib/lisp/org-xoxo.el: New file.
* lisp/org-ascii.el: Removed file.
* lisp/org-beamer.el: Removed file.
* lisp/org-docbook.el: Removed file.
* lisp/org-exp-blocks.el: Removed file.
* lisp/org-exp.el: Removed file.
* lisp/org-freemind.el: Removed file.
* lisp/org-html.el: Removed file.
* lisp/org-icalendar.el: Removed file.
* lisp/org-jsinfo.el: Removed file.
* lisp/org-latex.el: Removed file.
* lisp/org-lparse.el: Removed file.
* lisp/org-odt.el: Removed file.
* lisp/org-publish.el: Removed file.
* lisp/org-special-blocks.el: Removed file.
* lisp/org-taskjuggler.el: Removed file.
* lisp/org-xoxo.el: Removed file.
* testing/lisp/test-org-exp.el: Removed file.
* testing/lisp/test-org-html.el: Removed file.
Install new exporter into Org innards

* contrib/lisp/org-mime.el (org-mime-htmlize, org-mime-compose): Use
  new exporter.
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Use new
  exporter.
* lisp/ob-latex.el (org-babel-execute:latex): Use new exporter.
* lisp/ob-org.el (org-babel-execute:org): Use new exporter.
* lisp/org-agenda.el (org-agenda-menu, org-agenda-write): Use new
  iCalendar export back-end.
* lisp/org-table.el (org-table-export, orgtbl-export): Remove
  dependency on `org-exp' library.
(org-table-clean-before-export): New function.
(org-table-colgroup-info): New variable.
(orgtbl-to-html): Use to new HTML export back-end.
* lisp/org.el (org-modules): Remove modules relative to obsolete
  export framework and add those relative to the new one.
(org-create-formula-image-with-dvipng, org-format-latex
org-create-formula-image-with-imagemagick): Use new exporter.
(org-indent-line): INCLUDE keywords are indented like regular
keywords.
(org-mode-map): Bind C-c C-e to new export dispatcher.
(org-menu): Install new exporter in menu.
Remove unnecessary linking to export framework

* lisp/org-clock.el (org-clocktable-defaults,
  org-clocktable-write-default): Avoid requiring the whole export
  framework just to check one variable.
* lisp/org-footnote.el (org-footnote-section): Update
  docstring.
(org-footnote-normalize): Remove all export related part from the
  function.
* lisp/org-inlinetask.el (org-inlinetask-export,
  org-inlinetask-export-templates): Removed variables.
(org-inlinetask-export-handler): Removed function.
* lisp/org-plot.el: Remove dependency on `org-exp' library.
* lisp/org.el (org-additional-option-like-keywords): Remove variable.
(org-get-export-keywords): New function.
(org-options-keywords): Update default list of keywords.
(org-remove-flyspell-overlays-in): Apply changes to keywords
compilation.
(org-highlight-latex-fragments-and-specials)
org-latex-and-specials-regexp,
org-export-html-special-string-regexps): Remove variables.
(org-compute-latex-and-specials-regexp,
org-do-latex-and-special-faces, org-remove-file-link-modifiers):
Remove functions.
(org-set-regexps-and-options, org-set-font-lock-defaults): Apply all
removals.
(org-use-sub-superscripts): Fix docstring.  Remove unused group.
(org-match-sexp-depth): Make it a defconst instead of a defcustom in
order to remove `org-export-translation' group completely.

The new export framework shouldn't be as much interleaved with Org
core as with the previous one.  For example, export options, which are
back-end dependent, shouldn't interfere with the display of the
buffer.
org-pcomplete: Modify completion for buffer keywords

* lisp/org-pcomplete.el (pcomplete/org-mode/file-option): Collect
  valid keywords for completion without requiring the whole export
  framework.
(pcomplete/org-mode/file-option/options): Rewrite using new export
  framework.  Only complete up to the colon.
(pcomplete/org-mode/file-option/x): Removed macro.
(pcomplete/org-mode/file-option/title,
 pcomplete/org-mode/file-option/author,
 pcomplete/org-mode/file-option/email,
 pcomplete/org-mode/file-option/date): Removed functions.
(pcomplete/org-mode/file-option/infojs_opt): New function.

Completion for some keywords was removed because it provided only the
default value, which is the same as not writing the keyword at all.  In
other words, a user would almost always want to modify the completed
value, which makes the completion moot.
Fix tests related to export

* lisp/ob-exp.el (org-babel-exp-process-buffer): Renamed from
  `org-export-blocks-preprocess'.
* lisp/ox.el (org-export-execute-babel-code): Apply previous renaming.
* testing/org-test.el (org-test-at-id): Make sure the function returns
  the value of the last form in its body.
* testing/lisp/test-ob-exp.el: Fix tests.
* testing/lisp/test-ob-lob.el: Fix tests.
Remove references to `org-protected' `org-example' and `original-indentation'

* lisp/org-macs.el (org-if-unprotected, org-if-unprotected-1,
  org-if-unprotected-at): Removed macros.
(org-re-search-forward-unprotected): Removed function.
* lisp/org.el (org-format-latex): Remove reference to `org-protected'.
* lisp/org-list.el (org-list-struct): Remove reference to
  `org-example' and `org-protected'.
* lisp/org-footnote.el (org-footnote-at-reference-p): Remove reference
  to `org-protected'.
* lisp/org-capture.el (org-capture-fill-template): Remove reference to
  `org-protected'.
* contrib/lisp/org-wikinodes.el (org-wikinodes-process-links-for-export):
  Remove reference to `org-protected' value.

These text properties were used by the old export framework. They are
not needed anymore.
Manage variables related to both LaTeX export and snippets

* lisp/org.el (org-format-latex-header-extra, org-export-have-math):
  Removed variables.
(org-latex-default-packages-alist): Renamed from
`org-export-latex-default-packages-alist'.
(org-latex-packages-alist): Renamed from
`org-export-latex-packages-alist'.
(org-try-cdlatex-tab, org-cdlatex-underscore-caret,
org-cdlatex-math-modify): Reorder in file.
(org-format-latex): Remove `org-format-latex-header-extra'.
(org-create-formula-image-with-dvipng,
org-create-formula-image-with-imagemagick): Apply variables renaming
and removal.
* lisp/org-entities.el (org-entities-user): Update docstring.
* lisp/ox-latex.el (org-latex-classes, org-latex-listings): Update
  docstring.
(org-latex-guess-inputenc): Renamed from `org-latex--guess-inputenc'.
(org-latex-guess-babel-language): Renamed from
`org-latex--guess-babel-language'.
(org-latex-template): Apply renaming.
* lisp/ox-beamer.el (org-beamer-template): Apply renaming.
* lisp/ob-latex.el (org-babel-execute:latex): Apply variable renaming
  and removal.
(org-babel-latex-tex-to-pdf): Call `org-latex-compile' instead of
copying it.